From: Dominique Martinet Date: Thu, 13 Feb 2020 13:36:32 +0000 (+0000) Subject: LU-12198 libcfs: always copy ioctl header back to user X-Git-Tag: 2.13.53~190 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=9e02ef474f8caa833d6a1b5e0068d5323a57e8c4;p=fs%2Flustre-release.git 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 Fixes: fba98579efc4 ("LU-6202 libcfs: replace libcfs_register_ioctl with a blocking notifier_chain") Signed-off-by: Dominique Martinet Change-Id: I2b6e319aceeb00d488572053d27023891afe1928 Reviewed-on: https://review.whamcloud.com/37559 Tested-by: jenkins Reviewed-by: Yang Sheng Reviewed-by: James Simmons Reviewed-by: Neil Brown Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index d925a6c..bb6abb6 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -224,9 +224,8 @@ static 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: