mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: syzbot <syzbot+6986a30df88382d1f7bf@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] ext4: hold buffer reference in ext4_read_inline_dir to prevent UAF
Date: Tue, 13 Jan 2026 05:05:44 -0800	[thread overview]
Message-ID: <69664328.050a0220.2e06c6.000d.GAE@google.com> (raw)
In-Reply-To: <6965a06e.050a0220.38aacd.0005.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] ext4: hold buffer reference in ext4_read_inline_dir to prevent UAF
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

Hold an additional buffer reference during ext4_read_inline_data() to
prevent use-after-free. The iloc buffer_head could be freed by another
thread while ext4_read_inline_data() is accessing it, leading to a
use-after-free read.

The fix ensures the buffer remains valid during the critical section:
- get_bh() before calling ext4_read_inline_data() increments refcount
- Even if another thread calls brelse(), refcount stays above zero
- Buffer cannot be freed while we hold the reference
- brelse() after ext4_read_inline_data() decrements refcount safely

Reported-by: syzbot+6986a30df88382d1f7bf@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6986a30df88382d1f7bf
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 fs/ext4/inline.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 1f6bc05593df..b7dcbef4d5aa 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1395,14 +1395,25 @@ int ext4_read_inline_dir(struct file *file,
 	}
 
 	inline_size = ext4_get_inline_size(inode);
+
+	/*
+	 * Hold an additional reference to the iloc buffer to prevent
+	 * use-after-free. The buffer could be freed by another thread
+	 * during ext4_read_inline_data() if we don't hold a reference.
+	 */
+	get_bh(iloc.bh);
+
 	dir_buf = kmalloc(inline_size, GFP_NOFS);
 	if (!dir_buf) {
 		ret = -ENOMEM;
+		brelse(iloc.bh);
 		up_read(&EXT4_I(inode)->xattr_sem);
 		goto out;
 	}
 
 	ret = ext4_read_inline_data(inode, dir_buf, inline_size, &iloc);
+	brelse(iloc.bh);
+
 	up_read(&EXT4_I(inode)->xattr_sem);
 	if (ret < 0)
 		goto out;
-- 
2.43.0


      parent reply	other threads:[~2026-01-13 13:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13  1:31 [syzbot] [ext4?] KASAN: use-after-free Read in ext4_read_inline_data syzbot
2026-01-13  6:43 ` Forwarded: [PATCH] ext4: add validation and bounds checking in ext4_read_inline_data() syzbot
2026-01-13 13:05 ` syzbot [this message]

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=69664328.050a0220.2e06c6.000d.GAE@google.com \
    --to=syzbot+6986a30df88382d1f7bf@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.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

all inboxes | Powered by JetHome®