lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 02 Feb 2017 17:51:48 -0800
From:   Eric Dumazet <eric.dumazet@...il.com>
To:     Lorenzo Colitti <lorenzo@...gle.com>
Cc:     Daniel Borkmann <daniel@...earbox.net>,
        Chenbo Feng <chenbofeng.kernel@...il.com>,
        "David S . Miller" <davem@...emloft.net>,
        Alexei Starovoitov <ast@...com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Willem de Bruijn <willemb@...gle.com>,
        Chenbo Feng <fengc@...gle.com>
Subject: Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve
 socket uid

On Fri, 2017-02-03 at 10:18 +0900, Lorenzo Colitti wrote:
> On Fri, Feb 3, 2017 at 9:31 AM, Eric Dumazet <eric.dumazet@...il.com> wrote:
> >> It should be safe to call sock_net_uid on any type of socket
> >> (including NULL). sk_uid was added to struct sock in 86741ec25462
> >> ("net: core: Add a UID field to struct sock.")
> >
> > But a request socket or a timewait socket do not have this field.
> >
> > Daniel point is valid.
> 
> My bad. Yes.
> 
> It would definitely be useful to have the UID available in request
> sockets, and perhaps timewait sockets as well. That could be done by
> moving the UID to sock_common, or with something along the lines of:
> 
>  static inline kuid_t sock_net_uid(const struct net *net, const struct sock *sk)
>  {
> +       if (sk && sk->sk_state == TCP_NEW_SYN_RECV)
> +               sk = sk->__sk_common.skc_listener;
> +       else if (sk && !sk_fullsock(sk))
> +               sk = NULL;
> +
>         return sk ? sk->sk_uid : make_kuid(net->user_ns, 0);
>  }
> 
> Any thoughts on which is better?

You could use

if (sk) {
    sk = sk_to_full_sk(sk);
    if (sk_fullsock(sk))
        return sk->sk_uid;
}


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ