🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

[Bug 301062] snp(4): snp_dtor() frees the softc without draining snp_outpoll sleepers

#689
From: bugzilla-noreply
Date: Mon, 23 Nov 2026 22:09
55 lines
4006 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301062

            Bug ID: 301062
           Summary: snp(4): snp_dtor() frees the softc without draining
                    snp_outpoll sleepers
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: laamalif@proton.me

snp_dtor() frees struct snp_softc with threads still registered on
ss->snp_outpoll. A thread blocked in poll(2) on the snoop device has
its selfd linked on snp_outpoll.si_tdlist (selrecord() at
sys/dev/snp/snp.c:338); when the last file descriptor is closed,
snp_dtor() runs cv_destroy() and free(ss, M_SNP) without calling
seldrain(). When the blocked thread later returns from poll, its
selfdfree does mtx_lock(sfp->sf_mtx) and TAILQ_REMOVE on the selinfo
inside the freed softc: a use-after-free write into freed M_SNP
memory.

This is the same defect FreeBSD-SA-26:19 / CVE-2026-45251 fixed in
procdesc, jaildesc, and netmap, and the same seldrain() call that
tty.c, tty_pts.c, kern_jaildesc.c, sys_timerfd.c, sys_eventfd.c,
vfs_inotify.c, uipc_mqueue.c, and kqueue_destroy all perform before
freeing the structure holding their selinfo. snp is the one site the
advisory series missed: the destruction path has no drain.

The device is 0600 root:wheel (make_dev() at snp.c:354), so both the
closer and the poller hold descriptors opened by root; the exposure
is root-configured snoop sessions, not an unprivileged path. The bug
is the use-after-free itself, matching the SA-26:19 primitive.

The attached patch adds the missing call:

cv_destroy(&ss->snp_outwait);
seldrain(&ss->snp_outpoll);
free(ss, M_SNP);

I have not built or booted a kernel with the patch; the one-line
seldrain() placement mirrors the other SA-26:19 sites exactly.

-- 
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-301062-227@https.bugs.freebsd.org/bugzilla/>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: bugzilla-noreply@freebsd.org
Newsgroups: muc.lists.freebsd.bugs
Subject: [Bug 301062] snp(4): snp_dtor() frees the softc without draining
 snp_outpoll sleepers
Date: Mon, 23 Nov 2026 22:09:55 +0000
Organization: Newsgate at muc.de e.V.
Approved: news-admin@muc.de
Distribution: world
Message-ID: <bug-301062-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="38192"; 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=1795471794;
	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=JzuljVQHJz9leh9AZQMSYIioGf3G2lO2e8Znpub9GA8=;
	b=bqO2uHV9x9HbfkfNK264vh80hWtt26lgjBOFZuKKUAumCX5KYwuiFQnFRD1tIP6l70g3n2
	YXx+k7dl7OD3s0YcaX4A51TT3J6VN8ui6iDEymnN//MRsT2ZEzCo/SrNaWIV8Y0ns0uXwi
	rRKON9pMmVoVm0q3rdy/ns8Tp4D5cAVyjB1yzB2FBmxRicb6JyrI7qZ2oNI4IKlm5acuDT
	CPRJ08DJEndk8DnFF+ETLNIlqqWpnL2p65G8GEsQemoS4KLlMC66ZdmEITwTM02pfmUxT/
	TB8k0RMxu3TdaOMJE2ZZnxQ/7UyaREGtxo9Z5qb0n6MX4nAysv9pPUE8/hma7Q==
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