[PATCH 04/22] pidfs: add missing BUILD_BUG_ON() assert on struct pidfd_info

Christian Brauner posted 22 patches 3 months, 1 week ago
[PATCH 04/22] pidfs: add missing BUILD_BUG_ON() assert on struct pidfd_info
Posted by Christian Brauner 3 months, 1 week ago
Validate that the size of struct pidfd_info is correctly updated.

Fixes: 1d8db6fd698d ("pidfs, coredump: add PIDFD_INFO_COREDUMP")
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/pidfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/pidfs.c b/fs/pidfs.c
index c0f410903c3f..7e4d90cc74ff 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -306,6 +306,8 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
 	const struct cred *c;
 	__u64 mask;
 
+	BUILD_BUG_ON(sizeof(struct pidfd_info) != PIDFD_INFO_SIZE_VER1);
+
 	if (!uinfo)
 		return -EINVAL;
 	if (usize < PIDFD_INFO_SIZE_VER0)

-- 
2.47.3
Re: [PATCH 04/22] pidfs: add missing BUILD_BUG_ON() assert on struct pidfd_info
Posted by Alexander Mikhalitsyn 3 months, 1 week ago
Am Di., 28. Okt. 2025 um 09:46 Uhr schrieb Christian Brauner
<brauner@kernel.org>:
>
> Validate that the size of struct pidfd_info is correctly updated.
>
> Fixes: 1d8db6fd698d ("pidfs, coredump: add PIDFD_INFO_COREDUMP")
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>

> ---
>  fs/pidfs.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/pidfs.c b/fs/pidfs.c
> index c0f410903c3f..7e4d90cc74ff 100644
> --- a/fs/pidfs.c
> +++ b/fs/pidfs.c
> @@ -306,6 +306,8 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
>         const struct cred *c;
>         __u64 mask;
>
> +       BUILD_BUG_ON(sizeof(struct pidfd_info) != PIDFD_INFO_SIZE_VER1);
> +
>         if (!uinfo)
>                 return -EINVAL;
>         if (usize < PIDFD_INFO_SIZE_VER0)
>
> --
> 2.47.3
>