summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Luczaj <mhal@rbox.co>2024-11-11 00:17:34 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-11-22 15:37:35 +0100
commita0b8fd37fd300d3d73254c4af6ab87f1a4593c9b (patch)
tree1a08d026eaac348f9796fd5f819736886e920418
parent9b242c4232af20897e1eddea4836e66af36e51ce (diff)
net: Make copy_safe_from_sockptr() match documentation
commit eb94b7bb10109a14a5431a67e5d8e31cfa06b395 upstream. 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: 6309863b31dd ("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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--include/linux/sockptr.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h
index 1c1a5d926b17..0eb3a2b1f81f 100644
--- a/include/linux/sockptr.h
+++ b/include/linux/sockptr.h
@@ -77,7 +77,9 @@ static inline int copy_safe_from_sockptr(void *dst, size_t ksize,
{
if (optlen < ksize)
return -EINVAL;
- return copy_from_sockptr(dst, optval, ksize);
+ if (copy_from_sockptr(dst, optval, ksize))
+ return -EFAULT;
+ return 0;
}
static inline int copy_to_sockptr_offset(sockptr_t dst, size_t offset,