From: David Gibson <david@gibson.dropbear.id.au>
To: Jon Maloy <jmaloy@redhat.com>
Cc: sbrivio@redhat.com, passt-dev@passt.top
Subject: Re: [PATCH 3/7] tap: Assert IPv6 tail size before subtracting header length
Date: Thu, 9 Jul 2026 12:13:06 +1000 [thread overview]
Message-ID: <ak8DsZheJBiDGfel@zatzit> (raw)
In-Reply-To: <20260708223203.885345-4-jmaloy@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1379 bytes --]
On Wed, Jul 08, 2026 at 06:31:59PM -0400, Jon Maloy wrote:
> In tap6_handler(), iov_tail_size(&data) - sizeof(*ip6h) is used to
> compute the expected payload length. The subtraction is safe because
> IOV_PEEK_HEADER() already verified that the tail contains at least
> sizeof(*ip6h) bytes, but add an assert to make the invariant
> explicit.
Again, I think "assumption" would be clearer. I think of "invariant"
as something that applies at every iteration of a loop, or to a data
structure at all times, rather than just to a particular variable at a
particular point
>
> Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tap.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tap.c b/tap.c
> index 6d93c7ce..d0d5148e 100644
> --- a/tap.c
> +++ b/tap.c
> @@ -986,7 +986,9 @@ resume:
> if (!ip6h)
> continue;
>
> - check = iov_tail_size(&data) - sizeof(*ip6h);
> + check = iov_tail_size(&data);
> + assert(check >= sizeof(*ip6h));
> + check -= sizeof(*ip6h);
>
> saddr = &ip6h->saddr;
> daddr = &ip6h->daddr;
> --
> 2.52.0
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-07-09 2:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 22:31 [PATCH 0/7] Fix issues and false positives in code coverge tool Jon Maloy
2026-07-08 22:31 ` [PATCH 1/7] passt: Initialise listening socket fds to -1 Jon Maloy
2026-07-09 2:09 ` David Gibson
2026-07-08 22:31 ` [PATCH 2/7] udp_vu: Assert iov_tail_clone() return before assigning to msg_iovlen Jon Maloy
2026-07-09 2:11 ` David Gibson
2026-07-08 22:31 ` [PATCH 3/7] tap: Assert IPv6 tail size before subtracting header length Jon Maloy
2026-07-09 2:13 ` David Gibson [this message]
2026-07-08 22:32 ` [PATCH 4/7] doc/migration: Use strncpy() for socket path and fix argv access Jon Maloy
2026-07-09 2:20 ` David Gibson
2026-07-08 22:32 ` [PATCH 5/7] doc/migration: Fix buffer type mismatch in recv() call Jon Maloy
2026-07-09 2:22 ` David Gibson
2026-07-08 22:32 ` [PATCH 6/7] doc/platform-requirements: Initialise va_list before va_start() Jon Maloy
2026-07-09 2:40 ` David Gibson
2026-07-08 22:32 ` [PATCH 7/7] doc/platform-requirements: Close leaked sockets in test_close_dup() Jon Maloy
2026-07-09 2:41 ` David Gibson
2026-07-09 2:09 ` [PATCH 0/7] Fix issues and false positives in code coverge tool David Gibson
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=ak8DsZheJBiDGfel@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=jmaloy@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).