From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: stable@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>,
Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
Narcisa Vasile <navasile@linux.microsoft.com>
Subject: Re: [PATCH] eal: fix alarm cancel list walk
Date: Fri, 4 Sep 2026 13:46:42 -0700 [thread overview]
Message-ID: <20260904134642.18a288ae@phoenix.local> (raw)
In-Reply-To: <20260904202031.2688530-1-stephen@networkplumber.org>
On Fri, 4 Sep 2026 13:20:31 -0700
Stephen Hemminger <stephen@networkplumber.org> wrote:
> All three implementations of rte_eal_alarm_cancel() free entries while
> walking the alarm list with LIST_FOREACH, which leaves the iterator
> pointing into freed memory.
>
> Linux and FreeBSD use two loops: one draining matches from the head of
> the list, then a LIST_FOREACH over the rest that frees the current
> entry and assigns the saved ap_prev to ap so iteration resumes from the
> predecessor. ap_prev is only refreshed to a live entry by an iteration
> that does not remove, and the head loop leaves it NULL when it empties
> the list. A removal in the second loop then sets ap to NULL or to an
> already freed entry, and the LIST_FOREACH increment dereferences it.
> GCC -fanalyzer reports the freed case:
>
> lib/eal/linux/eal_alarm.c:224:44: warning: use after 'free' of 'ap'
> [CWE-416] [-Wanalyzer-use-after-free]
>
> Windows has no such dance: it calls alarm_remove_unsafe() straight from
> the loop body, so the increment reads freed memory on every removal but
> the last.
>
> Replace all of these with LIST_FOREACH_SAFE. FreeBSD sys/queue.h and
> the bundled Windows sys/queue.h already provide it; glibc does not, so
> define it locally as is already done in several drivers.
>
> Fixes: af75078fece3 ("first public release")
> Fixes: f4cbdbc7fbd2 ("eal/windows: implement alarm API")
> Cc: stable@dpdk.org
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
The windows bug is real, the other platforms it is not a bug but just
Gcc getting confused. Will split and resend
prev parent reply other threads:[~2026-09-04 20:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 20:20 [PATCH] eal: fix alarm cancel list walk Stephen Hemminger
2026-09-04 20:46 ` Stephen Hemminger [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=20260904134642.18a288ae@phoenix.local \
--to=stephen@networkplumber.org \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=navasile@linux.microsoft.com \
--cc=stable@dpdk.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.