lkml.org 
[lkml]   [2023]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 9/9] net: use new capable_any functionality
Hi Christian,

cgzones@googlemail.com wrote on Thu, 11 May 2023 16:25:32 +0200:

> Use the new added capable_any function in appropriate cases, where a
> task is required to have any of two capabilities.
>
> Add sock_ns_capable_any() wrapper similar to existing sock_ns_capable()
> one.
>
> Reorder CAP_SYS_ADMIN last.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
> v4:
> - introduce sockopt_ns_capable_any()
> v3:
> - rename to capable_any()
> - make use of ns_capable_any
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
> include/net/sock.h | 1 +
> net/caif/caif_socket.c | 2 +-
> net/core/sock.c | 18 ++++++++++--------
> net/ieee802154/socket.c | 6 ++----
> net/ipv4/ip_sockglue.c | 4 ++--
> net/ipv6/ipv6_sockglue.c | 3 +--
> net/unix/scm.c | 2 +-
> 7 files changed, 18 insertions(+), 18 deletions(-)
>

[...]

> diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
> index 1fa2fe041ec0..f9bc6cae4af9 100644
> --- a/net/ieee802154/socket.c
> +++ b/net/ieee802154/socket.c
> @@ -904,8 +904,7 @@ static int dgram_setsockopt(struct sock *sk, int level, int optname,
> ro->want_lqi = !!val;
> break;
> case WPAN_SECURITY:
> - if (!ns_capable(net->user_ns, CAP_NET_ADMIN) &&
> - !ns_capable(net->user_ns, CAP_NET_RAW)) {
> + if (!ns_capable_any(net->user_ns, CAP_NET_ADMIN, CAP_NET_RAW)) {
> err = -EPERM;
> break;
> }
> @@ -928,8 +927,7 @@ static int dgram_setsockopt(struct sock *sk, int level, int optname,
> }
> break;
> case WPAN_SECURITY_LEVEL:
> - if (!ns_capable(net->user_ns, CAP_NET_ADMIN) &&
> - !ns_capable(net->user_ns, CAP_NET_RAW)) {
> + if (!ns_capable_any(net->user_ns, CAP_NET_ADMIN, CAP_NET_RAW)) {
> err = -EPERM;
> break;
> }

I was not noticed this was applied already, so, for ieee802154:

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

\
 
 \ /
  Last update: 2023-05-22 18:48    [W:0.173 / U:1.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site