Skip to contentSkip to conversation

net: align SO_RCVMARK required privileges with SO_MARK

PATCH Applied Eyal Birger 3 participants 3 messages May 4, 2022 – May 6, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: align SO_RCVMARK required privileges with SO_MARK

The commit referenced in the "Fixes" tag added the SO_RCVMARK socket option for receiving the skb mark in the ancillary data.

Since this is a new capability, and exposes admin configured details regarding the underlying network setup to sockets, let's align the needed capabilities with those of SO_MARK.

Fixes 6fd1d51cfa25 ("net: SO_RCVMARK socket option for SO_MARK with recvmsg()")
---
 net/core/sock.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/core/sock.c +6 -0
index be20a1af20e5..6b287eb5427b 100644
@@ -1315,6 +1315,12 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 		__sock_set_mark(sk, val);
 		break;
 	case SO_RCVMARK:
+		if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_RAW) &&
+		    !ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
+			ret = -EPERM;
+			break;
+		}
+
 		sock_valbool_flag(sk, SOCK_RCVMARK, valbool);
 		break;
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 9 lines · On Wed, 4 May 2022 12:54:59 +0300 Eyal Birger wrote:

The commit referenced in the "Fixes" tag added the SO_RCVMARK socket option for receiving the skb mark in the ancillary data.

Since this is a new capability, and exposes admin configured details regarding the underlying network setup to sockets, let's align the needed capabilities with those of SO_MARK.

Fixes 6fd1d51cfa25 ("net: SO_RCVMARK socket option for SO_MARK with recvmsg()")

It's not really as bad as the ability to set the mark, but since Erin is not complaining I assume it's fine with their use case.

#2 lore raw
In reply to Eyal Birger
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 Wed, 4 May 2022 12:54:59 +0300 you wrote:

The commit referenced in the "Fixes" tag added the SO_RCVMARK socket option for receiving the skb mark in the ancillary data.

Since this is a new capability, and exposes admin configured details regarding the underlying network setup to sockets, let's align the needed capabilities with those of SO_MARK.

[...]

Here is the summary with links:
- [net-next] net: align SO_RCVMARK required privileges with SO_MARK

    https://git.kernel.org/netdev/net-next/c/1f86123b9749

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html