From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: inode: Check if we get a valid inode before checking its mode.
Date: Fri, 29 Mar 2019 09:21:19 +0200 [thread overview]
Message-ID: <3c4b3444-8ca4-fe8d-9b69-a7972fe6185c@suse.com> (raw)
In-Reply-To: <20190329071259.6447-1-wqu@suse.com>
On 29.03.19 г. 9:12 ч., Qu Wenruo wrote:
> We should check the inode validation before checking the imode.
>
> As btrfs_iget() could return ERR_PTR(), unlike previous path, we need to
> verify the inode before checking the imode.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> To David:
>
> Please fold this into 9944a5b5d26e ("btrfs: inode: Verify inode mode to avoid NULL pointer dereference")
> of misc-next branch.
> ---
> fs/btrfs/inode.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 3ee835cbb490..97f47dd295e8 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -5776,6 +5776,8 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
>
> if (location.type == BTRFS_INODE_ITEM_KEY) {
> inode = btrfs_iget(dir->i_sb, &location, root, NULL);
> + if (IS_ERR(inode))
> + return inode;
>
> /* Do extra check against inode mode with di_type */
> if (btrfs_inode_type(inode) != di_type) {
>
next prev parent reply other threads:[~2019-03-29 7:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-29 7:12 [PATCH] btrfs: inode: Check if we get a valid inode before checking its mode Qu Wenruo
2019-03-29 7:21 ` Nikolay Borisov [this message]
2019-03-29 15:19 ` David Sterba
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=3c4b3444-8ca4-fe8d-9b69-a7972fe6185c@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox