[RHEL7,COMMIT] ms/lockd: lost rollback of set_grace_period() in lockd_down_net()

Submitted by Konstantin Khorenko on July 4, 2018, 3:44 p.m.


Message ID 201807041544.w64FiBX3009509@finist_ce7.work
State New
Series "ms/lockd: fix "list_add double add" caused by legacy signal interface"
Headers show

Commit Message

Konstantin Khorenko July 4, 2018, 3:44 p.m.
The commit is pushed to "branch-rh7-3.10.0-862.3.2.vz7.61.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.3.2.vz7.61.12
commit 9740a12cc5e25a789afe0a8705de2a363b009798
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Thu Nov 2 13:03:42 2017 +0300

    ms/lockd: lost rollback of set_grace_period() in lockd_down_net()
    Commit efda760fe95ea ("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: efda760fe95e ("lockd: fix lockd shutdown race")
    Cc: stable@vger.kernel.org
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    This patch should actually fix
    (cherry picked from commit 3a2b19d1ee5633f76ae8a88da7bc039a5d1732aa)
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
 fs/lockd/svc.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index b52fd0feeac6..d2cffb3bbec3 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -278,6 +278,8 @@  static void lockd_down_net(struct svc_serv *serv, struct net *net)
 	if (ln->nlmsvc_users) {
 		if (--ln->nlmsvc_users == 0) {
+			cancel_delayed_work_sync(&ln->grace_period_end);
+			locks_end_grace(&ln->lockd_manager);
 			svc_shutdown_net(serv, net);
 			dprintk("lockd_down_net: per-net data destroyed; net=%p\n", net);