All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shigeru Yoshida <syoshida@redhat.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shigeru Yoshida <syoshida@redhat.com>,
	syzbot+bf4bb7731ef73b83a3b4@syzkaller.appspotmail.com
Subject: [PATCH] ext4: Verify extent header in ext4_find_extent()
Date: Mon,  2 Jan 2023 14:58:33 +0000	[thread overview]
Message-ID: <20230102145833.2758-1-syoshida@redhat.com> (raw)

syzbot reported use-after-free in ext4_find_extent() [1].  If there is
a corrupted file system, this can cause invalid memory access.

This patch fixes the issue by verifying extent header.

Reported-by: syzbot+bf4bb7731ef73b83a3b4@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=cd95cb722bfa1234ac4c78345c8953ee2e7170d0 [1]
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
---
 fs/ext4/extents.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 9de1c9d1a13d..79bfa583ab1d 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -901,6 +901,9 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
 		ret = -EFSCORRUPTED;
 		goto err;
 	}
+	ret = ext4_ext_check(inode, eh, depth, 0);
+	if (ret)
+		goto err;
 
 	if (path) {
 		ext4_ext_drop_refs(path);
-- 
2.38.1


             reply	other threads:[~2023-01-02 14:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02 14:58 Shigeru Yoshida [this message]
2023-01-02 23:10 ` [PATCH] ext4: Verify extent header in ext4_find_extent() Eric Biggers
2023-01-03 17:33   ` Shigeru Yoshida

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=20230102145833.2758-1-syoshida@redhat.com \
    --to=syoshida@redhat.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+bf4bb7731ef73b83a3b4@syzkaller.appspotmail.com \
    --cc=tytso@mit.edu \
    /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.