mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] taskstats: fix cgroupstats invalid fd handling and add selftests
@ 2026-07-10 20:07 Yiyang Chen
  2026-07-10 20:07 ` [PATCH 1/2] taskstats: return -EBADF when cgroupstats receives an invalid fd Yiyang Chen
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Yiyang Chen @ 2026-07-10 20:07 UTC (permalink / raw)
  To: Balbir Singh, Andrew Morton; +Cc: linux-kernel, Dr . Thomas Orgis, Yiyang Chen

This series fixes an issue where cgroupstats mishandles invalid file
descriptors, and introduces a functional kselftest to prevent regressions.

When an invalid file descriptor is passed via CGROUPSTATS_CMD_ATTR_FD,
cgroupstats_user_cmd() returns 0 instead of an error code. This leads to
two broken behaviors depending on netlink flags:
- Callers without NLM_F_ACK block indefinitely on recv().
- Callers with NLM_F_ACK receive a misleading success ACK (errno == 0)
  but no actual statistics payload.

The first patch addresses this by returning -EBADF when the fd cannot be
resolved. The second patch adds a comprehensive kselftest covering both
the valid cgroup v1 query and the invalid fd paths (with and without
NLM_F_ACK) to ensure the fixes work as intended.

Yiyang Chen (2):
  taskstats: return -EBADF when cgroupstats receives an invalid fd
  selftests/acct: add cgroupstats functional test

 kernel/taskstats.c                         |   2 +-
 tools/testing/selftests/acct/Makefile      |   1 +
 tools/testing/selftests/acct/cgroupstats.c | 354 +++++++++++++++++++++
 3 files changed, 356 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/acct/cgroupstats.c

-- 
2.43.0


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

end of thread, other threads:[~2026-07-27  0:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-10 20:07 [PATCH 0/2] taskstats: fix cgroupstats invalid fd handling and add selftests Yiyang Chen
2026-07-10 20:07 ` [PATCH 1/2] taskstats: return -EBADF when cgroupstats receives an invalid fd Yiyang Chen
2026-07-27  0:40   ` Balbir Singh
2026-07-10 20:07 ` [PATCH 2/2] selftests/acct: add cgroupstats functional test Yiyang Chen
2026-07-10 22:59 ` [PATCH 0/2] taskstats: fix cgroupstats invalid fd handling and add selftests Andrew Morton
2026-07-11  4:44   ` Yiyang Chen
2026-07-24 22:51 ` Bradley Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®