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: <94c81ecec7e0653705ba8c989ea4842783152232.camel@linux.dev>
Date: Thu, 24 Jul 2025 19:05:55 +0800
From: KaFai Wan <kafai.wan@...ux.dev>
To: Yonghong Song <yonghong.song@...ux.dev>, ast@...nel.org, 
 daniel@...earbox.net, john.fastabend@...il.com, andrii@...nel.org, 
 martin.lau@...ux.dev, eddyz87@...il.com, song@...nel.org,
 kpsingh@...nel.org,  sdf@...ichev.me, haoluo@...gle.com, jolsa@...nel.org,
 mykolal@...com,  shuah@...nel.org, laoar.shao@...il.com,
 linux-kernel@...r.kernel.org,  bpf@...r.kernel.org,
 linux-kselftest@...r.kernel.org, leon.hwang@...ux.dev
Subject: Re: [PATCH bpf-next v3 3/4] selftests/bpf: Add selftest for
 attaching tracing programs to functions in deny list

On Wed, 2025-07-23 at 09:42 -0700, Yonghong Song wrote:
> 
> 
> On 7/22/25 8:34 AM, KaFai Wan wrote:
> > The result:
> > 
> >   $ tools/testing/selftests/bpf/test_progs -t
> > tracing_failure/tracing_deny
> >   #468/3   tracing_failure/tracing_deny:OK
> >   #468     tracing_failure:OK
> >   Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
> > 
> > Signed-off-by: KaFai Wan <kafai.wan@...ux.dev>
> 
> LGTM but see a nit below.
> 
> Acked-by: Yonghong Song <yonghong.song@...ux.dev>
> 
> > ---
> >   .../bpf/prog_tests/tracing_failure.c          | 33
> > +++++++++++++++++++
> >   .../selftests/bpf/progs/tracing_failure.c     |  6 ++++
> >   2 files changed, 39 insertions(+)
> > 
> > diff --git
> > a/tools/testing/selftests/bpf/prog_tests/tracing_failure.c
> > b/tools/testing/selftests/bpf/prog_tests/tracing_failure.c
> > index a222df765bc3..140fb0d175cf 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/tracing_failure.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/tracing_failure.c
> > @@ -28,10 +28,43 @@ static void test_bpf_spin_lock(bool
> > is_spin_lock)
> >   	tracing_failure__destroy(skel);
> >   }
> >   
> > +static void test_tracing_deny(void)
> > +{
> > +	struct tracing_failure *skel;
> > +	char log_buf[256];
> > +	int btf_id, err;
> > +
> > +	/* migrate_disable depends on CONFIG_SMP */
> > +	btf_id = libbpf_find_vmlinux_btf_id("migrate_disable",
> > BPF_TRACE_FENTRY);
> > +	if (btf_id <= 0) {
> > +		test__skip();
> > +		return;
> > +	}
> 
> There is a discussion about inlining migrate_disable(). See
>   
> https://lore.kernel.org/bpf/CAADnVQ+Afov4E=9t=3M=zZmO9z4ZqT6imWD5xijDHshTf3J=RA@mail.gmail.com/
> 
> Maybe trying to find a different function? Otherwise, if
> migrate_disable
> is inlined and this test will become useless.
> 
Okey, I will use __rcu_read_lock() instead.
> > +
> > +	skel = tracing_failure__open();
> > +	if (!ASSERT_OK_PTR(skel, "tracing_failure__open"))
> > +		return;
> > +
> > +	bpf_program__set_autoload(skel->progs.tracing_deny, true);
> > +	bpf_program__set_log_buf(skel->progs.tracing_deny,
> > log_buf, sizeof(log_buf));
> > +
> > +	err = tracing_failure__load(skel);
> > +	if (!ASSERT_ERR(err, "tracing_failure__load"))
> > +		goto out;
> > +
> > +	ASSERT_HAS_SUBSTR(log_buf,
> > +			  "Attaching tracing programs to function
> > 'migrate_disable' is rejected.",
> > +			  "log_buf");
> > +out:
> > +	tracing_failure__destroy(skel);
> > +}
> > +
> >   void test_tracing_failure(void)
> >   {
> >   	if (test__start_subtest("bpf_spin_lock"))
> >   		test_bpf_spin_lock(true);
> >   	if (test__start_subtest("bpf_spin_unlock"))
> >   		test_bpf_spin_lock(false);
> > +	if (test__start_subtest("tracing_deny"))
> > +		test_tracing_deny();
> >   }
> > diff --git a/tools/testing/selftests/bpf/progs/tracing_failure.c
> > b/tools/testing/selftests/bpf/progs/tracing_failure.c
> > index d41665d2ec8c..dfa152e8194e 100644
> > --- a/tools/testing/selftests/bpf/progs/tracing_failure.c
> > +++ b/tools/testing/selftests/bpf/progs/tracing_failure.c
> > @@ -18,3 +18,9 @@ int BPF_PROG(test_spin_unlock, struct
> > bpf_spin_lock *lock)
> >   {
> >   	return 0;
> >   }
> > +
> > +SEC("?fentry/migrate_disable")
> > +int BPF_PROG(tracing_deny)
> > +{
> > +	return 0;
> > +}
> 

-- 
Thanks,
KaFai

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ