Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3248189imu; Sat, 24 Nov 2018 01:02:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/WzCp1RRj0c6gGJfON9evq4Akd39yVvyhiuO6vbmuXuc5tDlWEOu9Ze8thIYuuIX3krfB6q X-Received: by 2002:a65:6094:: with SMTP id t20mr17043972pgu.285.1543050139584; Sat, 24 Nov 2018 01:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543050139; cv=none; d=google.com; s=arc-20160816; b=dXQHQghSq1Pp5YuIF5AW+L8UcIZw7GOcYiMCICGaE9buQF9ql+7e8owQogGgMwEVjB yeK2c4rwsWc34wk76BAt/EcRO2MGvBw69IcCAHyj1lBTFL0fSKwglrIRZY7rwwu6fMXN gg3aPdpPZoFCw7/0dYwNFfXvaIvXmw9p0SV+HQlk6XHrYl1Kv2bSWD1iEPGw2cfqzDIY q829Gs/83bJRibtA9c76R8SJPu8NtACooddiTBEV8EJPZqHluDbNRqf8JdkvG7qAJDtA o8Xw5iAp/wGxmtgaILfrW1bExZT/Cc/fbNULgbNOgB00uJ0NmhmFa2aw2Inra10wUY3h mHeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xnMkdvRFFYIV390BxpdslgwLe2p4Yo/ChTAe2MuZUmE=; b=ewZWx2YKOUEAMnMsKPreu+asb30MhfFoQ/zbQI6OBtSjg6STHVacPmeFxt9jVGxr6u +bcML7zF12sptYDVqo9xQScaLKead1Kvt68tiI8oo31vmaQV+mbfqpYA8S9o9s8p7cCu QBQ7bonMEY8Ds7/V3yLNWigw42jnwa2Kjjmk5Z9MKhmsmqKKLRDu9oWJP0sErl8igK5s 3Po2H5waSa/xf3KsoM+mNWIkoSyJzf3oKi5P4kz5qV/VZN4ow8FwWT5qiL5sC1oxAL/S tllxAPWW5dhqD1hHd1HHZ/H2IaSLxfttQ6m62dTKX2DxiPuoQ3nEJ1jqGUAWhnvm6cHv +0Qg== 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 e35si25855824pgb.548.2018.11.24.01.02.04; Sat, 24 Nov 2018 01:02:19 -0800 (PST) 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 S1730939AbeKXOfn (ORCPT + 99 others); Sat, 24 Nov 2018 09:35:43 -0500 Received: from fieldses.org ([173.255.197.46]:36688 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728450AbeKXOfn (ORCPT ); Sat, 24 Nov 2018 09:35:43 -0500 Received: by fieldses.org (Postfix, from userid 2815) id 2111B2016; Fri, 23 Nov 2018 22:48:52 -0500 (EST) Date: Fri, 23 Nov 2018 22:48:52 -0500 From: "J. Bruce Fields" To: Pan Bian Cc: Amir Goldstein , Miklos Szeredi , Al Viro , Christoph Hellwig , linux-kernel Subject: Re: [PATCH V2] exportfs: do not read dentry after free Message-ID: <20181124034852.GD7489@fieldses.org> References: <1542959793-118334-1-git-send-email-bianpan2016@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1542959793-118334-1-git-send-email-bianpan2016@163.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 23, 2018 at 03:56:33PM +0800, Pan Bian wrote: > The function dentry_connected calls dput(dentry) to drop the previously > acquired reference to dentry. In this case, dentry can be released. > After that, IS_ROOT(dentry) checks the condition > (dentry == dentry->d_parent), which may result in a use-after-free bug. > This patch directly compares dentry with its parent obtained before > dropping the reference. Looks right to me, thanks.--b. > > Fixes: a056cc8934c("exportfs: stop retrying once we race with > rename/remove") > > Signed-off-by: Pan Bian > > --- > V2: get rid of the comment > > --- > fs/exportfs/expfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c > index 645158d..a69aaf5 100644 > --- a/fs/exportfs/expfs.c > +++ b/fs/exportfs/expfs.c > @@ -77,7 +77,7 @@ static bool dentry_connected(struct dentry *dentry) > struct dentry *parent = dget_parent(dentry); > > dput(dentry); > - if (IS_ROOT(dentry)) { > + if (dentry == parent) { > dput(parent); > return false; > } > -- > 2.7.4 >