Skip to content

taskstats: fix cgroupstats invalid fd handling and add selftests

Yiyang Chen lkml 1 version Applied

Status from this message: [merged mm-nonmm-stable] selftests-acct-add-cgroupstats-functional-test.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 4 repliesApplied 2/2

Patches in v1 All 2 applied

#Subject and filesSizeRepliesApplied
1/2taskstats: return -EBADF when cgroupstats receives an invalid fdkernel/taskstats.c+1 -11 replyApplied
2/2selftests/acct: add cgroupstats functional testtools/testing/selftests/acct/Makefile tools/testing/selftests/acct/cgroupstats.c+355 -00 repliesApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchBradley MorganBalbir Singh
SeriesR-b
1/2A-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] taskstats: fix cgroupstats invalid fd handling and add selftests

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
Signature · 1 line
2.43.0