History

pidfd: add a new supported_mask field

Some of the future fields in struct pidfd_info can be optional. If the kernel has nothing to emit in that field, then it doesn't set the flag in the reply. This presents a problem: There is currently no way to know what mask flags the kernel supports since one can't always count on them being in the reply. Add a new PIDFD_INFO_SUPPORTED_MASK flag and field that the kernel can set in the reply. Userspace can use this to determine if the fields it requires from the kernel are supported. This also gives us a way to deprecate fields in the future, if that should become necessary.

Christian Brauner committed 1 year ago

Commit dfd78541 parent d8fc51d2 files · +19 −1Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/linux/pidfd.h+3−0
@@ -26,9 +26,11 @@ · 25 unmodified lines
2626 #define PIDFD_INFO_CGROUPID (1UL << 2) /* Always returned if available, even if not requested */
2727 #define PIDFD_INFO_EXIT (1UL << 3) /* Only returned if requested. */
2828 #define PIDFD_INFO_COREDUMP (1UL << 4) /* Only returned if requested. */
29+#define PIDFD_INFO_SUPPORTED_MASK (1UL << 5) /* Want/got supported mask flags */
2930
3031 #define PIDFD_INFO_SIZE_VER0 64 /* sizeof first published struct */
3132 #define PIDFD_INFO_SIZE_VER1 72 /* sizeof second published struct */
33+#define PIDFD_INFO_SIZE_VER2 80 /* sizeof third published struct */
3234
3335 /*
3436 * Values for @coredump_mask in pidfd_info.
@@ -94,6 +96,7 @@ struct pidfd_info { · 59 unmodified lines
9496 __s32 exit_code;
9597 __u32 coredump_mask;
9698 __u32 __spare1;
99+ __u64 supported_mask; /* Mask flags that this kernel supports */
97100 };
98101
99102 #define PIDFS_IOCTL_MAGIC 0xFF