Skip to content

Commit

Permalink
net: Make copy_safe_from_sockptr() match documentation
Browse files Browse the repository at this point in the history
commit eb94b7b 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: 6309863 ("net: add copy_safe_from_sockptr() helper")
Signed-off-by: Michal Luczaj <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
mmhal authored and gregkh committed Nov 22, 2024
1 parent 9b242c4 commit a0b8fd3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/linux/sockptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a0b8fd3

Please sign in to comment.