Re: [MPTCP] [PATCH 24/24] net: pass a sockptr_t into ->setsockopt

2020-07-22 Thread Matthieu Baerts

Hi Christoph,

On 20/07/2020 14:47, Christoph Hellwig wrote:

Rework the remaining setsockopt code to pass a sockptr_t instead of a
plain user pointer.  This removes the last remaining set_fs(KERNEL_DS)
outside of architecture specific code.

Signed-off-by: Christoph Hellwig 
---


...

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 27b6f250b87dfd..30a8e697b9db9c 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1627,7 +1627,7 @@ static void mptcp_destroy(struct sock *sk)
  }
  
  static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname,

-  char __user *optval, unsigned int optlen)
+  sockptr_t optval, unsigned int optlen)
  {
struct sock *sk = (struct sock *)msk;
struct socket *ssock;
@@ -1643,8 +1643,8 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock 
*msk, int optname,
return -EINVAL;
}
  
-		ret = sock_setsockopt(ssock, SOL_SOCKET, optname,

- USER_SOCKPTR(optval), optlen);
+   ret = sock_setsockopt(ssock, SOL_SOCKET, optname, optval,
+ optlen);


A very small detail related to the modifications in MPTCP code, only if 
you have to send a v2 and if you don't mind: may you move "optlen" to 
the previous line like it was before your patch 7/24. Same below at the 
end of the function.


That would reduce the global diff in MPTCP files to function signatures 
only.


Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net


Re: [PATCH 24/24] net: pass a sockptr_t into ->setsockopt

2020-07-20 Thread David Miller
From: Stefan Schmidt 
Date: Mon, 20 Jul 2020 16:19:38 +0200

> For the ieee802154 part:
> 
> Acked-by: Stefan Schmidt 

Please do not quote an entire patch just to add an ACK, trim it just
to the commit message, or even less.

Thank you.


Re: [PATCH 24/24] net: pass a sockptr_t into ->setsockopt

2020-07-20 Thread Stefan Schmidt

Hello.

On 20.07.20 14:47, Christoph Hellwig wrote:

Rework the remaining setsockopt code to pass a sockptr_t instead of a
plain user pointer.  This removes the last remaining set_fs(KERNEL_DS)
outside of architecture specific code.

Signed-off-by: Christoph Hellwig 
---
  crypto/af_alg.c   |  7 ++--
  drivers/crypto/chelsio/chtls/chtls_main.c | 18 ++-
  drivers/isdn/mISDN/socket.c   |  4 +--
  include/linux/net.h   |  4 ++-
  include/net/inet_connection_sock.h|  3 +-
  include/net/ip.h  |  2 +-
  include/net/ipv6.h|  4 +--
  include/net/sctp/structs.h|  2 +-
  include/net/sock.h|  4 +--
  include/net/tcp.h |  4 +--
  net/atm/common.c  |  6 ++--
  net/atm/common.h  |  2 +-
  net/atm/pvc.c |  2 +-
  net/atm/svc.c |  6 ++--
  net/ax25/af_ax25.c|  6 ++--
  net/bluetooth/hci_sock.c  |  8 ++---
  net/bluetooth/l2cap_sock.c| 22 ++---
  net/bluetooth/rfcomm/sock.c   | 12 ---
  net/bluetooth/sco.c   |  6 ++--
  net/caif/caif_socket.c|  8 ++---
  net/can/j1939/socket.c| 12 +++
  net/can/raw.c | 16 +-
  net/core/sock.c   |  2 +-
  net/dccp/dccp.h   |  2 +-
  net/dccp/proto.c  | 20 ++--
  net/decnet/af_decnet.c| 16 ++
  net/ieee802154/socket.c   |  6 ++--
  net/ipv4/ip_sockglue.c| 13 +++-
  net/ipv4/raw.c|  8 ++---
  net/ipv4/tcp.c|  5 ++-
  net/ipv4/udp.c|  6 ++--
  net/ipv4/udp_impl.h   |  4 +--
  net/ipv6/ipv6_sockglue.c  | 10 +++---
  net/ipv6/raw.c| 10 +++---
  net/ipv6/udp.c|  6 ++--
  net/ipv6/udp_impl.h   |  4 +--
  net/iucv/af_iucv.c|  4 +--
  net/kcm/kcmsock.c |  6 ++--
  net/l2tp/l2tp_ppp.c   |  4 +--
  net/llc/af_llc.c  |  4 +--
  net/mptcp/protocol.c  | 14 
  net/netlink/af_netlink.c  |  4 +--
  net/netrom/af_netrom.c|  4 +--
  net/nfc/llcp_sock.c   |  6 ++--
  net/packet/af_packet.c| 39 ---
  net/phonet/pep.c  |  4 +--
  net/rds/af_rds.c  | 30 -
  net/rds/rdma.c| 14 
  net/rds/rds.h |  6 ++--
  net/rose/af_rose.c|  4 +--
  net/rxrpc/af_rxrpc.c  |  8 ++---
  net/rxrpc/ar-internal.h   |  4 +--
  net/rxrpc/key.c   |  9 +++---
  net/sctp/socket.c |  4 +--
  net/smc/af_smc.c  |  4 +--
  net/socket.c  | 23 -
  net/tipc/socket.c |  8 ++---
  net/tls/tls_main.c| 17 +-
  net/vmw_vsock/af_vsock.c  |  4 +--
  net/x25/af_x25.c  |  4 +--
  net/xdp/xsk.c |  8 ++---
  61 files changed, 248 insertions(+), 258 deletions(-)

diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 29f71428520b4b..892242a42c3ec9 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -197,8 +197,7 @@ static int alg_bind(struct socket *sock, struct sockaddr 
*uaddr, int addr_len)
return err;
  }
  
-static int alg_setkey(struct sock *sk, char __user *ukey,

- unsigned int keylen)
+static int alg_setkey(struct sock *sk, sockptr_t ukey, unsigned int keylen)
  {
struct alg_sock *ask = alg_sk(sk);
const struct af_alg_type *type = ask->type;
@@ -210,7 +209,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
return -ENOMEM;
  
  	err = -EFAULT;

-   if (copy_from_user(key, ukey, keylen))
+   if (copy_from_sockptr(key, ukey, keylen))
goto out;
  
  	err = type->setkey(ask->private, key, keylen);

@@ -222,7 +221,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
  }
  
  static int alg_setsockopt(struct socket *sock, int level, int optname,

- char __user *optval, unsigned int optlen)
+ sockptr_t optval, unsigned int optlen)
  {
struct sock *sk = sock->sk;
struct alg_sock *ask = alg_sk(sk);
diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c 
b/drivers/crypt

[PATCH 24/24] net: pass a sockptr_t into ->setsockopt

2020-07-20 Thread Christoph Hellwig
Rework the remaining setsockopt code to pass a sockptr_t instead of a
plain user pointer.  This removes the last remaining set_fs(KERNEL_DS)
outside of architecture specific code.

Signed-off-by: Christoph Hellwig 
---
 crypto/af_alg.c   |  7 ++--
 drivers/crypto/chelsio/chtls/chtls_main.c | 18 ++-
 drivers/isdn/mISDN/socket.c   |  4 +--
 include/linux/net.h   |  4 ++-
 include/net/inet_connection_sock.h|  3 +-
 include/net/ip.h  |  2 +-
 include/net/ipv6.h|  4 +--
 include/net/sctp/structs.h|  2 +-
 include/net/sock.h|  4 +--
 include/net/tcp.h |  4 +--
 net/atm/common.c  |  6 ++--
 net/atm/common.h  |  2 +-
 net/atm/pvc.c |  2 +-
 net/atm/svc.c |  6 ++--
 net/ax25/af_ax25.c|  6 ++--
 net/bluetooth/hci_sock.c  |  8 ++---
 net/bluetooth/l2cap_sock.c| 22 ++---
 net/bluetooth/rfcomm/sock.c   | 12 ---
 net/bluetooth/sco.c   |  6 ++--
 net/caif/caif_socket.c|  8 ++---
 net/can/j1939/socket.c| 12 +++
 net/can/raw.c | 16 +-
 net/core/sock.c   |  2 +-
 net/dccp/dccp.h   |  2 +-
 net/dccp/proto.c  | 20 ++--
 net/decnet/af_decnet.c| 16 ++
 net/ieee802154/socket.c   |  6 ++--
 net/ipv4/ip_sockglue.c| 13 +++-
 net/ipv4/raw.c|  8 ++---
 net/ipv4/tcp.c|  5 ++-
 net/ipv4/udp.c|  6 ++--
 net/ipv4/udp_impl.h   |  4 +--
 net/ipv6/ipv6_sockglue.c  | 10 +++---
 net/ipv6/raw.c| 10 +++---
 net/ipv6/udp.c|  6 ++--
 net/ipv6/udp_impl.h   |  4 +--
 net/iucv/af_iucv.c|  4 +--
 net/kcm/kcmsock.c |  6 ++--
 net/l2tp/l2tp_ppp.c   |  4 +--
 net/llc/af_llc.c  |  4 +--
 net/mptcp/protocol.c  | 14 
 net/netlink/af_netlink.c  |  4 +--
 net/netrom/af_netrom.c|  4 +--
 net/nfc/llcp_sock.c   |  6 ++--
 net/packet/af_packet.c| 39 ---
 net/phonet/pep.c  |  4 +--
 net/rds/af_rds.c  | 30 -
 net/rds/rdma.c| 14 
 net/rds/rds.h |  6 ++--
 net/rose/af_rose.c|  4 +--
 net/rxrpc/af_rxrpc.c  |  8 ++---
 net/rxrpc/ar-internal.h   |  4 +--
 net/rxrpc/key.c   |  9 +++---
 net/sctp/socket.c |  4 +--
 net/smc/af_smc.c  |  4 +--
 net/socket.c  | 23 -
 net/tipc/socket.c |  8 ++---
 net/tls/tls_main.c| 17 +-
 net/vmw_vsock/af_vsock.c  |  4 +--
 net/x25/af_x25.c  |  4 +--
 net/xdp/xsk.c |  8 ++---
 61 files changed, 248 insertions(+), 258 deletions(-)

diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 29f71428520b4b..892242a42c3ec9 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -197,8 +197,7 @@ static int alg_bind(struct socket *sock, struct sockaddr 
*uaddr, int addr_len)
return err;
 }
 
-static int alg_setkey(struct sock *sk, char __user *ukey,
- unsigned int keylen)
+static int alg_setkey(struct sock *sk, sockptr_t ukey, unsigned int keylen)
 {
struct alg_sock *ask = alg_sk(sk);
const struct af_alg_type *type = ask->type;
@@ -210,7 +209,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
return -ENOMEM;
 
err = -EFAULT;
-   if (copy_from_user(key, ukey, keylen))
+   if (copy_from_sockptr(key, ukey, keylen))
goto out;
 
err = type->setkey(ask->private, key, keylen);
@@ -222,7 +221,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
 }
 
 static int alg_setsockopt(struct socket *sock, int level, int optname,
- char __user *optval, unsigned int optlen)
+ sockptr_t optval, unsigned int optlen)
 {
struct sock *sk = sock->sk;
struct alg_sock *ask = alg_sk(sk);
diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c 
b/drivers/crypto/chelsio/chtls/chtls_main.c
index d98b89d0fa6eeb..c3058dcdb33c5c 100644
--- a/drivers/crypto/chelsio/chtls/chtls_main.