qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Houqi (Nick) Zuo" <hzuo@redhat.com>, qemu-devel@nongnu.org
Cc: Jason Wang <jasowang@redhat.com>, Cindy Lu <lulu@redhat.com>,
	Michael Tsirkin <mst@redhat.com>
Subject: Re: [PATCH v4] net/tap-linux.c: avoid abort when setting invalid fd
Date: Thu, 16 Oct 2025 10:09:10 +0200	[thread overview]
Message-ID: <da5919bf-2739-4d28-b27e-ab09bdaee97b@linaro.org> (raw)
In-Reply-To: <20250925023235.1899458-1-hzuo@redhat.com>

Hi Nick,

On 25/9/25 04:32, Houqi (Nick) Zuo wrote:
> When QEMU creates a tap device automatically and the tap device is
> manually removed from the host while the guest is running, the tap
> device file descriptor becomes invalid. Later, when the guest executes
> shutdown, the tap_fd_set_vnet_hdr_len() function may be called and
> abort QEMU with a core dump when attempting to use the invalid fd.
> 
> This patch removes many abort() calls in this file. If the fd is found
> to be in a bad state (e.g., EBADFD or ENODEV), the related function
> will print an error message.
> 
> The expected behavior for this negative test case is that QEMU should
> report an error but continue running rather than aborting.


> Fixes: 0caed25cd171c611781589b5402161d27d57229c ("virtio: Call set_features during reset")
> 
> Signed-off-by: Houqi (Nick) Zuo <hzuo@redhat.com>
> ---
>   net/tap-linux.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/net/tap-linux.c b/net/tap-linux.c
> index e832810665..24e63a0b54 100644
> --- a/net/tap-linux.c
> +++ b/net/tap-linux.c
> @@ -206,15 +206,16 @@ void tap_fd_set_vnet_hdr_len(int fd, int len)
>       if (ioctl(fd, TUNSETVNETHDRSZ, &len) == -1) {
>           fprintf(stderr, "TUNSETVNETHDRSZ ioctl() failed: %s. Exiting.\n",
>                   strerror(errno));

Remove "Exiting".

While here, can you replace fprintf() -> error_report()?

> -        abort();

If we don't exit anymore, this function should return some value
indicating the failure, and the callers should check it.

>       }
>   }

Regards,

Phil.


  parent reply	other threads:[~2025-10-16  8:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25  2:32 [PATCH v4] net/tap-linux.c: avoid abort when setting invalid fd Houqi (Nick) Zuo
2025-10-09 14:09 ` Lei Yang
2025-10-16  8:09 ` Philippe Mathieu-Daudé [this message]
2025-10-16 11:02   ` Houqi Zuo

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=da5919bf-2739-4d28-b27e-ab09bdaee97b@linaro.org \
    --to=philmd@linaro.org \
    --cc=hzuo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=lulu@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).