From: Jianlin Shi <shijianlin11@foxmail.com>
To: kuba@kernel.org, netdev@vger.kernel.org, virtualization@lists.linux.dev
Cc: mst@redhat.com, jasowangio@gmail.com, eperezma@redhat.com,
xuanzhuo@linux.alibaba.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
talgi@nvidia.com, hengqi@linux.alibaba.com, horms@kernel.org
Subject: Re: [PATCH 1/2] dim: clear irq_moder on init failure
Date: Thu, 8 Oct 2026 23:42:27 +0800 [thread overview]
Message-ID: <20261008154227.10902-1-shijianlin11@foxmail.com> (raw)
In-Reply-To: <20261005185335.2f8e8b42@kernel.org>
You're right - there is no such sequence on current mainline.
net_dim_init_irq_moder() has a single in-tree caller (virtio-net). If it
fails, virtnet_probe() still does "goto free", which only ends in
free_netdev(). Nothing calls net_dim_free_irq_moder() on that path, so
the stale dev->irq_moder value is never dereferenced; it disappears when
the net_device is freed.
The dereference becomes reachable with the unwind change in patch 2:
virtnet_init_irq_moder()
-> net_dim_init_irq_moder() /* fails after kfree(moder); irq_moder stale */
goto free_irq_moder; /* patch 2 */
virtnet_free_irq_moder()
net_dim_free_irq_moder()
/* non-NULL irq_moder => */
rtnl_dereference(dev->irq_moder->rx_profile) /* UAF */
kfree(dev->irq_moder) /* freed again */
So patch 1 is not fixing a reachable bug on today's tree by itself; it is
a hard prerequisite for patch 2. Without patch 1, patch 2 would trade the
virtqueue leak for UAF (and a second kfree of moder) on this error path.
I can add this call chain to the patch 1 commit message in v2 if you prefer.
Jianlin
next prev parent reply other threads:[~2026-10-08 15:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 8:19 [PATCH 0/2] virtio-net/dim: fix irq moderation init failure unwind Jianlin Shi
2026-09-30 8:19 ` [PATCH 1/2] dim: clear irq_moder on init failure Jianlin Shi
2026-10-06 1:53 ` Jakub Kicinski
2026-10-08 15:42 ` Jianlin Shi [this message]
2026-09-30 8:19 ` [PATCH 2/2] virtio-net: unwind VQs when irq moderation init fails Jianlin Shi
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=20261008154227.10902-1-shijianlin11@foxmail.com \
--to=shijianlin11@foxmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=hengqi@linux.alibaba.com \
--cc=horms@kernel.org \
--cc=jasowangio@gmail.com \
--cc=kuba@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=talgi@nvidia.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox