From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D79ED31A7E2 for ; Tue, 24 Feb 2026 08:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771922182; cv=none; b=PSZfp72wYU9mqtMKL/lP7vCe0f4/tRlUMP4bgO4zA9/Jnz82l8phJlrS9seu3copOQXn/IzmMNo8Ix3iSMuKjH+D7VzefiFq/yXpN0xtnmYfUpEyQof73cgFUjBtSjerHulnax/p71a9fEfKAW8HYLRtLud7Oe2+Ox2nS3vmc+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771922182; c=relaxed/simple; bh=RIpNB6sqN0Piao8qbbYTXJR2zAlGqNeqDeR3utvO8tk=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=kF2PVcCs9SLsafcWW98WM8dMhwd6Nx58gV/nWBy6OF3Iz1a5P/QRv8nuyJTI/ofNtNe2XmoJjKX/jOzNGV43XXzmu0NIN6F3u17OPWinMonkEOou130TZlq0hd7GwKkNTxaipK3JyXHObeiH3zHRDF7ISDe7gWUlWbX5tnhlw60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-679c29b437cso15944947eaf.2 for ; Tue, 24 Feb 2026 00:36:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771922180; x=1772526980; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=s8TOZmDKVIXOOkHAj/O9h1gDOQ3CmA7xt/CYpSjQcpI=; b=OwNl4djn9w66VV6D88ApVVHgYWwVYyRwo4Bpqdvut1SmtuJvz7JhpIE/XXa1edya7o 7KtwO9KzfivR2RcQ2ruDKpwOZokuMVxjrLf6Fw0lh5Ak2WD8yMy5Cd6eDQrKAvMAU23Q 3c3QiV11Oa6aLc/t2jBqmwXzcy3t9YJEyvd7JtRDbHKkteuA4M22VAd/fZQiUGxpem0+ mrCPKglbJKZa5Sa/M/iSF1+9U3RqXCRh0NIkrsPySsvrSpWqHreP4gFnh0ajuizRNsCl sgCkApQ0dB+DN00fvxuV4hLYV66wIz6g78lBERdLnPFRBfDHmVd5erUheijmtuiaImFu 3T5Q== X-Gm-Message-State: AOJu0YyD2p+/BumROa/VH3pME3d2eztC0+A8ECGzmchUO+/Kc8xAoEW2 mRH6dY6bvmtqSrOZZDS1I/0BDWEeu0TZZ26wyfc7SVlp5pZL/GJVk9C2HWcC1Kr7szc3T2nolq8 tTfdNdONPKs8aQ8yJ695QgbO9bXPyuvkoOI6iurUNYrX0NcjsQu/+CzQItEk= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:16a6:b0:678:20d7:eea6 with SMTP id 006d021491bc7-679c450c644mr6858518eaf.67.1771922179845; Tue, 24 Feb 2026 00:36:19 -0800 (PST) Date: Tue, 24 Feb 2026 00:36:19 -0800 In-Reply-To: <699b9b6f.a70a0220.2c38d7.0189.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <699d6303.a00a0220.121a60.00f9.GAE@google.com> Subject: Forwarded: [PATCH] ext4: add bounds check in xattr_find_entry() to prevent use-after-free From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] ext4: add bounds check in xattr_find_entry() to prevent use-after-free Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master xattr_find_entry() receives an 'end' pointer to mark the boundary of the valid xattr region, but never uses it to validate entries during iteration. The IS_LAST_ENTRY() check dereferences the entry pointer (reading 4 bytes) without first verifying that the entry is within bounds. On a corrupted filesystem, this allows the loop to walk past the valid buffer into freed memory, triggering a use-after-free. This is observed when mounting a crafted ext4 image where inline xattr entries in the inode body are corrupted. During path lookup, the ACL permission check calls ext4_get_acl() -> ext4_xattr_ibody_get() -> xattr_find_entry(), which iterates over the corrupted inline xattr entries and reads from a freed page. Fix this by adding a bounds check against 'end' before each entry is accessed in the iteration loop, and validating that the next entry also falls within bounds. Return -EFSCORRUPTED if the xattr entries overrun the valid region. Reported-by: syzbot+fb32afec111a7d61b939@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=fb32afec111a7d61b939 Signed-off-by: Deepanshu Kartikey --- fs/ext4/xattr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 7bf9ba19a89d..5080ec44228a 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -652,6 +652,13 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name, header = IHDR(inode, raw_inode); end = ITAIL(inode, raw_inode); entry = IFIRST(header); + + if ((void *)entry + sizeof(__u32) > end) { + EXT4_ERROR_INODE(inode, "inline xattr region overflow"); + error = -EFSCORRUPTED; + goto cleanup; + } + error = xattr_find_entry(inode, &entry, end, name_index, name, 0); if (error) goto cleanup; -- 2.34.1