From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>, Eduard <eddyz87@gmail.com>,
bpf <bpf@vger.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Mykola Lysenko <mykolal@fb.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH v2] selftests/bpf: Validate UDP length in cls_redirect test
Date: Fri, 6 Jun 2025 11:33:41 -0700 [thread overview]
Message-ID: <CAADnVQLUpRqP73gJ4+PM57jofFp-jPU_xj4eKwMT6mpeKxMu0Q@mail.gmail.com> (raw)
In-Reply-To: <20250603052805.13042-1-suchitkarunakaran@gmail.com>
On Mon, Jun 2, 2025 at 10:28 PM Suchit Karunakaran
<suchitkarunakaran@gmail.com> wrote:
>
> From: Suchit <suchitkarunakaran@gmail.com>
>
> Add validation step to ensure that the UDP payload is
> long enough to contain the expected GUE and UNIGUE encapsulation
> headers
>
> Signed-off-by: Suchit <suchitkarunakaran@gmail.com>
> ---
>
> Changes since v2:
> - Rebase
>
> tools/testing/selftests/bpf/progs/test_cls_redirect.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_cls_redirect.c b/tools/testing/selftests/bpf/progs/test_cls_redirect.c
> index f344c6835e84..c1d2eaee2e77 100644
> --- a/tools/testing/selftests/bpf/progs/test_cls_redirect.c
> +++ b/tools/testing/selftests/bpf/progs/test_cls_redirect.c
> @@ -978,7 +978,14 @@ int cls_redirect(struct __sk_buff *skb)
> return TC_ACT_OK;
> }
>
> - /* TODO Check UDP length? */
> + uint16_t udp_len = bpf_ntohs(encap->udp.len);
> + uint16_t min_encap_len = sizeof(encap->udp) + sizeof(encap->gue) + sizeof(encap->unigue);
> +
> + if (udp_len < min_encap_len) {
> + metrics->errors_total_malformed_encapsulation++;
> + return TC_ACT_SHOT;
> + }
I don't quite see the point.
This is a test prog. It's not supposed to be used as production code.
next prev parent reply other threads:[~2025-06-06 18:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 5:28 [PATCH v2] selftests/bpf: Validate UDP length in cls_redirect test Suchit Karunakaran
2025-06-06 18:33 ` Alexei Starovoitov [this message]
2025-06-07 15:54 ` Suchit K
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=CAADnVQLUpRqP73gJ4+PM57jofFp-jPU_xj4eKwMT6mpeKxMu0Q@mail.gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=suchitkarunakaran@gmail.com \
--cc=yonghong.song@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;
as well as URLs for NNTP newsgroup(s).