Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4128286pxb; Mon, 30 Aug 2021 20:04:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT5ioqUM9rOx2lsWdiaD998jO7WGz/Uf5bxci+g90t3g00DUStUIAnbVnsd8QY0bOF/sQS X-Received: by 2002:a17:906:265a:: with SMTP id i26mr29035873ejc.522.1630379042255; Mon, 30 Aug 2021 20:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630379042; cv=none; d=google.com; s=arc-20160816; b=o6w2q+sIlhRx6zsH3A7m8lMJH9Q7hHHajq6U1MG0VETrh4GC7ErwOGEaXWRdkzOw4J rGPTfyYsKWGFWUw7pIPIWGCi7r/mI1cMolyiGdow+F0NC7L6L5Oat3e5hjH2YZxvYhEL 0jkGoV7JUUeKGtwhozSW5HMWvk79pRHYDZtY/nPy0EpV6fRu1OSZlHbvAZZ4B+D/NxQ+ wSWmpS1mOE7gnz2YtRDFmqfppBKmEhk6846mHbo0Fqvv2x+6Jv5BsKnnKB1IuxWy9SBP kRB9nQwHZvuUJyPR02sLrzqsv55QKtqoLgquQwTOpaKs+QPOSoJFqaK4yOesLqYravYN AtzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=e4QasSsrVnYXhoq58YzFUadXZG0bfNB1qOF8D+jlY6U=; b=wNpm4erA1yukzM6UxwLTTbsCx71bt1mi5sIHf24n0UE8wt/X+asob+JUCYxsWc2Tut Ros39eTpF2sUUH4RfLeuyteivDK0sb7kLvozxGWNzPdO8BocZyFvitMFyAUjP9LxKDxm E2Jpy0e9OczDIwHFgNq/dx+E940Hw821mNEBCNqr8P97Kp84/lB8qXGMRD+yrNK3cRNW m1LIAve0S3yxE1mMqnkGrSDn+kG7/u0Sy00FWwLn9xFu15pTVIKukskwKYKrKSVQRX5P I+MhltKV4c1CP7JU/ipMH/YClvNB1iCTdLWlDXFR8MjGHvqAOPI85gFSC8ff1anRsd6w BwAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp8si9640636ejc.325.2021.08.30.20.03.34; Mon, 30 Aug 2021 20:04:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239701AbhHaDDl (ORCPT + 99 others); Mon, 30 Aug 2021 23:03:41 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:52282 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232054AbhHaDDS (ORCPT ); Mon, 30 Aug 2021 23:03:18 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 17V326xp029013 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Aug 2021 23:02:06 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 2BE3615C3E7E; Mon, 30 Aug 2021 23:02:06 -0400 (EDT) Date: Mon, 30 Aug 2021 23:02:06 -0400 From: "Theodore Ts'o" To: Zhang Yi Cc: linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca, jack@suse.cz, yukuai3@huawei.com Subject: Re: [PATCH v4 6/6] ext4: prevent getting empty inode buffer Message-ID: References: <20210826130412.3921207-1-yi.zhang@huawei.com> <20210826130412.3921207-7-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210826130412.3921207-7-yi.zhang@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Aug 26, 2021 at 09:04:12PM +0800, Zhang Yi wrote: > > So this patch initialize the inode buffer by filling the in-mem inode > contents if we skip read I/O, ensure that the buffer is really uptodate. > > Signed-off-by: Zhang Yi > --- > fs/ext4/inode.c | 22 ++++++++++++++++------ > 1 file changed, 16 insertions(+), 6 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 3c36e701e30e..8b37f55b04ad 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -4446,8 +4446,8 @@ static int ext4_fill_raw_inode(struct inode *inode, struct ext4_inode *raw_inode > * inode. > */ > static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino, > - struct ext4_iloc *iloc, int in_mem, > - ext4_fsblk_t *ret_block) > + struct inode *inode, struct ext4_iloc *iloc, > + int in_mem, ext4_fsblk_t *ret_block) In this patch you've added a new argument 'inode'. However, if in_mem is true, and inode is NULL, the kernel will crash with a null pointer dereference. Furthermore, whenever in_mem is false, the callers pass in NULL for inode. Given that, perhaps we should just drop the in_mem argument, and then instead of if (in_mem) { we do: if (inode && !ext4_test_inode_state(inode, EXT4_STATE_XATTR) { with the comments adjusted accordingly? I think it will make the code a bit simpler and readable. What do you think? - Ted