From: Stephen Hemminger <stephen@networkplumber.org>
To: David Marchand <david.marchand@redhat.com>
Cc: dev@dpdk.org, sriram.yagnaraman@ericsson.com, jgrajcia@cisco.com,
thomas@monjalon.net
Subject: Re: [PATCH] net/memif: fix use after free on listener socket close
Date: Thu, 5 Nov 2026 09:32:52 +0100 [thread overview]
Message-ID: <20261105093252.59fcdf28@stephen-xps.local> (raw)
In-Reply-To: <20261104164153.1674329-1-david.marchand@redhat.com>
On Wed, 4 Nov 2026 17:41:53 +0100
David Marchand <david.marchand@redhat.com> wrote:
> memif_socket_remove_device() calls rte_intr_callback_unregister() on
> the listener socket interrupt handle. If memif_listener_handler() is
> active at that point, the unregister returns -EAGAIN and the code
> proceeds to close and free the handle while the handler is still
> running.
>
> Use rte_intr_callback_unregister_sync() which retries until the
> handler completes.
>
> Fixes: 7281511c2cfa ("net/memif: fix some interrupt FD leaks")
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
Manually run AI review likes the patch but sees related pre-existing problem
Subject: Re: [PATCH] net/memif: fix use after free on listener socket close
On Wed, 4 Nov 2026 17:41:53 +0100
David Marchand <david.marchand@redhat.com> wrote:
> memif_socket_remove_device() calls rte_intr_callback_unregister() on
> the listener socket interrupt handle. If memif_listener_handler() is
> active at that point, the unregister returns -EAGAIN and the code
> proceeds to close and free the handle while the handler is still
> running.
The fix is correct. memif_socket_remove_device() is only reached from
memif_dev_close() in the primary, never from an interrupt callback,
so the _sync variant cannot spin on its own callback.
Info:
The same pattern is left in memif_socket_create_or_reuse(), on the
rte_hash_add_key_data() failure path. The listener callback was just
registered, so a client connecting in that window hits the same race.
Worth converting in the same patch:
if (socket->listener) {
- rte_intr_callback_unregister(socket->intr_handle,
- memif_listener_handler, socket);
+ rte_intr_callback_unregister_sync(socket->intr_handle,
+ memif_listener_handler, socket);
rte_intr_fd_close(socket->intr_handle);
Separate, pre-existing issue (not for this patch): control channels
accepted by memif_listener_handler() hold cc->socket but are not
tracked by the socket until memif_msg_receive_init() binds them to a
device. If the last device is closed while a client is between accept
and INIT, the socket is freed and the later INIT walks
cc->socket->dev_queue on freed memory. memif_socket_remove_device()
needs to disconnect pending control channels (or the socket needs a
list of them) before rte_free(socket).
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
next prev parent reply other threads:[~2026-11-05 8:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 16:41 [PATCH] net/memif: fix use after free on listener socket close David Marchand
2026-11-05 8:32 ` Stephen Hemminger [this message]
2026-11-06 14:57 ` [PATCH v2] " David Marchand
2026-11-09 22:13 ` Stephen Hemminger
2026-11-10 7:43 ` David Marchand
2026-11-10 14:36 ` Stephen Hemminger
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=20261105093252.59fcdf28@stephen-xps.local \
--to=stephen@networkplumber.org \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=jgrajcia@cisco.com \
--cc=sriram.yagnaraman@ericsson.com \
--cc=thomas@monjalon.net \
/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