From: sashiko-bot@kernel.org
To: "Kuniyuki Iwashima" <kuniyu@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf 2/6] selftest: bpf: Add test for bpf_tcp_sock() and RAW socket.
Date: Tue, 05 May 2026 04:14:33 +0000 [thread overview]
Message-ID: <20260505041433.8B6AEC2BCC7@smtp.kernel.org> (raw)
In-Reply-To: <20260504210610.180150-3-kuniyu@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Newly added code uses manual error checks instead of the mandated modern ASSERT_* macros.
--
commit 1a574056fa08ab8c66dcd9b6ee5f0739ff6721b7
Author: Kuniyuki Iwashima <kuniyu@google.com>
selftest: bpf: Add test for bpf_tcp_sock() and RAW socket.
This commit adds a test to cover bpf_tcp_sock() for wrong socket types,
specifically tricking it with IPPROTO_TCP on an AF_INET RAW socket. It
also fixes a missing free() in the test.
> diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
> index 53637431ec5d..5fd33ad2eaaf 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
[ ... ]
> @@ -211,6 +211,22 @@ static int getsetsockopt(void)
> }
> ASSERT_EQ(optlen, 8, "Unexpected NETLINK_LIST_MEMBERSHIPS value");
>
> + /* Trick bpf_tcp_sock() with IPPROTO_TCP */
> + close(fd);
> + fd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
> + if (fd < 0) {
> + log_err("Failed to create RAW socket");
> + goto err;
> + }
This isn't a bug, but should this new code use the modern ASSERT_OK_FD()
macro instead of manual fd checks and log_err()?
> +
> + optlen = 20;
> + errno = 0;
> + err = setsockopt(fd, SOL_TCP, TCP_SAVED_SYN, &buf, optlen);
> + if (!err) {
> + log_err("Unexpected setsockopt(TCP_SAVED_SYN)");
> + goto err;
> + }
Could we use ASSERT_ERR() for this error check as well?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260504210610.180150-1-kuniyu@google.com?part=2
next prev parent reply other threads:[~2026-05-05 4:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 21:04 [PATCH v2 bpf 0/6] bpf: tcp: Fix type confusion in bpf helper functions Kuniyuki Iwashima
2026-05-04 21:04 ` [PATCH v2 bpf 1/6] bpf: tcp: Fix type confusion in bpf_tcp_sock() Kuniyuki Iwashima
2026-05-04 21:50 ` bot+bpf-ci
2026-05-04 21:53 ` Kuniyuki Iwashima
2026-05-05 4:14 ` sashiko-bot
2026-05-05 5:37 ` Kuniyuki Iwashima
2026-05-04 21:04 ` [PATCH v2 bpf 2/6] selftest: bpf: Add test for bpf_tcp_sock() and RAW socket Kuniyuki Iwashima
2026-05-05 4:14 ` sashiko-bot [this message]
2026-05-05 5:38 ` Kuniyuki Iwashima
2026-05-04 21:04 ` [PATCH v2 bpf 3/6] mptcp: bpf: fix type confusion in bpf_mptcp_sock_from_subflow() Kuniyuki Iwashima
2026-05-05 4:14 ` sashiko-bot
2026-05-05 5:43 ` Kuniyuki Iwashima
2026-05-05 15:14 ` Matthieu Baerts
2026-05-04 21:04 ` [PATCH v2 bpf 4/6] bpf: tcp: Fix type confusion in bpf_skc_to_tcp_sock() Kuniyuki Iwashima
2026-05-04 21:04 ` [PATCH v2 bpf 5/6] bpf: tcp: Fix type confusion in bpf_skc_to_tcp6_sock() Kuniyuki Iwashima
2026-05-04 21:04 ` [PATCH v2 bpf 6/6] bpf: tcp: Fix type confusion in sol_tcp_sockopt() Kuniyuki Iwashima
2026-05-08 19:10 ` [PATCH v2 bpf 0/6] bpf: tcp: Fix type confusion in bpf helper functions patchwork-bot+netdevbpf
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=20260505041433.8B6AEC2BCC7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kuniyu@google.com \
--cc=sashiko@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox