Received: by 10.192.165.156 with SMTP id m28csp1206440imm; Wed, 11 Apr 2018 14:34:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx49iVoXkBTlhA3mKf0TkBBS8pvaLtGy3mFOhplGzRoLFqq/WxrB9F3qh5NAdCgauJk6bSmlG X-Received: by 10.99.119.195 with SMTP id s186mr4700839pgc.453.1523482460735; Wed, 11 Apr 2018 14:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523482460; cv=none; d=google.com; s=arc-20160816; b=LkBM8+g25PKZWtZRpVzui4+t1jvH0SoP2vHVNeBbJpGGKAMP1zBcsWVF+qZ9vrFyi1 C4yY8WMWgcqrE5mwP28pjvRrInWh9+9BbaydQU1AVULwELw1yvN9NDtq/i3IVNJ9g+G0 LquuI9YiYrCfH16B9I5NdCk/R5VnZ2ni82h3Lyd5GkIHMWiWgViAUyp0aQnM96Vx1Tx0 RQJxcIm4RZ+wrRbF2Y2ik2r4cIpQm0F11T3dS4JsEsplKl1yKkxHE3Wyf2arq8xJYfbQ g9ujjIWuR7jPRsaw96wyV4llRQIlAuVcg8DTvDCJ9v29sG+TEd5WmrFLadr9FlC0V3Qu RQkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mvKVCjYHe/nJ3jqq6C8Z1WmlTgsT71z/iUwVC6HScl4=; b=T5iMJVg7ZScXRrCnKTOnDXRygd2t3BnjfqJ1p1DLmfHqpL5XzuLrPp1FvFZ6/XUe3q WasVbwItq7MhFMcWOAvK3ENMzUAdKr8WIGwOyXPDo65p3HqOy/vqtvFcvbPVHF55bWiw ShgleMEoXOWw17821menwOSO87FlH3fRb130jv9WyJi1Og7vyEVHWF0zpFxHJBVP7lOA lMhHXx7qugO1vCFL741R79MQuA1uk/vYkgsaQ6hN44CznUvN+WZrRea0+FJ/oOUJyXgU r9W1bljkf5kR2pTa8K4QCGGNSL0qqU8CwrK18V2UrM6acJcI66DKIkbVVXxFB0pLEEMs Xzug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q28si1220740pgc.614.2018.04.11.14.33.44; Wed, 11 Apr 2018 14:34:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754420AbeDKV0O (ORCPT + 99 others); Wed, 11 Apr 2018 17:26:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55302 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754016AbeDKSiR (ORCPT ); Wed, 11 Apr 2018 14:38:17 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 49ACFE38; Wed, 11 Apr 2018 18:38:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Jeffery , "J. Bruce Fields" , Sasha Levin Subject: [PATCH 3.18 008/121] lockd: fix lockd shutdown race Date: Wed, 11 Apr 2018 20:35:11 +0200 Message-Id: <20180411183456.733325116@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183456.195010921@linuxfoundation.org> References: <20180411183456.195010921@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: "J. Bruce Fields" [ Upstream commit efda760fe95ea15291853c8fa9235c32d319cd98 ] As reported by David Jeffery: "a signal was sent to lockd while lockd was shutting down from a request to stop nfs. The signal causes lockd to call restart_grace() which puts the lockd_net structure on the grace list. If this signal is received at the wrong time, it will occur after lockd_down_net() has called locks_end_grace() but before lockd_down_net() stops the lockd thread. This leads to lockd putting the lockd_net structure back on the grace list, then exiting without anything removing it from the list." So, perform the final locks_end_grace() from the the lockd thread; this ensures it's serialized with respect to restart_grace(). Reported-by: David Jeffery Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/lockd/svc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -129,6 +129,8 @@ lockd(void *vrqstp) { int err = 0; struct svc_rqst *rqstp = vrqstp; + struct net *net = &init_net; + struct lockd_net *ln = net_generic(net, lockd_net_id); /* try_to_freeze() is called from svc_recv() */ set_freezable(); @@ -173,6 +175,8 @@ lockd(void *vrqstp) if (nlmsvc_ops) nlmsvc_invalidate_all(); nlm_shutdown_hosts(); + cancel_delayed_work_sync(&ln->grace_period_end); + locks_end_grace(&ln->lockd_manager); return 0; } @@ -267,8 +271,6 @@ static void lockd_down_net(struct svc_se 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("lockd_down_net: per-net data destroyed; net=%p\n", net); }