Skip to content

Commit 5fd497e

Browse files
author
Bastien Nocera
committed
net: Make copy_safe_from_sockptr() match documentation
JIRA: https://issues.redhat.com/browse/RHEL-74483 commit eb94b7b Author: Michal Luczaj <mhal@rbox.co> Date: Mon Nov 11 00:17:34 2024 +0100 net: Make copy_safe_from_sockptr() match documentation copy_safe_from_sockptr() return copy_from_sockptr() return copy_from_sockptr_offset() return copy_from_user() copy_from_user() does not return an error on fault. Instead, it returns a number of bytes that were not copied. Have it handled. Patch has a side effect: it un-breaks garbage input handling of nfc_llcp_setsockopt() and mISDN's data_sock_setsockopt(). Fixes: 6309863 ("net: add copy_safe_from_sockptr() helper") Signed-off-by: Michal Luczaj <mhal@rbox.co> Link: https://patch.msgid.link/20241111-sockptr-copy-ret-fix-v1-1-a520083a93fb@rbox.co Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Bastien Nocera <bnocera@redhat.com>
1 parent 79f3c6e commit 5fd497e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/linux/sockptr.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ static inline int copy_safe_from_sockptr(void *dst, size_t ksize,
7777
{
7878
if (optlen < ksize)
7979
return -EINVAL;
80-
return copy_from_sockptr(dst, optval, ksize);
80+
if (copy_from_sockptr(dst, optval, ksize))
81+
return -EFAULT;
82+
return 0;
8183
}
8284

8385
static inline int copy_struct_from_sockptr(void *dst, size_t ksize,

0 commit comments

Comments
 (0)