Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp206437ybl; Thu, 23 Jan 2020 21:54:31 -0800 (PST) X-Google-Smtp-Source: APXvYqwKuQ7yzkYDXJMKmj/fALUx6hXKnvBF6txojTRl+09XPqbpvV3jKhZaxcy9bY6ankPs6W7h X-Received: by 2002:a9d:708f:: with SMTP id l15mr1600277otj.229.1579845271305; Thu, 23 Jan 2020 21:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579845271; cv=none; d=google.com; s=arc-20160816; b=G7BojC6fQwY7VJqtE5LPBC4eu5JZQcldhXr2RkJZ2Onuf7bcbEUdrSCN+4ZKVDkKtF AL9/I5PNw3PM5CAzKCWkaDk6xQyY2AxaQpeUjt02pWlrzanBo+CaWRmnBNFataeIB20G IDDQL1KKUZm83fOGK1b4K8WZDT3VhzeiAfVu6DXTaAr063CSAw2/qWtVnD948J2Zi4Y/ QrERs7MOultaZCRydoUp9BqrcwhdPadoY79pMRuC9CFQ1UeZzNDYmLARJTjsRGIZewld 55SiwjbmJoeUNI3Tm3JJzfMpn9xOejAcn/O9qAkyqvDABWflo+EhHyavEPuxhh/Yq5pY P0Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YYL1XrIyjR544EAnIy43CmKHnObpFqcOhUKxoM4L9Ew=; b=U1EaBk7qSZ6SEznWUJT1ozD1XYYLSYmBrb6PHygQIHDqVLteCM2UtWL8YFI5r+uZXc 4qriQ6iUh8k1+ZKzczFeCMkOdsn0gfzP+OItjOHHQMEQytEft+B+ArRM76xit7nij18A z8Ypmgooj7lr+Il+kTTbocSm9pWdFcfmwT/zhr8+FbQCsVC4sY3rhQdSkQ0TRzRgHBpE MzCZAsHplGlT0efwb8AQLO5SUXJMfkUo51Wneob3DTv5ZTXH3OjtNW6yBa8Dp/WJAwrg EMQmEWt81+PYM9WvViCPG/X/OcEW4MdKySnMv5huygSIWIkbbSFbbwDK5J1xx0q4w40E whjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XDHBOOKK; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3si2445769otr.245.2020.01.23.21.54.19; Thu, 23 Jan 2020 21:54:31 -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=@kernel.org header.s=default header.b=XDHBOOKK; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727250AbgAXFQD (ORCPT + 99 others); Fri, 24 Jan 2020 00:16:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:33830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727163AbgAXFQD (ORCPT ); Fri, 24 Jan 2020 00:16:03 -0500 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BBDDF2071A; Fri, 24 Jan 2020 05:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579842963; bh=+bhb+s0f7B8ftjSnB2z/I4wHjcLdDMiVwk5zcTEu+Xg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XDHBOOKK9bkcNNfisMo8Nc3n1utEsOSFcTbo/UH7ZqTVyKMQuk6ACT1kRFMpzt8aB 5j6gHRPkoqlU8SqTZZWXuXn9s/Hhoi+DtJXL/EC2pRIXpb26vbju+EHQM3laQjcWOM k7vSkMNunrddsoN4QHTjTyp+7TwQ5xYVI6swmAeo= Date: Thu, 23 Jan 2020 21:16:01 -0800 From: Eric Biggers To: Gao Xiang 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: <20200124051601.GB832@sol.localdomain> References: <20200124041234.159740-1-ebiggers@kernel.org> <20200124050423.GA31271@hsiangkao-HP-ZHAN-66-Pro-G1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200124050423.GA31271@hsiangkao-HP-ZHAN-66-Pro-G1> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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. - Eric