public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Aditya Merchant <adityamerchant08@gmail.com>, passt-dev@passt.top
Cc: Stefano Brivio <sbrivio@redhat.com>,
	David Gibson <david@gibson.dropbear.id.au>,
	Paul Holzinger <pholzing@redhat.com>
Subject: Re: [PATCH v2 2/2] pasta: Terminate inotify buffer, skip nameless events in netns watch
Date: Tue, 17 Nov 2026 14:15:58 +0100	[thread overview]
Message-ID: <6a060132-fb18-44f4-a97d-b549fe966e05@redhat.com> (raw)
In-Reply-To: <20261113112114.38764-3-adityamerchant08@gmail.com>

On 11/13/26 12:21, Aditya Merchant wrote:
> In pasta_netns_quit_inotify_handler(), we compare the name of each event
> we read with the base name of the namespace, but we don't make sure that
> the buffer we read events into is zero-terminated. Events without a name,
> such as the IN_IGNORED we get once the watch is removed, also have no
> name to compare: for those, ev->name points past the end of the event.
> 
> Terminate the buffer, as wait_for_socket() in passt-repair does, and
> skip events without a name.
> 
> Suggested-by: Stefano Brivio <sbrivio@redhat.com>
> Signed-off-by: Aditya Merchant <adityamerchant08@gmail.com>

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

> ---
>   pasta.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/pasta.c b/pasta.c
> index 4cd58fd..5ef678d 100644
> --- a/pasta.c
> +++ b/pasta.c
> @@ -537,10 +537,13 @@ void pasta_netns_quit_inotify_handler(const struct ctx *c, int inotify_fd)
>   	if ((n = read(inotify_fd, buf, sizeof(buf))) < (ssize_t)sizeof(*ev))
>   		return;
>   
> +	/* cppcheck-suppress [negativeIndex, unmatchedSuppression] */
> +	buf[n - 1] = '\0';
>   	for (p = buf; p < buf + n; p += sizeof(*ev) + ev->len) {
>   		ev = (const struct inotify_event *)p;
>   
> -		if (!strncmp(ev->name, c->netns_base, sizeof(c->netns_base))) {
> +		if (ev->len &&
> +		    !strncmp(ev->name, c->netns_base, sizeof(c->netns_base))) {
>   			info("Namespace %s is gone, exiting", c->netns_base);
>   			passt_exit(EXIT_SUCCESS);
>   		}


      reply	other threads:[~2026-11-17 13:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 11:21 [PATCH v2 0/2] Follow changes to the host nameserver for DNS forwarding Aditya Merchant
2026-11-13 11:21 ` [PATCH v2 1/2] conf: Follow changes to the host nameserver used " Aditya Merchant
2026-11-17 16:35   ` Laurent Vivier
2026-11-13 11:21 ` [PATCH v2 2/2] pasta: Terminate inotify buffer, skip nameless events in netns watch Aditya Merchant
2026-11-17 13:15   ` Laurent Vivier [this message]

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=6a060132-fb18-44f4-a97d-b549fe966e05@redhat.com \
    --to=lvivier@redhat.com \
    --cc=adityamerchant08@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=pholzing@redhat.com \
    --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).