Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp208338ybl; Thu, 23 Jan 2020 21:57:45 -0800 (PST) X-Google-Smtp-Source: APXvYqzv1zIPLKZSQFmdCRCALfPaAl+3/mf0ImsTMEqI6ETh4QP+A58ka6ejxf3WKn8LEtsZhiHX X-Received: by 2002:aca:1b19:: with SMTP id b25mr1045288oib.24.1579845465309; Thu, 23 Jan 2020 21:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579845465; cv=none; d=google.com; s=arc-20160816; b=HTJd/bRhl+lScOcoKqQXqLv4nr83iVF4M/KAWRDwWqHy4d8NK1ZK+VyMevoSAUJ/Lj lNP0bpyUm4erkQLUmvp22G/gu9MtBQm1rf8z19ophVa2dCxxXtfg/y5pOvAA/Kjv3p9M JawcpIMKh5sgfMKumUuzeT7ik9k+qpfG6iEKga2WKJpEgZFt7ceOUXKTI3P3u3cQkNFK rqUnUwnY+OX+mNiZHNcgx1B5Qnio72rMLG8DBV0oez3eJKl2mwfVQX7Qr0eJY5WHkrYc fdSGzwwjCp7mFLLQQ6WfqaMiN/5uqgwEvbaPCPAJ1uDpxziGTHj61dhfi3hDvzKUic3q Mubg== 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:dkim-signature; bh=9necSZIJYyRRJ8jaU0pxv6QHcZkJLNsfLRyto+nrVh0=; b=AcHLDsXSi8sxH5zqa3t01F42rET06P+726cPWdwaNMWzuRTMYmqKgIrRE8XJYLDEhh KWGqJWvPLVUExSQ9xlYunAKFHrnvUdvoQTUyENwHIUNfLRBinCX7qo8cUCqtsLnejJ2B hl6Lzre9jNG/YCK872VhZdA2o4vHUrlfPrmiyNnhDkRcnC9YLFxn60sYecwg+S58hbSA m1ePYuqHXbzp9XPX6oJGcMNoItpVgqoY7ghr0PCY7xcyNhFsDbBpqG0BeUiZVtafdzsy 2E1OXt5CISsLaIJpwtgmeaQM4aabU4j1mFrSWyUrwM4sXdmZJ3LaEKbvJCLCf+y0WP98 0Wxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=WwEBKWsy; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2si2274066otq.196.2020.01.23.21.57.32; Thu, 23 Jan 2020 21:57:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=WwEBKWsy; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729752AbgAXF16 (ORCPT + 99 others); Fri, 24 Jan 2020 00:27:58 -0500 Received: from sonic303-23.consmr.mail.gq1.yahoo.com ([98.137.64.204]:38853 "EHLO sonic303-23.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729388AbgAXF16 (ORCPT ); Fri, 24 Jan 2020 00:27:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1579843676; bh=9necSZIJYyRRJ8jaU0pxv6QHcZkJLNsfLRyto+nrVh0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=WwEBKWsy3oq7a8PjwdUA//IN9YkACLmL5JznGU9u2ynO50qVQKTY+sGwdeM7J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MWYbH.QfVWY61YOWdBzSS0uaLHBOXbwzW5rV1XkQKi4j1zmX.l 10Fk3AeDnoQaWx5Moqv18Oz1Tc..AEiBaD9aTGQfVX7YUyi7jHRovnVy8mAD2F4bQKE5.3nAx427 uF3LPxI_gkd8LkauPvDyh7HD7SmoZtTubyPxMtgueBIA4YNqGDL8J6IFOMdlNO7jE1WcKDTLE63W Uy16LO2Vogu2th1yjnnGpaAhHbjMySKUq3u0u4.HNtd5cg0OuHjjFe0E5YgVM3tI825GTG5bsVOm A2H1FYmGq3JdexnGbqGnTfdPOZi4h6DPLHT3Fvxg46yJvXW193JJf69qKG2KdnjnVPYe3396Y13D FW6pqj9hNUKu6w_oGAPTBVbEYT2yNXr4.wg1PnYpFHUPDKarAClWCOAmxzlwTCOLK0GuNiWK9ItM nNzEWorDfEZi_7RGLuUbFWKb2DKSEaYMBJhg4wqyaK8Ii1GeCkOqWePBwMZieIyKILpHQX3GegwY 5fPch8JKIXEepoGK7Ud4WkupjyMgzkE8Pe3XRIuVL3slJZMH8RR9urgW831I17RP2Xyx0gBSALJS bfVsd3XrV2xpw4O5RqUj16Y76vzS3DemXYXClYZ5yRxjlpIHmk7ctla4tZwODvVmAy.dJKizhsV1 SdNFR_yBYcwpZQ3UEzU3kojQlAqDMgkk1Ag-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.gq1.yahoo.com with HTTP; Fri, 24 Jan 2020 05:27:56 +0000 Received: by smtp428.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID f9b7953f40d5a7531fce28ad55186da6; Fri, 24 Jan 2020 05:27:55 +0000 (UTC) Date: Fri, 24 Jan 2020 13:27:50 +0800 From: Gao Xiang To: Eric Biggers Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Alexander Viro , Daniel Rosenberg , Gabriel Krisman Bertazi Subject: Re: [PATCH] ext4: fix race conditions in ->d_compare() and ->d_hash() Message-ID: <20200124052740.GB31271@hsiangkao-HP-ZHAN-66-Pro-G1> References: <20200124041234.159740-1-ebiggers@kernel.org> <20200124050423.GA31271@hsiangkao-HP-ZHAN-66-Pro-G1> <20200124051601.GB832@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200124051601.GB832@sol.localdomain> User-Agent: Mutt/1.10.1 (2018-07-13) X-Mailer: WebService/1.1.14873 hermes Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_181) Content-Length: 1359 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Jan 23, 2020 at 09:16:01PM -0800, Eric Biggers wrote: > On Fri, Jan 24, 2020 at 01:04:25PM +0800, Gao Xiang wrote: > > > diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c > > > index 8964778aabefb..0129d14629881 100644 > > > --- a/fs/ext4/dir.c > > > +++ b/fs/ext4/dir.c > > > @@ -671,9 +671,11 @@ static int ext4_d_compare(const struct dentry *dentry, unsigned int len, > > > const char *str, const struct qstr *name) > > > { > > > struct qstr qstr = {.name = str, .len = len }; > > > - struct inode *inode = dentry->d_parent->d_inode; > > > + const struct dentry *parent = READ_ONCE(dentry->d_parent); > > > > I'm not sure if we really need READ_ONCE d_parent here (p.s. d_parent > > won't be NULL anyway), and d_seq will guard all its validity. If I'm > > wrong, correct me kindly... > > > > Otherwise, it looks good to me... > > Reviewed-by: Gao Xiang > > > > While d_parent can't be set to NULL, it can still be changed concurrently. > So we need READ_ONCE() to ensure that a consistent value is used. If I understand correctly, unlazy RCU->ref-walk will be guarded by seqlock, and for ref-walk we have d_lock (and even parent lock) in relative paths. So I prematurely think no race of renaming or unlinking evenually. I'm curious about that if experts could correct me about this. Thanks, Gao Xiang > > - Eric