public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Edward AD <eadavis@sina.com>
To: syzbot+b3123e6d9842e526de39@syzkaller.appspotmail.com
Cc: adilger.kernel@dilger.ca, jack@suse.cz,
	linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	nathan@kernel.org, ndesaulniers@google.com,
	syzkaller-bugs@googlegroups.com, trix@redhat.com, tytso@mit.edu,
	yi.zhang@huawei.com
Subject: [PATCH] ext4: fix ext4_calculate_overhead use invliad j_inode
Date: Sat, 26 Aug 2023 11:55:54 +0800	[thread overview]
Message-ID: <20230826035554.2849316-1-eadavis@sina.com> (raw)
In-Reply-To: <000000000000b1426e0603bc40b6@google.com>

In ext4_calculate_overhead(), ext4_get_journal_inode() returned an invalid inode 
pointer without processing. Here, an invalid pointer judgment condition is added 
to avoid incorrect operation of invalid pointer j_inode.

Reported-by: syzbot+b3123e6d9842e526de39@syzkaller.appspotmail.com
Fixes: 99d6c5d892bf ("ext4: ext4_get_{dev}_journal return proper error value")
Signed-off-by: Edward AD <eadavis@sina.com>
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 34f5406c08da..0dac00954d25 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4178,7 +4178,7 @@ int ext4_calculate_overhead(struct super_block *sb)
 	else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) {
 		/* j_inum for internal journal is non-zero */
 		j_inode = ext4_get_journal_inode(sb, j_inum);
-		if (j_inode) {
+		if (j_inode && !IS_ERR(j_inode)) {
 			j_blocks = j_inode->i_size >> sb->s_blocksize_bits;
 			overhead += EXT4_NUM_B2C(sbi, j_blocks);
 			iput(j_inode);
-- 
2.25.1


  parent reply	other threads:[~2023-08-26  3:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25  9:48 [syzbot] [ext4?] BUG: unable to handle kernel paging request in ext4_calculate_overhead syzbot
2023-08-25 12:22 ` Zhang Yi
2023-08-26  3:55 ` Edward AD [this message]
2023-08-28 10:17   ` [PATCH] ext4: fix ext4_calculate_overhead use invliad j_inode Jan Kara

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=20230826035554.2849316-1-eadavis@sina.com \
    --to=eadavis@sina.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=syzbot+b3123e6d9842e526de39@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=trix@redhat.com \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox