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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 23 Jun 2020 14:24:52 -0700
From:   Martin KaFai Lau <kafai@...com>
To:     Jakub Sitnicki <jakub@...udflare.com>
CC:     <bpf@...r.kernel.org>, <netdev@...r.kernel.org>,
        <kernel-team@...udflare.com>, Andrii Nakryiko <andriin@...com>
Subject: Re: [PATCH bpf-next v2 2/3] bpf, netns: Keep attached programs in
 bpf_prog_array

On Tue, Jun 23, 2020 at 10:59:37PM +0200, Jakub Sitnicki wrote:
> On Tue, Jun 23, 2020 at 09:33 PM CEST, Martin KaFai Lau wrote:
> > On Tue, Jun 23, 2020 at 12:34:58PM +0200, Jakub Sitnicki wrote:
> >
> > [ ... ]
> >
> >> @@ -93,8 +108,16 @@ static int bpf_netns_link_update_prog(struct bpf_link *link,
> >>  		goto out_unlock;
> >>  	}
> >>
> >> +	run_array = rcu_dereference_protected(net->bpf.run_array[type],
> >> +					      lockdep_is_held(&netns_bpf_mutex));
> >> +	if (run_array)
> >> +		ret = bpf_prog_array_replace_item(run_array, link->prog, new_prog);
> >> +	else
> > When will this happen?
> 
> This will never happen, unless there is a bug. As long as there is a
> link attached, run_array should never be detached (null). Because it can
> be handled gracefully, we fail the bpf(LINK_UPDATE) syscall.
> 
> Your question makes me think that perhaps it should trigger a warning,
> with WARN_ON_ONCE, to signal clearly to the reader that this is an
> unexpected state.
> 
> WDYT?
Thanks for confirming and the explanation.

If it will never happen, I would skip the "if (run_array)".  That
will help the code reading in the future.

I would not WARN also.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ