[PATCH] net: allow CAP_NET_RAW to setsockopt SO_PRIORITY

Subsystems: networking [general], networking [sockets], the rest

STALE1718d LANDED

Landed in mainline as a1b519b74548 on 2021-11-25.

2 messages, 2 authors, 2021-11-25 · open the first message on its own page

[PATCH] net: allow CAP_NET_RAW to setsockopt SO_PRIORITY

From: Maciej Żenczykowski <hidden>
Date: 2021-11-23 20:37:12

From: Maciej Żenczykowski <redacted>

CAP_NET_ADMIN is and should continue to be about configuring the
system as a whole, not about configuring per-socket or per-packet
parameters.
Sending and receiving raw packets is what CAP_NET_RAW is all about.

It can already send packets with any VLAN tag, and any IPv4 TOS
mark, and any IPv6 TCLASS mark, simply by virtue of building
such a raw packet.  Not to mention using any protocol and source/
/destination ip address/port tuple.

These are the fields that networking gear uses to prioritize packets.

Hence, a CAP_NET_RAW process is already capable of affecting traffic
prioritization after it hits the wire.  This change makes it capable
of affecting traffic prioritization even in the host at the nic and
before that in the queueing disciplines (provided skb->priority is
actually being used for prioritization, and not the TOS/TCLASS field)

Hence it makes sense to allow a CAP_NET_RAW process to set the
priority of sockets and thus packets it sends.

Signed-off-by: Maciej Żenczykowski <redacted>
---
 net/core/sock.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/net/core/sock.c b/net/core/sock.c
index 31a2b79c9b38..1e49a127adef 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1135,6 +1135,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 
 	case SO_PRIORITY:
 		if ((val >= 0 && val <= 6) ||
+		    ns_capable(sock_net(sk)->user_ns, CAP_NET_RAW) ||
 		    ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))
 			sk->sk_priority = val;
 		else
-- 
2.34.0.rc2.393.gf8c9666880-goog

Re: [PATCH] net: allow CAP_NET_RAW to setsockopt SO_PRIORITY

From: patchwork-bot+netdevbpf@kernel.org
Date: 2021-11-25 03:12:13

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski [off-list ref]:

On Tue, 23 Nov 2021 12:37:02 -0800 you wrote:
From: Maciej Żenczykowski <redacted>

CAP_NET_ADMIN is and should continue to be about configuring the
system as a whole, not about configuring per-socket or per-packet
parameters.
Sending and receiving raw packets is what CAP_NET_RAW is all about.

[...]
Here is the summary with links:
  - net: allow CAP_NET_RAW to setsockopt SO_PRIORITY
    https://git.kernel.org/netdev/net-next/c/a1b519b74548

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help