From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Edward Adam Davis <eadavis@qq.com>,
syzbot+7c31755f2cea07838b0c@syzkaller.appspotmail.com,
Christian Brauner <brauner@kernel.org>,
Sasha Levin <sashal@kernel.org>,
viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-6.18] fs: init flags_valid before calling vfs_fileattr_get
Date: Thu, 5 Mar 2026 10:36:56 -0500 [thread overview]
Message-ID: <20260305153704.106918-13-sashal@kernel.org> (raw)
In-Reply-To: <20260305153704.106918-1-sashal@kernel.org>
From: Edward Adam Davis <eadavis@qq.com>
[ Upstream commit cb184dd19154fc486fa3d9e02afe70a97e54e055 ]
syzbot reported a uninit-value bug in [1].
Similar to the "*get" context where the kernel's internal file_kattr
structure is initialized before calling vfs_fileattr_get(), we should
use the same mechanism when using fa.
[1]
BUG: KMSAN: uninit-value in fuse_fileattr_get+0xeb4/0x1450 fs/fuse/ioctl.c:517
fuse_fileattr_get+0xeb4/0x1450 fs/fuse/ioctl.c:517
vfs_fileattr_get fs/file_attr.c:94 [inline]
__do_sys_file_getattr fs/file_attr.c:416 [inline]
Local variable fa.i created at:
__do_sys_file_getattr fs/file_attr.c:380 [inline]
__se_sys_file_getattr+0x8c/0xbd0 fs/file_attr.c:372
Reported-by: syzbot+7c31755f2cea07838b0c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7c31755f2cea07838b0c
Tested-by: syzbot+7c31755f2cea07838b0c@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Link: https://patch.msgid.link/tencent_B6C4583771D76766D71362A368696EC3B605@qq.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
This confirms the bug: `fuse_fileattr_get()` reads `fa->flags_valid`
(line 517), but in the `file_getattr` syscall, `fa` was declared
uninitialized. The `flags_valid` field could contain any stack garbage,
leading to the KMSAN report. The fix initializes it to `{ .flags_valid =
true }`, matching the pattern used by `ioctl_getflags()` at line 313.
## Analysis
**What the commit fixes:** An uninitialized memory read (KMSAN uninit-
value) in the `file_getattr` syscall path. The `struct file_kattr fa`
variable is declared on the stack without initialization, then passed to
`vfs_fileattr_get()` which calls filesystem-specific `fileattr_get()`
implementations. The FUSE implementation (`fuse_fileattr_get`) reads
`fa->flags_valid` before writing to it, triggering use of uninitialized
memory.
**Bug severity:** This is a real bug reportable by KMSAN. The
uninitialized `flags_valid` field determines which code path is taken in
`fuse_fileattr_get()` (line 517). If `flags_valid` happens to be false
(zero), the fuse driver takes the wrong code path (xattr-based instead
of ioctl-based), potentially returning incorrect or garbage data to
userspace.
**Fix quality:** The fix is a one-line change - initializing the struct
with `{ .flags_valid = true }`. This exactly matches the existing
pattern at line 313 (`ioctl_getflags`), making it obviously correct. The
`/* hint only */` comment also matches.
**Scope:** Only the 6.19 stable tree is affected. The `file_getattr`
syscall was introduced in commit `be7efb2d20d67` which first appeared in
v6.17-rc1. The code was moved to `fs/file_attr.c` as part of that
series. Older stable trees (6.12.y, 6.6.y, 5.15.y, etc.) don't have this
syscall and are unaffected.
**Risk:** Extremely low. The change only adds initialization of a single
struct field, matching an existing pattern in the same file.
**Stable criteria check:**
- Obviously correct: Yes, matches existing pattern
- Fixes a real bug: Yes, KMSAN-detected uninit read, syzbot-reported
- Small and contained: Yes, one-line change
- No new features: Correct
- Tested: Yes, syzbot Tested-by tag
## Verification
- Read `fs/file_attr.c:380` - confirmed `struct file_kattr fa;` is
uninitialized in `file_getattr` syscall
- Read `fs/file_attr.c:313` - confirmed `ioctl_getflags` uses `{
.flags_valid = true }` (the pattern the fix replicates)
- Read `fs/file_attr.c:82-94` - confirmed `vfs_fileattr_get()` passes
`fa` directly to filesystem's `fileattr_get` callback without
initializing it
- Read `fs/fuse/ioctl.c:517` - confirmed `fuse_fileattr_get` reads
`fa->flags_valid` before writing, triggering the KMSAN report
- `git tag --contains be7efb2d20d67` showed the syscall was introduced
in v6.17-rc1 (not v6.19-rc1 as might be assumed)
- `git show v6.19.6:fs/file_attr.c` confirmed the fix is NOT yet in
6.19.6 stable
- `git log v6.12.75 -- fs/file_attr.c` returned empty, confirming older
stable trees don't have this file/code
**YES**
fs/file_attr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/file_attr.c b/fs/file_attr.c
index 13cdb31a3e947..4889cf59b2562 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -377,7 +377,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename,
struct filename *name __free(putname) = NULL;
unsigned int lookup_flags = 0;
struct file_attr fattr;
- struct file_kattr fa;
+ struct file_kattr fa = { .flags_valid = true }; /* hint only */
int error;
BUILD_BUG_ON(sizeof(struct file_attr) < FILE_ATTR_SIZE_VER0);
--
2.51.0
next prev parent reply other threads:[~2026-03-05 15:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 15:36 [PATCH AUTOSEL 6.19-6.18] scsi: ufs: core: Reset urgent_bkops_lvl to allow runtime PM power mode Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-5.10] unshare: fix unshare_fs() handling Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-6.12] drm/amdgpu/vcn5: Add SMU dpm interface type Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-6.1] wifi: mac80211: set default WMM parameters on all links Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-5.15] ALSA: usb-audio: Check max frame size for implicit feedback mode, too Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-5.10] scsi: ses: Fix devices attaching to different hosts Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-6.6] ASoC: cs42l43: Report insert for exotic peripherals Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-5.15] ALSA: usb-audio: Avoid implicit feedback mode on DIYINHK USB Audio 2.0 Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-5.10] ACPI: PM: Save NVS memory on Lenovo G70-35 Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-5.10] scsi: storvsc: Fix scheduling while atomic on PREEMPT_RT Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-6.1] ASoC: amd: yc: Add ASUS EXPERTBOOK BM1503CDA to quirk table Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-5.10] ACPI: OSI: Add DMI quirk for Acer Aspire One D255 Sasha Levin
2026-03-05 15:36 ` Sasha Levin [this message]
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-6.6] scsi: ufs: core: Fix possible NULL pointer dereference in ufshcd_add_command_trace() Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-6.18] perf/core: Fix refcount bug and potential UAF in perf_mmap Sasha Levin
2026-03-05 15:36 ` [PATCH AUTOSEL 6.19-6.6] scsi: ufs: core: Fix shift out of bounds when MAXQ=32 Sasha Levin
2026-03-05 15:37 ` [PATCH AUTOSEL 6.19-5.15] scsi: mpi3mr: Add NULL checks when resetting request and reply queues Sasha Levin
2026-03-05 15:37 ` [PATCH AUTOSEL 6.19-6.12] ALSA: hda/realtek: Fix speaker pop on Star Labs StarFighter Sasha Levin
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=20260305153704.106918-13-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=brauner@kernel.org \
--cc=eadavis@qq.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=syzbot+7c31755f2cea07838b0c@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
/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