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]
Message-ID: <87blr6rqd4.fsf@cloudflare.com>
Date:   Tue, 14 Jan 2020 16:48:23 +0100
From:   Jakub Sitnicki <jakub@...udflare.com>
To:     Martin Lau <kafai@...com>,
        John Fastabend <john.fastabend@...il.com>
Cc:     "bpf\@vger.kernel.org" <bpf@...r.kernel.org>,
        "netdev\@vger.kernel.org" <netdev@...r.kernel.org>,
        "kernel-team\@cloudflare.com" <kernel-team@...udflare.com>,
        Eric Dumazet <edumazet@...gle.com>,
        Lorenz Bauer <lmb@...udflare.com>
Subject: Re: [PATCH bpf-next v2 07/11] bpf, sockmap: Return socket cookie on lookup from syscall

On Tue, Jan 14, 2020 at 04:16 AM CET, John Fastabend wrote:
> Martin Lau wrote:
>> On Fri, Jan 10, 2020 at 11:50:23AM +0100, Jakub Sitnicki wrote:
>> > Tooling that populates the SOCKMAP with sockets from user-space needs a way
>> > to inspect its contents. Returning the struct sock * that SOCKMAP holds to
>> > user-space is neither safe nor useful. An approach established by
>> > REUSEPORT_SOCKARRAY is to return a socket cookie (a unique identifier)
>> > instead.
>> >
>> > Since socket cookies are u64 values SOCKMAP needs to support such a value
>> > size for lookup to be possible. This requires special handling on update,
>> > though. Attempts to do a lookup on SOCKMAP holding u32 values will be met
>> > with ENOSPC error.
>> >
>> > Signed-off-by: Jakub Sitnicki <jakub@...udflare.com>
>> > ---
>
> [...]
>
>> > +static void *sock_map_lookup_sys(struct bpf_map *map, void *key)
>> > +{
>> > +	struct sock *sk;
>> > +
>> > +	WARN_ON_ONCE(!rcu_read_lock_held());
>> It seems unnecessary.  It is only called by syscall.c which
>> holds the rcu_read_lock().  Other than that,
>>
>
> +1 drop it. The normal rcu annotations/splats should catch anything
> here.

Oh, okay. Thanks for pointing it out.

I noticed __sock_map_lookup_elem called from sock_map_lookup_sys has the
same WARN_ON_ONCE check. Looks like it can be cleaned up.

Granted, __sock_map_lookup_elem also gets invoked by sockmap BPF helpers
for redirecting (bpf_msg_redirect_map, bpf_sk_redirect_map). But we
always run sk_skb and sk_msg progs RCU read lock held.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ