net: allow CAP_NET_RAW to setsockopt SO_PRIORITY
Subsystems (3)
PATCH 1/1 net: allow CAP_NET_RAW to setsockopt SO_PRIORITY
From: Maciej Żenczykowski <[email protected]>
It is my belief that 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. Hence it makes sense to allow a CAP_NET_RAW process to set the priority of sockets and thus packets it sends.
--- net/core/sock.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
net/core/sock.c +2 -1
@@ -612,7 +612,8 @@ set_rcvbuf:break ;case SO_PRIORITY : -if ((val >=0 && val <=6 ) ||capable (CAP_NET_ADMIN )) +if ((val >=0 && val <=6 ) + ||capable (CAP_NET_ADMIN ) ||capable (CAP_NET_RAW )) sk->sk_priority = val;else ret = -EPERM ;
Signature · 1 line
1.7.3.1
David Miller
maintainerFrom: Maciej Żenczykowski <[email protected]>
Date: Mon, 24 Oct 2011 21:47:18 -0700
Quoted 7 lines
It is my belief that
CAP_NET_ADMINis 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_RAWis all about. Hence it makes sense to allow aCAP_NET_RAWprocess to set the priority of sockets and thus packets it sends.
SO_PRIORITY influences the packet scheduler and internal queueing policies, not just the packet contents that hit the wire.
Thus CAP_NET_ADMIN is the appropriate capability check.
Quoted 5 lines
SO_PRIORITYinfluences the packet scheduler and internal queueing policies, not just the packet contents that hit the wire.Thus
CAP_NET_ADMINis the appropriate capability check.
I can certainly see why you would think that, but:
A raw socket can already spew traffic, ie. packets, with any content. This includes VLAN tags and IPv4 TOS field, and IPv6 TCLASS field. These are the fields used for packet prioritization at switches and in the rest of network fabric.
AFAICT, it makes no sense to allow a raw socket to prioritize traffic outside of the host, but
not allow it to prioritize traffic in the host.
- Maciej
David Miller
maintainerFrom: Maciej Żenczykowski <[email protected]>
Date: Mon, 24 Oct 2011 22:07:20 -0700
Quoted 4 lines
A raw socket can already spew traffic, ie. packets, with any content. This includes VLAN tags and IPv4 TOS field, and IPv6 TCLASS field. These are the fields used for packet prioritization at switches and in the rest of network fabric.
SO_PRIORITY can control prioritizations that are not influenced by packet contents.
There is a huge difference.
Quoted 4 lines
SO_PRIORITYcan control prioritizations that are not influenced by packet contents.There is a huge difference.
I do agree that it can do that, but I'm not sure the difference is huge as you so put it.
In the vast majority of cases prioritization is desired based on some meaningful aspect
of a packet that can also be observed later on in the network - hence vlan tags, tos/tclass marks,
protocol, port numbers and the like.
I guess to me, in the real world (or at least the portion of it I'm aware of), the difference is minor at best.
Being able to select xmit queues, is kind of like being able to select output device.
You give a CAP_NET_RAW process raw access to the wire - prioritization seems just one more aspect of this. Especially since this isn't permanently reconfiguring anything.
Anyway, enough discussion ;-)
Cheers,
Maciej