Skip to content

Commit

Permalink
lockd: lost rollback of set_grace_period() in lockd_down_net()
Browse files Browse the repository at this point in the history
Commit efda760 ("lockd: fix lockd shutdown race") is incorrect,
it removes lockd_manager and disarm grace_period_end for init_net only.

If nfsd was started from another net namespace lockd_up_net() calls
set_grace_period() that adds lockd_manager into per-netns list
and queues grace_period_end delayed work.

These action should be reverted in lockd_down_net().
Otherwise it can lead to double list_add on after restart nfsd in netns,
and to use-after-free if non-disarmed delayed work will be executed after netns destroy.

Fixes: efda760 ("lockd: fix lockd shutdown race")
Cc: [email protected]
Signed-off-by: Vasily Averin <[email protected]>
Signed-off-by: J. Bruce Fields <[email protected]>
  • Loading branch information
vaverin authored and J. Bruce Fields committed Nov 27, 2017
1 parent a3152f1 commit 3a2b19d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/lockd/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net)
if (ln->nlmsvc_users) {
if (--ln->nlmsvc_users == 0) {
nlm_shutdown_hosts_net(net);
cancel_delayed_work_sync(&ln->grace_period_end);
locks_end_grace(&ln->lockd_manager);
svc_shutdown_net(serv, net);
dprintk("%s: per-net data destroyed; net=%x\n",
__func__, net->ns.inum);
Expand Down

0 comments on commit 3a2b19d

Please sign in to comment.