mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
x25: convert to getsockopt_iter
Convert X.25 socket's getsockopt implementation to use the new getsockopt_iter callback with sockopt_t. Key changes: - Replace (char __user *optval, int __user *optlen) with sockopt_t *opt - Use opt->optlen for buffer length (input) and returned size (output) - Use copy_to_iter() instead of put_user()/copy_to_user() - Add linux/uio.h for copy_to_iter() Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://patch.msgid.link/20260507-getsock_two-v2-3-5873111d9c12@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
e0a917bca1
commit
447edcb0e4
@@ -53,6 +53,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/compat.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/uio.h>
|
||||
|
||||
#include <net/x25.h>
|
||||
#include <net/compat.h>
|
||||
@@ -448,7 +449,7 @@ static int x25_setsockopt(struct socket *sock, int level, int optname,
|
||||
}
|
||||
|
||||
static int x25_getsockopt(struct socket *sock, int level, int optname,
|
||||
char __user *optval, int __user *optlen)
|
||||
sockopt_t *opt)
|
||||
{
|
||||
struct sock *sk = sock->sk;
|
||||
int val, len, rc = -ENOPROTOOPT;
|
||||
@@ -456,22 +457,17 @@ static int x25_getsockopt(struct socket *sock, int level, int optname,
|
||||
if (level != SOL_X25 || optname != X25_QBITINCL)
|
||||
goto out;
|
||||
|
||||
rc = -EFAULT;
|
||||
if (get_user(len, optlen))
|
||||
goto out;
|
||||
len = opt->optlen;
|
||||
|
||||
rc = -EINVAL;
|
||||
if (len < 0)
|
||||
goto out;
|
||||
|
||||
len = min_t(unsigned int, len, sizeof(int));
|
||||
|
||||
rc = -EFAULT;
|
||||
if (put_user(len, optlen))
|
||||
goto out;
|
||||
opt->optlen = len;
|
||||
|
||||
val = test_bit(X25_Q_BIT_FLAG, &x25_sk(sk)->flags);
|
||||
rc = copy_to_user(optval, &val, len) ? -EFAULT : 0;
|
||||
rc = copy_to_iter(&val, len, &opt->iter_out) != len ? -EFAULT : 0;
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
@@ -1753,7 +1749,7 @@ static const struct proto_ops x25_proto_ops = {
|
||||
.listen = x25_listen,
|
||||
.shutdown = sock_no_shutdown,
|
||||
.setsockopt = x25_setsockopt,
|
||||
.getsockopt = x25_getsockopt,
|
||||
.getsockopt_iter = x25_getsockopt,
|
||||
.sendmsg = x25_sendmsg,
|
||||
.recvmsg = x25_recvmsg,
|
||||
.mmap = sock_no_mmap,
|
||||
|
||||
Reference in New Issue
Block a user