Message ID | 20241115-sockptr-copy-fixes-v1-4-d183c87fcbd5@rbox.co |
---|---|
State | Superseded |
Headers | show |
Series | net: Fix some callers of copy_from_sockptr() | expand |
On 2024-11-14 15:27, Michal Luczaj wrote: > copy_from_sockptr() has a history of misuse. Add a comment explaining that > the function follows API of copy_from_user(), i.e. returns 0 for success, > or number of bytes not copied on error. > > Signed-off-by: Michal Luczaj <mhal@rbox.co> > --- > include/linux/sockptr.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h > index 195debe2b1dbc5abf768aa806eb6c73b99421e27..3e6c8e9d67aef66e8ac5a4e474c278ac08244163 100644 > --- a/include/linux/sockptr.h > +++ b/include/linux/sockptr.h > @@ -53,6 +53,8 @@ static inline int copy_from_sockptr_offset(void *dst, sockptr_t src, > /* Deprecated. > * This is unsafe, unless caller checked user provided optlen. > * Prefer copy_safe_from_sockptr() instead. > + * > + * Returns 0 for success, or number of bytes not copied on error. > */ > static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) > { > In addition to this, please update the docs for copy_safe_from_sockptr() that calls into copy_from_sockptr() which also contains the misunderstanding of what copy_from_sockptr() returns.
diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h index 195debe2b1dbc5abf768aa806eb6c73b99421e27..3e6c8e9d67aef66e8ac5a4e474c278ac08244163 100644 --- a/include/linux/sockptr.h +++ b/include/linux/sockptr.h @@ -53,6 +53,8 @@ static inline int copy_from_sockptr_offset(void *dst, sockptr_t src, /* Deprecated. * This is unsafe, unless caller checked user provided optlen. * Prefer copy_safe_from_sockptr() instead. + * + * Returns 0 for success, or number of bytes not copied on error. */ static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) {
copy_from_sockptr() has a history of misuse. Add a comment explaining that the function follows API of copy_from_user(), i.e. returns 0 for success, or number of bytes not copied on error. Signed-off-by: Michal Luczaj <mhal@rbox.co> --- include/linux/sockptr.h | 2 ++ 1 file changed, 2 insertions(+)