🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.bugs
Article #71

[Bug 299325] LinuxKPI 802.11: linuxkpi_ieee80211_rx() leaks a node reference on its error paths

#71
From: bugzilla-noreply
Date: Mon, 12 Oct 2026 04:05
72 lines
4916 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299325

            Bug ID: 299325
           Summary: LinuxKPI 802.11: linuxkpi_ieee80211_rx() leaks a node
                    reference on its error paths
           Product: Base System
           Version: CURRENT
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: fbsdbugs@westryn.net

Created attachment 275615
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=275615&action=edit
release node reference on error

While working on AP mode for ath10k on top of LinuxKPI I was reading through
linuxkpi_ieee80211_rx() and noticed that the node reference it takes is never
dropped if the frame doesn't make it onto the deferred RX queue.

The function gets a referenced node early on, either from the driver's sta
(ieee80211_ref_node(lsta->ni), line 8417 in main) or from
ieee80211_find_rxnode() (line 8422).  On success that reference rides along
with the mbuf and lkpi_80211_lhw_rxq_rx_one() releases it after input.  But
there are four ways out after the reference is taken that jump to err: and
free the mbuf without releasing it:

  - line 8434: ieee80211_add_rx_params() fails
  - line 8530: m_tag_alloc() fails (LKPI_80211_USE_MTAG only)
  - line 8545: the rx queue is already stopped
  - line 8558: mbufq_enqueue() fails because the queue is full

err: only frees the skb, so each of these leaks the node, and with it the
driver's lsta.

I found this by reading the code, not by hitting it.  All four paths are
uncommon (allocation failure, a full 2048-frame queue, or frames arriving while
the hardware is being stopped), so I'd expect it to show up, if ever, as a node
that never goes away after a stop or under heavy load rather than anything
dramatic.

## Fix

The attached patch initializes ni to NULL, clears it once the frame has been
queued (the queue owns the reference from then on), and releases it at err:
if it's still set.  It doesn't touch the success path.

While I was there I also changed the debug message on the enqueue-failure
path.  Under D80211_TRACE_RX it's printed with ic_printf(ni->ni_ic, ...), but
ni is NULL for any frame from an unknown sender, so it uses the local ic
instead.

I've built and booted a kernel with this applied, but I haven't been able to
exercise the error paths themselves.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <bug-299325-227@https.bugs.freebsd.org/bugzilla/>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer04.iad!feed-me.highwinds-media.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder2.feed.ams11.usenet.farm!feeder4.usenet.farm!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer04.iad!feed-me.highwinds-media.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder2.feed.ams11.usenet.farm!feeder4.usenet.farm!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: bugzilla-noreply@freebsd.org
Newsgroups: muc.lists.freebsd.bugs
Subject: [Bug 299325] LinuxKPI 802.11: linuxkpi_ieee80211_rx() leaks a node
 reference on its error paths
Date: Mon, 12 Oct 2026 04:05:37 +0000
Organization: Newsgate at muc.de e.V.
Sender: owner-freebsd-bugs@FreeBSD.org
Approved: news-admin@muc.de
Distribution: world
Message-ID: <bug-299325-227@https.bugs.freebsd.org/bugzilla/>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="61503"; mail-complaints-to="news-admin@muc.de"
X-Original-To: bugs@mlmmj.nyi.freebsd.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1791777942;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding;
	bh=wBY12uhPUcTP/DxForpyT/U8iwO2ZL5z0LfifZ1nZOI=;
	b=c3WAALsuRua6Uyg+6T284hnma+B3S/QwtL/UIh7Wxu81Ns1mIDXiMDHkrnuMDAFpUqiP1i
	txx8E/cudle0koQZXWwhqw6+Hc1WawALh8JcwUH1gVpj9OnBwUUQIaXoRQqULgbsu+bInD
	bsL7bZtdHWbMBiSAyjCoRpi2RGkV0+n41e4kOoiTy73ONWeZC3LqHIEiwnmE6F1ahffu98
	JAn6HRf9Rp+hf83h5uTwfsXuCLSXbHoB2JV75esqyvIM3HEmiUW/yAy+qF2xsDEpGI0zNm
	lR9ydcbyo+ChXRnh94oUwAstb2r1YQUWce2UKmZW7Ny7fIqZE05pStYUQEGFEw==
X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f
Auto-Submitted: auto-generated
Precedence: list
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes
X-Received-Bytes: 4707