All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] selftests/cgroup: test pids.events notification
@ 2026-10-12  9:50 Sahaj Chaudhari
  2026-10-12 18:49 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Sahaj Chaudhari @ 2026-10-12  9:50 UTC (permalink / raw)
  To: tj, hannes, mkoutny, shuah; +Cc: cgroups, linux-kselftest, linux-kernel

Handle a failed read of the inotify event before comparing its signed ssize_t result with sizeof(struct inotify_event). This avoids treating -1 as a large unsigned length and inspecting the uninitialized event buffer.

Link: https://lore.kernel.org/r/20261007063516.1192279-1-sahaj123.sc@gmail.com
Signed-off-by: Sahaj Chaudhari <sahaj123.sc@gmail.com>
---
 tools/testing/selftests/cgroup/test_pids_local_events.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/cgroup/test_pids_local_events.c b/tools/testing/selftests/cgroup/test_pids_local_events.c
index fa501e209187..59885901fbf5 100644
--- a/tools/testing/selftests/cgroup/test_pids_local_events.c
+++ b/tools/testing/selftests/cgroup/test_pids_local_events.c
@@ -90,7 +90,11 @@ static int test_pids_events_notify(const char *root)
 		goto cleanup;
 	}
 	n = read(inotify_fd, event_buf.bytes, sizeof(event_buf.bytes));
-	if (n < sizeof(struct inotify_event) ||
+	if (n < 0) {
+		reason = "failed to read pids.events notification";
+		goto cleanup;
+	}
+	if ((size_t)n < sizeof(struct inotify_event) ||
 	    !(event_buf.align.mask & IN_MODIFY)) {
 		reason = "received no pids.events modify notification";
 		goto cleanup;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-12 18:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12  9:50 [PATCH v2] selftests/cgroup: test pids.events notification Sahaj Chaudhari
2026-10-12 18:49 ` Tejun Heo

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.