From: "Theodore Ts'o" <tytso@mit.edu>
To: Zhang Yi <yi.zhang@huawei.com>
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
Date: Mon, 30 Aug 2021 23:02:06 -0400 [thread overview]
Message-ID: <YS2brqdSIO8mQs3U@mit.edu> (raw)
In-Reply-To: <20210826130412.3921207-7-yi.zhang@huawei.com>
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 <yi.zhang@huawei.com>
> ---
> 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
next prev parent reply other threads:[~2021-08-31 3:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 13:04 [PATCH v4 0/6] ext4: fix a inode checksum error Zhang Yi
2021-08-26 13:04 ` [PATCH v4 1/6] ext4: move inode eio simulation behind io completeion Zhang Yi
2021-08-31 3:04 ` Theodore Ts'o
2021-08-26 13:04 ` [PATCH v4 2/6] ext4: remove an unnecessary if statement in __ext4_get_inode_loc() Zhang Yi
2021-08-31 3:04 ` Theodore Ts'o
2021-08-26 13:04 ` [PATCH v4 3/6] ext4: make the updating inode data procedure atomic Zhang Yi
2021-08-31 3:04 ` Theodore Ts'o
2021-08-26 13:04 ` [PATCH v4 4/6] ext4: factor out ext4_fill_raw_inode() Zhang Yi
2021-08-26 13:04 ` [PATCH v4 5/6] ext4: move ext4_fill_raw_inode() related functions Zhang Yi
2021-08-26 13:04 ` [PATCH v4 6/6] ext4: prevent getting empty inode buffer Zhang Yi
2021-08-31 3:02 ` Theodore Ts'o [this message]
2021-08-31 7:01 ` Zhang Yi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YS2brqdSIO8mQs3U@mit.edu \
--to=tytso@mit.edu \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.