* [BUG] fanotify: WARNING in fanotify_handle_event with crafted msdos image and long path
@ 2026-08-31 4:32 ZW Tang
2026-08-31 10:31 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: ZW Tang @ 2026-08-31 4:32 UTC (permalink / raw)
To: Jan Kara; +Cc: Amir Goldstein, linux-fsdevel, linux-kernel
Hi,
I am reporting a warning triggered by a syzkaller reproducer on
Linux 7.2.0-rc3. A similar issue appears to have been reported upstream
before, but I can still reproduce it on Linux 7.2.0-rc3 with HEAD commit
1137d8b5df06137fb49513cc923b3b24d94cb809.
The reproducer mounts a crafted msdos filesystem image, creates a very
long pathname, installs a fanotify mark, and then calls execve() on the
long path. During execve(), the file open path triggers fsnotify, which
then calls fanotify_handle_event(). While fanotify is constructing the
event, it hits a warning in fs/notify/fanotify/fanotify.h.
This looks like a fanotify name-event encoding robustness issue. A crafted
filesystem image together with a very long pathname appears to trigger an
unexpected name/fid event layout, and fanotify_info_copy_name() reaches a
WARN_ON_ONCE() path. The kernel should probably reject or truncate the
event cleanly instead of triggering a warning, because panic_on_warn turns
this into a kernel panic.
Reproducer:
syz reproducer: https://pastebin.com/raw/JqBwvgbH
console output: https://pastebin.com/raw/2jnY4jzL
kernel config: https://pastebin.com/raw/RgvQ5DPY
Kernel:
HEAD commit: 1137d8b5df06137fb49513cc923b3b24d94cb809
git tree: torvalds/linux
kernel version: 7.2.0-rc3 #1 PREEMPT(full) (QEMU Ubuntu 24.10)
Relevant log:
loop0: detected capacity change from 0 to 128
------------[ cut here ]------------
WARNING: fs/notify/fanotify/fanotify.h:217 at
fanotify_handle_event+0x3e93/0x4800, CPU#1: syz.0.17/10761
CPU: 1 UID: 0 PID: 10761 Comm: syz.0.17 Not tainted 7.2.0-rc3 #1 PREEMPT(full)
Hardware name: QEMU Ubuntu 24.10 PC (i440FX + PIIX, 1996)
RIP: 0010+0x3e93/0x4800
Call Trace:
<TASK>
fsnotify+0x1105/0x1be0
__fsnotify_parent+0x6b6/0xd40
vfs_open+0x2e6/0x3f0
path_openat+0x29a2/0x3e20
do_file_open+0x216/0x310
do_open_execat+0xe8/0x430
alloc_bprm+0x2b/0x900
do_execveat_common.isra.0+0x1a8/0x5d0
__x64_sys_execve+0x93/0xd0
do_syscall_64+0xc4/0x7a0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
Kernel panic - not syncing: kernel: panic_on_warn set ...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG] fanotify: WARNING in fanotify_handle_event with crafted msdos image and long path
2026-08-31 4:32 [BUG] fanotify: WARNING in fanotify_handle_event with crafted msdos image and long path ZW Tang
@ 2026-08-31 10:31 ` Jan Kara
2026-08-31 14:25 ` OGAWA Hirofumi
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2026-08-31 10:31 UTC (permalink / raw)
To: ZW Tang
Cc: Jan Kara, Amir Goldstein, linux-fsdevel, linux-kernel,
OGAWA Hirofumi
Hello,
On Mon 31-08-26 12:32:57, ZW Tang wrote:
> I am reporting a warning triggered by a syzkaller reproducer on
> Linux 7.2.0-rc3. A similar issue appears to have been reported upstream
> before, but I can still reproduce it on Linux 7.2.0-rc3 with HEAD commit
> 1137d8b5df06137fb49513cc923b3b24d94cb809.
>
> The reproducer mounts a crafted msdos filesystem image, creates a very
> long pathname, installs a fanotify mark, and then calls execve() on the
> long path. During execve(), the file open path triggers fsnotify, which
> then calls fanotify_handle_event(). While fanotify is constructing the
> event, it hits a warning in fs/notify/fanotify/fanotify.h.
>
> This looks like a fanotify name-event encoding robustness issue. A crafted
> filesystem image together with a very long pathname appears to trigger an
> unexpected name/fid event layout, and fanotify_info_copy_name() reaches a
> WARN_ON_ONCE() path. The kernel should probably reject or truncate the
> event cleanly instead of triggering a warning, because panic_on_warn turns
> this into a kernel panic.
fanotify complains that the name length is greater than NAME_MAX. If I can
guess, the problem likely is that the msdos filesystem (vfat?) allows a
file name that is longer than NAME_MAX. Which would be a bug in the
filesystem driver, not a problem in fanotify... Ogawa, care to have a look?
Honza
>
> Reproducer:
>
> syz reproducer: https://pastebin.com/raw/JqBwvgbH
> console output: https://pastebin.com/raw/2jnY4jzL
> kernel config: https://pastebin.com/raw/RgvQ5DPY
>
> Kernel:
>
> HEAD commit: 1137d8b5df06137fb49513cc923b3b24d94cb809
> git tree: torvalds/linux
> kernel version: 7.2.0-rc3 #1 PREEMPT(full) (QEMU Ubuntu 24.10)
>
> Relevant log:
>
> loop0: detected capacity change from 0 to 128
>
> ------------[ cut here ]------------
> WARNING: fs/notify/fanotify/fanotify.h:217 at
> fanotify_handle_event+0x3e93/0x4800, CPU#1: syz.0.17/10761
>
> CPU: 1 UID: 0 PID: 10761 Comm: syz.0.17 Not tainted 7.2.0-rc3 #1 PREEMPT(full)
> Hardware name: QEMU Ubuntu 24.10 PC (i440FX + PIIX, 1996)
>
> RIP: 0010+0x3e93/0x4800
>
> Call Trace:
> <TASK>
> fsnotify+0x1105/0x1be0
> __fsnotify_parent+0x6b6/0xd40
> vfs_open+0x2e6/0x3f0
> path_openat+0x29a2/0x3e20
> do_file_open+0x216/0x310
> do_open_execat+0xe8/0x430
> alloc_bprm+0x2b/0x900
> do_execveat_common.isra.0+0x1a8/0x5d0
> __x64_sys_execve+0x93/0xd0
> do_syscall_64+0xc4/0x7a0
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
> </TASK>
>
> Kernel panic - not syncing: kernel: panic_on_warn set ...
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG] fanotify: WARNING in fanotify_handle_event with crafted msdos image and long path
2026-08-31 10:31 ` Jan Kara
@ 2026-08-31 14:25 ` OGAWA Hirofumi
0 siblings, 0 replies; 3+ messages in thread
From: OGAWA Hirofumi @ 2026-08-31 14:25 UTC (permalink / raw)
To: Jan Kara; +Cc: ZW Tang, Amir Goldstein, linux-fsdevel, linux-kernel
Jan Kara <jack@suse.cz> writes:
> On Mon 31-08-26 12:32:57, ZW Tang wrote:
>> I am reporting a warning triggered by a syzkaller reproducer on
>> Linux 7.2.0-rc3. A similar issue appears to have been reported upstream
>> before, but I can still reproduce it on Linux 7.2.0-rc3 with HEAD commit
>> 1137d8b5df06137fb49513cc923b3b24d94cb809.
>>
>> The reproducer mounts a crafted msdos filesystem image, creates a very
>> long pathname, installs a fanotify mark, and then calls execve() on the
>> long path. During execve(), the file open path triggers fsnotify, which
>> then calls fanotify_handle_event(). While fanotify is constructing the
>> event, it hits a warning in fs/notify/fanotify/fanotify.h.
>>
>> This looks like a fanotify name-event encoding robustness issue. A crafted
>> filesystem image together with a very long pathname appears to trigger an
>> unexpected name/fid event layout, and fanotify_info_copy_name() reaches a
>> WARN_ON_ONCE() path. The kernel should probably reject or truncate the
>> event cleanly instead of triggering a warning, because panic_on_warn turns
>> this into a kernel panic.
>
> fanotify complains that the name length is greater than NAME_MAX. If I can
> guess, the problem likely is that the msdos filesystem (vfat?) allows a
> file name that is longer than NAME_MAX. Which would be a bug in the
> filesystem driver, not a problem in fanotify... Ogawa, care to have a look?
A patch looks like be applied to v7.3.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-31 14:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31 4:32 [BUG] fanotify: WARNING in fanotify_handle_event with crafted msdos image and long path ZW Tang
2026-08-31 10:31 ` Jan Kara
2026-08-31 14:25 ` OGAWA Hirofumi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox