lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 18 Jun 2020 09:09:37 -0700
From:   Jonathan Lemon <jonathan.lemon@...il.com>
To:     <netdev@...r.kernel.org>
CC:     <kernel-team@...com>, <axboe@...nel.dk>
Subject: [RFC PATCH 17/21] net/core: add the SO_REGISTER_DMA socket option

This option says that the socket will be performing zero copy sends
and receives through the netgpu module.

Signed-off-by: Jonathan Lemon <jonathan.lemon@...il.com>
---
 include/uapi/asm-generic/socket.h |  2 ++
 net/core/sock.c                   | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h
index 77f7c1638eb1..5a8577c90e2a 100644
--- a/include/uapi/asm-generic/socket.h
+++ b/include/uapi/asm-generic/socket.h
@@ -119,6 +119,8 @@
 
 #define SO_DETACH_REUSEPORT_BPF 68
 
+#define SO_REGISTER_DMA		69
+
 #if !defined(__KERNEL__)
 
 #if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))
diff --git a/net/core/sock.c b/net/core/sock.c
index 6c4acf1f0220..c9e93ee675d6 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -828,6 +828,25 @@ void sock_set_rcvbuf(struct sock *sk, int val)
 }
 EXPORT_SYMBOL(sock_set_rcvbuf);
 
+extern int netgpu_register_dma(struct sock *sk, char __user *optval, unsigned int optlen);
+
+static int
+sock_register_dma(struct sock *sk, char __user *optval, unsigned int optlen)
+{
+	int rc;
+	int (*fn)(struct sock *sk, char __user *optval, unsigned int optlen);
+
+	fn = symbol_get(netgpu_register_dma);
+	if (!fn)
+		return -EINVAL;
+
+	rc = fn(sk, optval, optlen);
+
+	symbol_put(netgpu_register_dma);
+
+	return rc;
+}
+
 /*
  *	This is meant for all protocols to use and covers goings on
  *	at the socket level. Everything here is generic.
@@ -1232,6 +1251,13 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 		}
 		break;
 
+	case SO_REGISTER_DMA:
+		if (!sk->sk_bound_dev_if)
+			ret = -EINVAL;
+		else
+			ret = sock_register_dma(sk, optval, optlen);
+		break;
+
 	case SO_TXTIME:
 		if (optlen != sizeof(struct sock_txtime)) {
 			ret = -EINVAL;
-- 
2.24.1

Powered by blists - more mailing lists