net: Added security socket
Subsystems (3)
PATCH 1/1 net: Added security socket
Added security_socket_connect
in kernel_connect
--- net/socket.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/socket.c +6 -0
@@ -3526,6 +3526,12 @@ EXPORT_SYMBOL(kernel_accept);int kernel_connect (struct socket *sock,struct sockaddr *addr,int addrlen,int flags) { +int err; + + err =security_socket_connect (sock, (struct sockaddr *)addr, addrlen); +if (err) +return err; +return sock->ops->connect (sock, addr, addrlen, flags); }EXPORT_SYMBOL (kernel_connect);
Signature · 1 line
2.25.1
Quoted 15 lines · Denis Arefev
Added
security_socket_connect
inkernel_connectSigned-off-by Denis Arefev <[email protected]>--- net/socket.c | 6 ++++++ 1 file changed, 6 insertions(+)net/socket.c +0
-0@@ -3526,6 +3526,12 @@ EXPORT_SYMBOL(kernel_accept);int kernel_connect (struct socket *sock,struct sockaddr *addr,int addrlen,int flags)
net/socket.c EXPORT_SYMBOL(kernel_accept); · line 3537
Quoted 10 lines
net/socket.c +6
-0{ +int err; + + err =security_socket_connect (sock, (struct sockaddr *)addr, addrlen); +if (err) +return err; +return sock->ops->connect (sock, addr, addrlen, flags); }EXPORT_SYMBOL (kernel_connect);
Why would we need to be adding this? If we are already operating within kernel space it seems like it would be more problematic than not to have to push items out to userspace for security. Assuming an attacker is operating at the kernel level the system is already compromised is it not?
Also assuming we do need this why are we only dealing with connect when we should probably also be looking at all the other kernel socket calls then as well?
PATCH 1/1 net: Added security socket
Hi Alexander. I understand your concern.
That's right kernel_connect is in kernel space,
but kernel_connect is used in RPC requests (/net/sunrpc/xprtsock.c), and the RPC protocol is used by the NFS server.
Note kernel_sendmsg is already protected.
Quoted 6 lines · Denis Arefev
Hi Alexander. I understand your concern.
That's rightkernel_connectis in kernel space,
butkernel_connectis used in RPC requests (/net/sunrpc/xprtsock.c), and the RPC protocol is used by the NFS server.
Notekernel_sendmsgis already protected.
Can you add a write-up about the need for this in the patch description? Your patch description described what you are doing but not the why. My main concern is that your patch may end up causing issues that could later be reverted by someone if they don't understand the motivation behind why you are making this change.
Calling out things like the fact that you are trying to add security to RPC sockets would be useful and would make it easier for patch review as people more familiar with the security code could also tell you if this is the correct approach to this or not.
Thanks,
- Alex