]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
lockd: fix "list_add double add" caused by legacy signal interface
authorVasily Averin <vvs@virtuozzo.com>
Mon, 13 Nov 2017 04:25:40 +0000 (07:25 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 3 Apr 2018 10:29:55 +0000 (12:29 +0200)
commit784d2f8d63a4cf9b88804bc792e4660bf576a7d7
tree61cfde2650fd86bc8576b0dd08cacf4c6d9ab4cd
parent85cba5c5161aebd93f2ab22ddc0c0ea68483a814
lockd: fix "list_add double add" caused by legacy signal interface

BugLink: http://bugs.launchpad.net/bugs/1755509
[ Upstream commit 81833de1a46edce9ca20cfe079872ac1c20ef359 ]

restart_grace() uses hardcoded init_net.
It can cause to "list_add double add" in following scenario:

1) nfsd and lockd was started in several net namespaces
2) nfsd in init_net was stopped (lockd was not stopped because
 it have users from another net namespaces)
3) lockd got signal, called restart_grace() -> set_grace_period()
 and enabled lock_manager in hardcoded init_net.
4) nfsd in init_net is started again,
 its lockd_up() calls set_grace_period() and tries to add
 lock_manager into init_net 2nd time.

Jeff Layton suggest:
"Make it safe to call locks_start_grace multiple times on the same
lock_manager. If it's already on the global grace_list, then don't try
to add it again.  (But we don't intentionally add twice, so for now we
WARN about that case.)

With this change, we also need to ensure that the nfsd4 lock manager
initializes the list before we call locks_start_grace. While we're at
it, move the rest of the nfsd_net initialization into
nfs4_state_create_net. I see no reason to have it spread over two
functions like it is today."

Suggested patch was updated to generate warning in described situation.

Suggested-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/nfs_common/grace.c
fs/nfsd/nfs4state.c