Skip to content

Commit

Permalink
net: Make copy_safe_from_sockptr() match documentation
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mmhal authored and kuba-moo committed Nov 14, 2024
1 parent a03b18a commit eb94b7b
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_struct_from_sockptr(void *dst, size_t ksize,
Expand Down

0 comments on commit eb94b7b

Please sign in to comment.