mirror of
https://github.com/torvalds/linux.git
synced 2026-07-29 18:51:21 +02:00
sockptr: let copy_struct_from_sockptr() use copy_struct_from_bounce_buffer()
The world would be better without sockptr_t, but this at least simplifies copy_struct_from_sockptr() to be just a dispatcher for copy_struct_from_user() or copy_struct_from_bounce_buffer() without any special logic on its own. Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Dmitry Safonov <dima@arista.com> Cc: Francesco Ruggeri <fruggeri@arista.com> Cc: Salam Noureddine <noureddine@arista.com> Cc: David Ahern <dsahern@kernel.org> Cc: David S. Miller <davem@davemloft.net> Cc: Michal Luczaj <mhal@rbox.co> Cc: David Wei <dw@davidwei.uk> Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Xin Long <lucien.xin@gmail.com> Cc: Eric Dumazet <edumazet@google.com> Cc: Kuniyuki Iwashima <kuniyu@google.com> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Willem de Bruijn <willemb@google.com> Cc: Neal Cardwell <ncardwell@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Simon Horman <horms@kernel.org> Cc: Aleksa Sarai <cyphar@cyphar.com> Cc: Christian Brauner <brauner@kernel.org> CC: Kees Cook <keescook@chromium.org> Cc: netdev@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Link: https://patch.msgid.link/b9b7e22664a53251d7ad099b12aead8b599c1257.1775576651.git.metze@samba.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
2eef8b32e4
commit
d2c344740b
|
|
@ -87,24 +87,10 @@ static inline int copy_safe_from_sockptr(void *dst, size_t ksize,
|
|||
static inline int copy_struct_from_sockptr(void *dst, size_t ksize,
|
||||
sockptr_t src, size_t usize)
|
||||
{
|
||||
size_t size = min(ksize, usize);
|
||||
size_t rest = max(ksize, usize) - size;
|
||||
|
||||
if (!sockptr_is_kernel(src))
|
||||
return copy_struct_from_user(dst, ksize, src.user, usize);
|
||||
|
||||
if (usize < ksize) {
|
||||
memset(dst + size, 0, rest);
|
||||
} else if (usize > ksize) {
|
||||
char *p = src.kernel;
|
||||
|
||||
while (rest--) {
|
||||
if (*p++)
|
||||
return -E2BIG;
|
||||
}
|
||||
}
|
||||
memcpy(dst, src.kernel, size);
|
||||
return 0;
|
||||
return copy_struct_from_bounce_buffer(dst, ksize, src.kernel, usize);
|
||||
}
|
||||
|
||||
static inline int copy_to_sockptr_offset(sockptr_t dst, size_t offset,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user