* [PATCH] fanotify: initialize permission event watchdog state
@ 2026-07-03 3:13 xuanqiang.luo
2026-07-03 15:17 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: xuanqiang.luo @ 2026-07-03 3:13 UTC (permalink / raw)
To: linux-fsdevel
Cc: Jan Kara, Amir Goldstein, Joanne Koong, Miklos Szeredi,
linux-kernel, Xuanqiang Luo
From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
fanotify permission events are allocated with kmem_cache_alloc(), but
fanotify_alloc_perm_event() does not initialize watchdog_cnt.
The watchdog reads watchdog_cnt after the event is moved to access_list.
A stale value can make it warn too early or skip the warning.
Initialize watchdog_cnt when allocating a permission event.
Fixes: b8cf8fda522d ("fanotify: add watchdog for permission events")
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
---
fs/notify/fanotify/fanotify.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index a3555bebad63e..b59f0aa43c4be 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -599,6 +599,7 @@ static struct fanotify_event *fanotify_alloc_perm_event(const void *data,
pevent->hdr.pad = 0;
pevent->hdr.len = 0;
pevent->state = FAN_EVENT_INIT;
+ pevent->watchdog_cnt = 0;
pevent->path = *path;
/* NULL ppos means no range info */
pevent->ppos = range ? &range->pos : NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] fanotify: initialize permission event watchdog state
2026-07-03 3:13 [PATCH] fanotify: initialize permission event watchdog state xuanqiang.luo
@ 2026-07-03 15:17 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2026-07-03 15:17 UTC (permalink / raw)
To: xuanqiang.luo
Cc: linux-fsdevel, Jan Kara, Amir Goldstein, Joanne Koong,
Miklos Szeredi, linux-kernel, Xuanqiang Luo
On Fri 03-07-26 11:13:45, xuanqiang.luo@linux.dev wrote:
> From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
>
> fanotify permission events are allocated with kmem_cache_alloc(), but
> fanotify_alloc_perm_event() does not initialize watchdog_cnt.
>
> The watchdog reads watchdog_cnt after the event is moved to access_list.
> A stale value can make it warn too early or skip the warning.
>
> Initialize watchdog_cnt when allocating a permission event.
>
> Fixes: b8cf8fda522d ("fanotify: add watchdog for permission events")
> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Thanks. I've added the patch to my tree.
Honza
> ---
> fs/notify/fanotify/fanotify.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index a3555bebad63e..b59f0aa43c4be 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -599,6 +599,7 @@ static struct fanotify_event *fanotify_alloc_perm_event(const void *data,
> pevent->hdr.pad = 0;
> pevent->hdr.len = 0;
> pevent->state = FAN_EVENT_INIT;
> + pevent->watchdog_cnt = 0;
> pevent->path = *path;
> /* NULL ppos means no range info */
> pevent->ppos = range ? &range->pos : NULL;
> --
> 2.43.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-03 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 3:13 [PATCH] fanotify: initialize permission event watchdog state xuanqiang.luo
2026-07-03 15:17 ` Jan Kara
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.