net: allow SO_MARK with CAP_NET_RAW
Subsystems (3)
PATCH 1/1 net: allow SO_MARK with CAP_NET_RAW
From: Maciej Żenczykowski <[email protected]>
A CAP_NET_RAW capable process can already spoof (on transmit) anything it desires via raw packet sockets... There is no good reason to not allow it to also be able to play routing tricks on packets from its own normal sockets.
There is a desire to be able to use SO_MARK for routing table selection (via ip rule fwmark) from within a user process without having to run it as root. Granting it CAP_NET_RAW is much less dangerous than CAP_NET_ADMIN (CAP_NET_RAW doesn't permit persistent state change, while CAP_NET_ADMIN does - by for example allowing the reconfiguration of the routing tables and/or bringing up/down devices).
Let's keep CAP_NET_ADMIN for persistent state changes, while using CAP_NET_RAW for non-configuration related stuff.
--- net/core/sock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/sock.c +2 -1
@@ -1281,7 +1281,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname,clear_bit (SOCK_PASSSEC , &sock->flags);break ;case SO_MARK : -if (!ns_capable (sock_net (sk)->user_ns,CAP_NET_ADMIN )) { +if (!ns_capable (sock_net (sk)->user_ns,CAP_NET_RAW ) && + !ns_capable (sock_net (sk)->user_ns,CAP_NET_ADMIN )) { ret = -EPERM ;break ; }
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 23 Nov 2021 12:37:15 -0800 you wrote:
From: Maciej Żenczykowski <[email protected]>
A
CAP_NET_RAWcapable process can already spoof (on transmit) anything it desires via raw packet sockets... There is no good reason to not allow it to also be able to play routing tricks on packets from its own normal sockets.[...]
Here is the summary with links:
- net: allow SO_MARK with CAP_NET_RAW
https://git.kernel.org/netdev/net-next/c/079925cce1d0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html