Received: by 10.192.165.156 with SMTP id m28csp1148644imm; Wed, 11 Apr 2018 13:21:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/s3syF0LIxMfwz30/UKs7xqC/DdI7FEsO5G8VsgebfGjltCSx8JWN2T/LFzPnjuUeIQ8I+ X-Received: by 10.99.54.65 with SMTP id d62mr4463101pga.225.1523478070757; Wed, 11 Apr 2018 13:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523478070; cv=none; d=google.com; s=arc-20160816; b=eDKS5j8fU1hiIhkNiY6Yv+TPwCPusKPmvhFerB3Z7484CA9h/meBNrIZdJZgSDdqvi yjKs4K+SuBClwKngj0DQITBqdg8tRTQ3ZgVkVyIHKp5jpwvpyu9/pxWGhpNWc212GYGZ IzAj+Bp3v7PLLMLZOzVDziypD0yQM5PGbbJSorp+xcwv/2CAAmDgOdNj4gEaDvkAqunf se7TnImYT4zYYKuwaSwNSDPJ7qBu+yhULVhCPbmMTPKo7LX5N2Jc+zRYZ6mAMruXK/zg mK9FdTLt9AXq0mJFjJczmm89F+YdYQ3nfzzUYhZPmNX24Fhnsu9qUXtw2AqC338mdzB0 WrKA== 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=sctOOFB6cOgfjgCzq/j38cEtSaYK9tsFrRgshV0hHqw=; b=NiqmuIEx9pZAq1vcW3Y60IAFkQMHlAfPpC6qThuzBw6+qQChWn/UEzlXAl49xb10Ai YQH0EUbq+0lZ40v6Goz8cTcBbM1uH+NdtoLGsdV4+w1qF84kCIIlV2ci/i9jXxqyi4mK ngw/yQzZW1DjHAgOI8kuRhwLajV84X8zHMWFUw8LsWiXzuJJA4AKATchXwGhXnKxJoIV oKyE3XHrrflxFJMB5E1tTOz/V39mMkiqsN2M7xOsPsmXDw2S14SJOmwFwEDe7L3qsl5/ KeNPXKlYrlwxZ9OaU98pNaeQX4KMtBBknUstcXmf+9a+4cZw7MomGVVuAX28cF49nRp0 5ZZw== 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 z11-v6si1749745plo.243.2018.04.11.13.20.34; Wed, 11 Apr 2018 13:21:10 -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 S933252AbeDKSxU (ORCPT + 99 others); Wed, 11 Apr 2018 14:53:20 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33708 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932401AbeDKSxS (ORCPT ); Wed, 11 Apr 2018 14:53:18 -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 CEEB0E97; Wed, 11 Apr 2018 18:53:17 +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 4.9 020/310] lockd: fix lockd shutdown race Date: Wed, 11 Apr 2018 20:32:39 +0200 Message-Id: <20180411183623.164151668@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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 4.9-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 @@ -132,6 +132,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(); @@ -176,6 +178,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; } @@ -270,8 +274,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); }