On 3/22/17 5:06 AM, Lorenzo Colitti wrote:
On Wed, Mar 22, 2017 at 8:09 PM, Willem de Bruijn
<willemdebruijn.ker...@gmail.com> wrote:
+       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);


makes sense to me.

Reply via email to