[PATCH v2 0/2] pidfs: do not report fields that do not fit into the caller's struct

From: Nickolai Zeldovich

Date: Sat Oct 24 2026 - 00:14:33 EST


PIDFD_GET_INFO sets the mask bits of fields that lie beyond the struct
size the caller passed, although the uapi header promises that the mask
names no such field and tells userspace to rely on the mask. Patch 1
clears those bits before the copy. Patch 2 adds a selftest for it.

Tested in a QEMU x86_64 guest: the new test fails without patch 1 and
passes with it, and the other pidfd selftests give the same results with
and without patch 1. Built with W=1 for x86_64.

The bug was found and fixed with the assistance of an AI agent.

Changes in v2:
- Split the selftest into its own patch (Christian Brauner).
- Rebased onto current mainline. struct pidfd_info has no new fields
since v1, so the size checks are unchanged.

v1: https://lore.kernel.org/all/20261017020634.792390-1-nickolai@xxxxxxxxxxxxx/

Nickolai Zeldovich (2):
pidfs: do not report fields that do not fit into the caller's struct
selftests/pidfd: test that fields beyond the struct size are not
reported

fs/pidfs.c | 8 ++++
tools/testing/selftests/pidfd/pidfd.h | 16 +++++++
.../testing/selftests/pidfd/pidfd_info_test.c | 48 +++++++++++++++++++
3 files changed, 72 insertions(+)


base-commit: 17bb0e2f6c8043f70a693a5f3797471cbed354c8
--
2.53.0