mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
af_iucv: convert to getsockopt_iter
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() Acked-by: Stanislav Fomichev <sdf@fomichev.me> Acked-by: Alexandra Winter <wintera@linux.ibm.com> Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://patch.msgid.link/20260520-getsock_four-v3-1-b8c0b16b7780@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
c227f8aaf2
commit
347fdd4df8
|
|
@ -26,6 +26,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/poll.h>
|
#include <linux/poll.h>
|
||||||
#include <linux/security.h>
|
#include <linux/security.h>
|
||||||
|
#include <linux/uio.h>
|
||||||
#include <net/sock.h>
|
#include <net/sock.h>
|
||||||
#include <asm/machine.h>
|
#include <asm/machine.h>
|
||||||
#include <asm/ebcdic.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,
|
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 sock *sk = sock->sk;
|
||||||
struct iucv_sock *iucv = iucv_sk(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)
|
if (level != SOL_IUCV)
|
||||||
return -ENOPROTOOPT;
|
return -ENOPROTOOPT;
|
||||||
|
|
||||||
if (get_user(len, optlen))
|
len = opt->optlen;
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
@ -1574,9 +1573,8 @@ static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
|
||||||
return -ENOPROTOOPT;
|
return -ENOPROTOOPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (put_user(len, optlen))
|
opt->optlen = len;
|
||||||
return -EFAULT;
|
if (copy_to_iter(&val, len, &opt->iter_out) != len)
|
||||||
if (copy_to_user(optval, &val, len))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2228,7 +2226,7 @@ static const struct proto_ops iucv_sock_ops = {
|
||||||
.socketpair = sock_no_socketpair,
|
.socketpair = sock_no_socketpair,
|
||||||
.shutdown = iucv_sock_shutdown,
|
.shutdown = iucv_sock_shutdown,
|
||||||
.setsockopt = iucv_sock_setsockopt,
|
.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,
|
static int iucv_sock_create(struct net *net, struct socket *sock, int protocol,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user