From: Mahe Tardy <mahe.tardy@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v7 5/7] selftests/bpf: add bpf_icmp_send kfunc cgroup_skb IPv6 tests
Date: Wed, 27 May 2026 00:07:47 +0200 [thread overview]
Message-ID: <ahYZs1DJfnWHtiG6@gmail.com> (raw)
In-Reply-To: <20260526193248.B92CC1F000E9@smtp.kernel.org>
On Tue, May 26, 2026 at 07:32:48PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Type confusion and address truncation in getsockname() due to using struct sockaddr_in for IPv6 addresses.
> --
>
> commit 0cc9d08ecac1ed3d21b7e5cbf50d68e27cb610de
> Author: Mahe Tardy <mahe.tardy@gmail.com>
>
> selftests/bpf: add bpf_icmp_send kfunc cgroup_skb IPv6 tests
>
> This test extends the existing cgroup_skb tests for the bpf_icmp_send
> kfunc by adding IPv6 support.
>
> > diff --git a/tools/testing/selftests/bpf/prog_tests/icmp_send_kfunc.c b/tools/testing/selftests/bpf/prog_tests/icmp_send_kfunc.c
> > index 0dc6b6ceafb4a..1d6900d6a8f8c 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/icmp_send_kfunc.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/icmp_send_kfunc.c
>
> [ ... ]
>
> > @@ -79,14 +94,15 @@ static void read_icmp_errqueue(int sockfd, int expected_code)
> > ASSERT_FAIL("no IP_RECVERR/IPV6_RECVERR control message found");
> > }
> >
> > -static void trigger_prog_read_icmp_errqueue(struct icmp_send *skel, int code)
> > +static void trigger_prog_read_icmp_errqueue(struct icmp_send *skel, int code,
> > + int af, const char *ip)
> > {
> > int srv_fd = -1, client_fd = -1;
> > struct sockaddr_in addr;
> > socklen_t len = sizeof(addr);
> >
> > - srv_fd = start_server(AF_INET, SOCK_STREAM, "127.0.0.1", 0, TIMEOUT_MS);
> > - if (!ASSERT_GE(srv_fd, 0, "start_server"))
> > + srv_fd = start_server(af, SOCK_STREAM, ip, 0, TIMEOUT_MS);
> > + if (!ASSERT_OK_FD(srv_fd, "start_server"))
> > return;
> >
> > if (getsockname(srv_fd, (struct sockaddr *)&addr, &len)) {
> > @@ -94,6 +110,8 @@ static void trigger_prog_read_icmp_errqueue(struct icmp_send *skel, int code)
> > return;
> > }
> > skel->bss->server_port = ntohs(addr.sin_port);
>
> [Severity: Medium]
> When af is AF_INET6, does this cause an address truncation in getsockname()
> since addr is defined as struct sockaddr_in?
>
> For an IPv6 socket, getsockname() requires struct sockaddr_in6 which is
> larger than struct sockaddr_in. While reading addr.sin_port happens to map
> to the same memory offset as sin6_port, could this lead to type confusion
> if the address fields are ever used?
>
> Would it be safer to use struct sockaddr_storage here to ensure enough space
> for either address family, similar to what is used in connect_to_fd_nonblock()?
I already replied many times to this point, I don't think that's a
problem here.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260526153708.279717-1-mahe.tardy@gmail.com?part=5
next prev parent reply other threads:[~2026-05-26 22:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 15:37 [PATCH bpf-next v7 0/7] bpf: add icmp_send kfunc Mahe Tardy
2026-05-26 15:37 ` [PATCH bpf-next v7 1/7] net: move netfilter nf_reject_fill_skb_dst to core ipv4 Mahe Tardy
2026-05-26 16:20 ` bot+bpf-ci
2026-05-28 22:54 ` Jordan Rife
2026-05-26 15:37 ` [PATCH bpf-next v7 2/7] net: move netfilter nf_reject6_fill_skb_dst to core ipv6 Mahe Tardy
2026-05-26 16:20 ` bot+bpf-ci
2026-05-26 22:02 ` Mahe Tardy
2026-05-28 22:55 ` Jordan Rife
2026-05-26 15:37 ` [PATCH bpf-next v7 3/7] bpf: add bpf_icmp_send kfunc Mahe Tardy
2026-05-28 22:55 ` Jordan Rife
2026-05-29 9:02 ` Mahe Tardy
2026-05-29 16:33 ` Jordan Rife
2026-05-29 16:38 ` Jordan Rife
2026-05-26 15:37 ` [PATCH bpf-next v7 4/7] selftests/bpf: add bpf_icmp_send kfunc cgroup_skb tests Mahe Tardy
2026-05-26 16:20 ` bot+bpf-ci
2026-05-26 22:05 ` Mahe Tardy
2026-05-26 19:24 ` sashiko-bot
2026-05-26 22:06 ` Mahe Tardy
2026-05-29 16:38 ` Jordan Rife
2026-05-26 15:37 ` [PATCH bpf-next v7 5/7] selftests/bpf: add bpf_icmp_send kfunc cgroup_skb IPv6 tests Mahe Tardy
2026-05-26 19:32 ` sashiko-bot
2026-05-26 22:07 ` Mahe Tardy [this message]
2026-05-26 15:37 ` [PATCH bpf-next v7 6/7] selftests/bpf: add bpf_icmp_send kfunc tc tests Mahe Tardy
2026-05-26 15:37 ` [PATCH bpf-next v7 7/7] selftests/bpf: add bpf_icmp_send recursion test Mahe Tardy
2026-05-26 20:22 ` sashiko-bot
2026-05-26 22:10 ` Mahe Tardy
2026-05-28 22:55 ` Jordan Rife
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=ahYZs1DJfnWHtiG6@gmail.com \
--to=mahe.tardy@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@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 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.