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] [day] [month] [year] [list]
Message-ID: <Z4qIjSMgIOqbHoef@jkangas-thinkpadp1gen3.rmtuswa.csb>
Date: Fri, 17 Jan 2025 08:42:53 -0800
From: Jared Kangas <jkangas@...hat.com>
To: Martin KaFai Lau <martin.lau@...ux.dev>
Cc: bpf@...r.kernel.org, davem@...emloft.net, edumazet@...gle.com,
	kuba@...nel.org, pabeni@...hat.com, horms@...nel.org,
	martin.lau@...nel.org, ast@...nel.org, johannes.berg@...el.com,
	kafai@...com, songliubraving@...com, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf] bpf: use attach_btf instead of vmlinux in
 bpf_sk_storage_tracing_allowed

On Thu, Jan 16, 2025 at 12:03:53PM -0800, Martin KaFai Lau wrote:
> On 1/16/25 8:23 AM, Jared Kangas wrote:
> > diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
> > index 2f4ed83a75ae..74584dd12550 100644
> > --- a/net/core/bpf_sk_storage.c
> > +++ b/net/core/bpf_sk_storage.c
> > @@ -352,8 +352,8 @@ const struct bpf_func_proto bpf_sk_storage_delete_proto = {
> >   static bool bpf_sk_storage_tracing_allowed(const struct bpf_prog *prog)
> >   {
> > -	const struct btf *btf_vmlinux;
> >   	const struct btf_type *t;
> > +	const struct btf *btf;
> >   	const char *tname;
> >   	u32 btf_id;
> > @@ -371,12 +371,12 @@ static bool bpf_sk_storage_tracing_allowed(const struct bpf_prog *prog)
> >   		return true;
> >   	case BPF_TRACE_FENTRY:
> >   	case BPF_TRACE_FEXIT:
> > -		btf_vmlinux = bpf_get_btf_vmlinux();
> > -		if (IS_ERR_OR_NULL(btf_vmlinux))
> > +		btf = prog->aux->attach_btf;
> > +		if (!btf)
> >   			return false;
> >   		btf_id = prog->aux->attach_btf_id;
> > -		t = btf_type_by_id(btf_vmlinux, btf_id);
> > -		tname = btf_name_by_offset(btf_vmlinux, t->name_off);
> > +		t = btf_type_by_id(btf, btf_id);
> > +		tname = btf_name_by_offset(btf, t->name_off);
> >   		return !!strncmp(tname, "bpf_sk_storage",
> >   				 strlen("bpf_sk_storage"));
> 
> Thanks for the report.
> 
> There is a prog->aux->attach_func_name, so it can be directly used, like:
> 
> 	case BPF_TRACE_FENTRY:
> 	case BPF_TRACE_FEXIT:
> 		return !!strncmp(prog->aux->attach_func_name, "bpf_sk_storage",
> 				 strlen("bpf_sk_storage"));
> 
> The above should do for the fix.
> 
> No need to check for null on attach_func_name. It should have been checked
> earlier in bpf_check_attach_target (the "tname" variable).

Good to know, that simplifies the patch quite a bit. Should I add a
Suggested-by when resubmitting?

> 
> pw-bot: cr
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ