Thread (9 messages) flat view 9 messages, 4 authors, 2017-03-22

Re: [PATCH net-next v7 2/3] Add a eBPF helper function to retrieve socket uid

From: Lorenzo Colitti <hidden>
Date: 2017-03-22 12:07:09

On Wed, Mar 22, 2017 at 8:09 PM, Willem de Bruijn
[off-list ref] wrote:
quoted
+       if (!sk || !sk_fullsock(sk))
+               return overflowuid;
+       kuid = sock_net_uid(sock_net(sk), sk);
+       return from_kuid_munged(&init_user_ns, kuid);
Ideally, this would be the user namespace relative to the BPF program.
What about sock_net(sk)->user_ns? We've already matched a socket, and
it's guaranteed to be a full socket and non-NULL (otherwise we've
already returned overflowuid), so it seems like the most correct
namespace to use is the one of the socket we've matched. Given that sk
is non-NULL, sock_net_uid just returns sk->sk_uid, so I think you can
just write this as:

if (!sk || !sk_fullsock(sk))
        return overflowuid;
return from_kuid_munged(sock_net(sk)->user_ns, sk->uid);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help