pidfd/cgroup-util: use fully-sized filehandle buffers

The current code assumes that FILEID_KERNFS filehandles will never grow
in size. This is not a safe assumption and userland shouldn't be trying
to guess the size of the filehandle it'll get.

We have a macro for that: MAX_HANDLE_SZ.
This commit is contained in:
Jeff Layton
2026-01-29 00:57:03 +09:00
committed by Yu Watanabe
parent 2e14be9a84
commit eb2e91b981
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -38,7 +38,7 @@
/* The structure to pass to name_to_handle_at() on cgroupfs2 */
typedef union {
struct file_handle file_handle;
uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)];
uint8_t space[MAX_HANDLE_SZ];
} cg_file_handle;
#define CG_FILE_HANDLE_INIT \
+1 -1
View File
@@ -239,7 +239,7 @@ int pidfd_get_inode_id_impl(int fd, uint64_t *ret) {
if (file_handle_supported) {
union {
struct file_handle file_handle;
uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)];
uint8_t space[MAX_HANDLE_SZ];
} fh = {
.file_handle.handle_bytes = sizeof(uint64_t),
.file_handle.handle_type = FILEID_KERNFS,