net-ipv6: IPV6_TRANSPARENT - check NET_RAW prior to NET_ADMIN
diff mbox series

Message ID 20191121211908.64187-1-zenczykowski@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • net-ipv6: IPV6_TRANSPARENT - check NET_RAW prior to NET_ADMIN
Related show

Commit Message

Maciej Żenczykowski Nov. 21, 2019, 9:19 p.m. UTC
From: Maciej Żenczykowski <maze@google.com>

NET_RAW is less dangerous, so more likely to be available to a process,
so check it first to prevent some spurious logging.

This matches IP_TRANSPARENT which checks NET_RAW first.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/ipv6_sockglue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller Nov. 22, 2019, 3:15 a.m. UTC | #1
From: Maciej Żenczykowski <zenczykowski@gmail.com>
Date: Thu, 21 Nov 2019 13:19:08 -0800

> From: Maciej Żenczykowski <maze@google.com>
> 
> NET_RAW is less dangerous, so more likely to be available to a process,
> so check it first to prevent some spurious logging.
> 
> This matches IP_TRANSPARENT which checks NET_RAW first.
> 
> Signed-off-by: Maciej Żenczykowski <maze@google.com>

Applied, thanks.

Patch
diff mbox series

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 264c292e7dcc..79fc012dd2ca 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -363,8 +363,8 @@  static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 		break;
 
 	case IPV6_TRANSPARENT:
-		if (valbool && !ns_capable(net->user_ns, CAP_NET_ADMIN) &&
-		    !ns_capable(net->user_ns, CAP_NET_RAW)) {
+		if (valbool && !ns_capable(net->user_ns, CAP_NET_RAW) &&
+		    !ns_capable(net->user_ns, CAP_NET_ADMIN)) {
 			retv = -EPERM;
 			break;
 		}