All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xu Kuohai" <xukuohai@huaweicloud.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf 2/2] selftests/bpf: Add return value tests for lsm cgroup
Date: Sat, 23 May 2026 10:08:28 +0000	[thread overview]
Message-ID: <20260523100829.584DB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260523085806.417723-3-xukuohai@huaweicloud.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] BPF test programs for the `socket_create` LSM hook incorrectly declare `struct task_struct *task` as their argument instead of `int family`.
--

commit b7003df7335bb1051987324aa639e3088d3673b5
Author: Xu Kuohai <xukuohai@huawei.com>

selftests/bpf: Add return value tests for lsm cgroup

This commit adds tests to check return values set by the bpf_set_retval()
helper for lsm cgroup programs.

> diff --git a/tools/testing/selftests/bpf/progs/verifier_lsm.c b/tools/testing/selftests/bpf/progs/verifier_lsm.c
> index 38e8e91768620..2072671ed6439 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_lsm.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_lsm.c

[ ... ]

> @@ -188,4 +188,49 @@ int BPF_PROG(null_check, struct file *file)
>  	return 0;
>  }
>  
> +SEC("lsm_cgroup/socket_create")
> +__description("lsm_cgroup with -4095~0 retval test 1")
> +__success
> +int BPF_PROG(lsm_cgroup_set_retval_zero_valid, struct task_struct *task)

[Severity: Low]
Is this argument type correct for the socket_create hook? The LSM hook for
socket_create expects (int family, int type, int protocol, int kern), so
the first argument should be int family.

Using struct task_struct *task incorrectly casts the first integer argument
to a pointer. While it works here because the argument isn't dereferenced,
could this cause issues if this code is used as a template and the argument
is accessed in other tests?

> +{
> +	bpf_set_retval(0);
> +	return 0;
> +}

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260523085806.417723-1-xukuohai@huaweicloud.com?part=2

  reply	other threads:[~2026-05-23 10:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-23  8:58 [PATCH bpf 0/2] Add return value check for BPF_LSM_CGROUP Xu Kuohai
2026-05-23  8:58 ` [PATCH bpf 1/2] bpf: " Xu Kuohai
2026-05-23  9:48   ` sashiko-bot
2026-05-25  8:57     ` Xu Kuohai
2026-05-23  8:58 ` [PATCH bpf 2/2] selftests/bpf: Add return value tests for lsm cgroup Xu Kuohai
2026-05-23 10:08   ` sashiko-bot [this message]
2026-05-25  1:56     ` Xu Kuohai
2026-05-25 18:43   ` Emil Tsalapatis
2026-05-26  7:56     ` Xu Kuohai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260523100829.584DB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xukuohai@huaweicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.