From a3c687a943233a7c5ae7e3fb906d1913b063c95c Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Thu, 13 Feb 2020 13:36:32 +0000 Subject: [PATCH] LU-12198 libcfs: always copy ioctl header back to user lnetctl_get_peer_list fills back the required size in header if the given buffer was too small. Userspace needs the info back to grow the buffer and try again. Note we only replace err on failure if err was previously not set Lustre-change: https://review.whamcloud.com/37559 Lustre-commit: 9e02ef474f8caa833d6a1b5e0068d5323a57e8c4 Fixes: fba98579efc4 ("LU-6202 libcfs: replace libcfs_register_ioctl with a blocking notifier_chain") Signed-off-by: Dominique Martinet Change-Id: I2b6e319aceeb00d488572053d27023891afe1928 Reviewed-by: Yang Sheng Reviewed-by: James Simmons Reviewed-by: Neil Brown Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/37720 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/libcfs/module.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index 44e949e..208565c 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -110,9 +110,8 @@ int libcfs_ioctl(unsigned long cmd, void __user *uparam) err = -EINVAL; else err = notifier_to_errno(err); - if (!err) - if (copy_to_user(uparam, hdr, hdr->ioc_len)) - err = -EFAULT; + if (copy_to_user(uparam, hdr, hdr->ioc_len) && !err) + err = -EFAULT; break; } out: -- 1.8.3.1