[PATCH net-next 3/6] af_iucv: convert to getsockopt_iter
Breno Leitao
leitao at debian.org
Wed May 13 05:34:14 PDT 2026
Convert IUCV 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()
Signed-off-by: Breno Leitao <leitao at debian.org>
---
net/iucv/af_iucv.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 72dfccd4e3d58..7a5ce93a83d9c 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -26,6 +26,7 @@
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/security.h>
+#include <linux/uio.h>
#include <net/sock.h>
#include <asm/machine.h>
#include <asm/ebcdic.h>
@@ -1535,7 +1536,7 @@ static int iucv_sock_setsockopt(struct socket *sock, int level, int optname,
}
static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
- char __user *optval, int __user *optlen)
+ sockopt_t *opt)
{
struct sock *sk = sock->sk;
struct iucv_sock *iucv = iucv_sk(sk);
@@ -1545,9 +1546,7 @@ static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
if (level != SOL_IUCV)
return -ENOPROTOOPT;
- if (get_user(len, optlen))
- return -EFAULT;
-
+ len = opt->optlen;
if (len < 0)
return -EINVAL;
@@ -1574,9 +1573,8 @@ static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
return -ENOPROTOOPT;
}
- if (put_user(len, optlen))
- return -EFAULT;
- if (copy_to_user(optval, &val, len))
+ opt->optlen = len;
+ if (copy_to_iter(&val, len, &opt->iter_out) != len)
return -EFAULT;
return 0;
@@ -2228,7 +2226,7 @@ static const struct proto_ops iucv_sock_ops = {
.socketpair = sock_no_socketpair,
.shutdown = iucv_sock_shutdown,
.setsockopt = iucv_sock_setsockopt,
- .getsockopt = iucv_sock_getsockopt,
+ .getsockopt_iter = iucv_sock_getsockopt,
};
static int iucv_sock_create(struct net *net, struct socket *sock, int protocol,
--
2.53.0-Meta
More information about the linux-afs
mailing list