Skip to contentSkip to conversation

fanotify: initialize permission event watchdog state

PATCH In review [email protected] 2 participants 2 messages Jul 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fanotify: initialize permission event watchdog state

From: Xuanqiang Luo <[email protected]>

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")
---
 fs/notify/fanotify/fanotify.c | 1 +
 1 file changed, 1 insertion(+)
fs/notify/fanotify/fanotify.c +1 -0
index a3555bebad63e..b59f0aa43c4be 100644
@@ -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;
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 5 lines · On Fri 03-07-26 11:13:45, [email protected] wrote:

From: Xuanqiang Luo <[email protected]>

fanotify permission events are allocated with kmem_cache_alloc(), but fanotify_alloc_perm_event() does not initialize watchdog_cnt.

Quoted 7 lines

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")

Thanks. I've added the patch to my tree.

Honza

Quoted 19 lines
---
 fs/notify/fanotify/fanotify.c | 1 +
 1 file changed, 1 insertion(+)
fs/notify/fanotify/fanotify.c +1 -0
index a3555bebad63e..b59f0aa43c4be 100644
@@ -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;
Signature · 1 line
2.43.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR