From: Paolo Abeni <pabeni@redhat.com>
To: Norbert Szetei <norbert@doyensec.com>, netdev@vger.kernel.org
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
linux-ppp@vger.kernel.org, linux-kernel@vger.kernel.org,
Qingfang Deng <qingfang.deng@linux.dev>
Subject: Re: [PATCH net] ppp: fix use-after-free reads in the stats ioctls.
Date: Tue, 30 Jun 2026 15:06:05 +0200 [thread overview]
Message-ID: <f81d25c6-4b14-4e48-a230-2d41a036a065@redhat.com> (raw)
In-Reply-To: <CF6F0CC7-C448-406B-8E24-2025AD585D18@doyensec.com>
Adding Qingfang.
On 6/28/26 2:44 PM, Norbert Szetei wrote:
> ppp_get_stats() (SIOCGPPPSTATS) and the SIOCGPPPCSTATS handler, both
> reached from ppp_net_siocdevprivate(), dereference state that other
> ioctls free under the ppp lock, without taking it:
>
> - ppp_get_stats() reads ppp->vj; PPPIOCSMAXCID frees it with
> slhc_free() under ppp_lock().
> - SIOCGPPPCSTATS calls ->comp_stat()/->decomp_stat() on
> ppp->xc_state / ppp->rc_state; PPPIOCSCOMPRESS and ppp_ccp_closed()
> free those.
>
> A concurrent stats ioctl can then read freed memory (slab-use-after-
> free), and the freed contents are copied back to userspace. This is
> reachable by a local user who has CAP_NET_ADMIN privileges and
> read/write access to /dev/ppp.
>
> Take the lock the freeing path holds around each access: the receive
> lock in ppp_get_stats() (PPPIOCSMAXCID frees ppp->vj under ppp_lock(),
> which includes it) and ppp_lock() around the SIOCGPPPCSTATS callbacks.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Norbert Szetei <norbert@doyensec.com>
> ---
> drivers/net/ppp/ppp_generic.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
> index 57c68efa5ff8..847c5e1793c8 100644
> --- a/drivers/net/ppp/ppp_generic.c
> +++ b/drivers/net/ppp/ppp_generic.c
> @@ -1505,10 +1505,13 @@ ppp_net_siocdevprivate(struct net_device *dev, struct ifreq *ifr,
>
> case SIOCGPPPCSTATS:
> memset(&cstats, 0, sizeof(cstats));
> + /* protect against PPPIOCSCOMPRESS/ppp_ccp_closed() freeing the state */
> + ppp_lock(ppp);
> if (ppp->xc_state)
> ppp->xcomp->comp_stat(ppp->xc_state, &cstats.c);
> if (ppp->rc_state)
> ppp->rcomp->decomp_stat(ppp->rc_state, &cstats.d);
> + ppp_unlock(ppp);
It looks like that this fix addresses the reported races, but I don't
like stats blocking the TX and RX path. Perhaps you should consider
switching to proper RCU for the relevant structs, and likely 2 separate
patches, one for xc_state/rc_state and the other for vj.
/P
prev parent reply other threads:[~2026-06-30 13:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 12:44 [PATCH net] ppp: fix use-after-free reads in the stats ioctls Norbert Szetei
2026-06-30 13:06 ` Paolo Abeni [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=f81d25c6-4b14-4e48-a230-2d41a036a065@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ppp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=norbert@doyensec.com \
--cc=qingfang.deng@linux.dev \
/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