From: Christian Brauner Date: Wed, 5 Mar 2025 10:08:11 +0000 (+0100) Subject: pidfs: switch to copy_struct_to_user() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=816b2e602035214de9ca2f68751e64ecef023dd1;p=users%2Fjedix%2Flinux-maple.git pidfs: switch to copy_struct_to_user() We have a helper that deals with all the required logic. Link: https://lore.kernel.org/r/20250305-work-pidfs-kill_on_last_close-v3-1-c8c3d8361705@kernel.org Reviewed-by: Jeff Layton Reviewed-by: Oleg Nesterov Signed-off-by: Christian Brauner --- diff --git a/fs/pidfs.c b/fs/pidfs.c index 049352f973de..aa8c8bda8c8f 100644 --- a/fs/pidfs.c +++ b/fs/pidfs.c @@ -276,10 +276,7 @@ static long pidfd_info(struct task_struct *task, unsigned int cmd, unsigned long * userspace knows about will be copied. If userspace provides a new * struct, only the bits that the kernel knows about will be copied. */ - if (copy_to_user(uinfo, &kinfo, min(usize, sizeof(kinfo)))) - return -EFAULT; - - return 0; + return copy_struct_to_user(uinfo, usize, &kinfo, sizeof(kinfo), NULL); } static bool pidfs_ioctl_valid(unsigned int cmd)