From nobody Tue Oct 14 18:49:58 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cmNYz04Fqz6Cs2L; Tue, 14 Oct 2025 18:49:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cmNYy6Qdfz4JPn; Tue, 14 Oct 2025 18:49:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760467798; 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=O0438FE3Y9WMIi3XkkoYnt8NCGwxOpRIolBglhu3+XE=; b=r0Abe+O5E0BHP40nU0FWCl11uXjNJ1S9Afp/hJcWlG9D9tv4ul5L9txj1l+RePWRw1IUPs z54+vKl+Ppn49tsgYEL6+CylEO3JwLeK9/mq7JuMV8+cd8q/8NgeNd2sJ8SikHfI3OHEp3 auqvDx8EjqG6pEj2jxfrayIIsqnpaxrf4SUNkVAtLdrfOcVPUcPN6zf+sZo1vJxA7oEvg5 FCOcd+yXS4fU9D+0BWBrYPk22hHS6h0E0q8nneeCW9lOxBLaa+FTCzr83S/eVsRVtEE68Q 9Ch7I9rA6JIWUIH6sNr3+lFxoOboQ4g2xKy+6760ejuEg1krUq0UVGRA4+qGug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760467798; 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=O0438FE3Y9WMIi3XkkoYnt8NCGwxOpRIolBglhu3+XE=; b=xZtuz4eW0anlOJdUl/YHZIJQD7TvrsPX2AiKPTSe93e2U52GyWrYZ01WvuEzwIr2DQ4TTG LwuPdD+/aWzo4O6xl+cDl52G8ONVPtbtaQwSus43NM1NLCXxgNMseEEwMorwCFoQBw6/dr t0uizJWqb1U+zJmipIHNJUOeUT4iC22vkk0hooej7rngtpU0LstZPRn6iJNFHusp0xqEau 8+EurAbVPjtY4QajsTZyO36SshoBzkERRQvsmacb0DWlAGueHyWWy76vPavXSjbidGCmIp tovv72GAC23/quq14n6K8M6jtblFEdrSOx5IGjn2XwlFjXBXYn5hzYXzL5jrRA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760467798; a=rsa-sha256; cv=none; b=G6PeBeWiyCmxPsmM80gpKw80mNLy0hzptQeDfpS4Xvzj96ihJJiqME8UKND+zCIjJnVD3p j3u9XBMzEnL3dduHOFDCJSIZctLLe4yoOibfSS2Tt5MnXz1Uc+Wj6+UIg98K8MnUKcbQI3 DugfMwE1g87MVGqnXWMMHyNbSV43ThMfljrqj4dqRHjJTqnrClhVNuwZTa4z+14mkFkkxD cvtN8FYbSPvg5XXPZIeXTk4VCkw3KHKpJZbCH8wZYLCIPHLBf+hMDIXbPiptR2gmMf3H3A 3fcWr6Ofzm3u8BSRjj1dTCFhHuExGIWLa76CqOro3QHJQ34WL7oxsvg/AJy2zQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cmNYy60Rlz149P; Tue, 14 Oct 2025 18:49:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59EInwDl039553; Tue, 14 Oct 2025 18:49:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59EInwsE039550; Tue, 14 Oct 2025 18:49:58 GMT (envelope-from git) Date: Tue, 14 Oct 2025 18:49:58 GMT Message-Id: <202510141849.59EInwsE039550@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: 880d180bb21c - main - unionfs: fix NULL deref on closing an fd passed through SCM_RIGHTS List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 880d180bb21c764aec6bd5bc8c0a6b07b8c2e199 Auto-Submitted: auto-generated The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=880d180bb21c764aec6bd5bc8c0a6b07b8c2e199 commit 880d180bb21c764aec6bd5bc8c0a6b07b8c2e199 Author: Jason A. Harmening AuthorDate: 2025-10-13 20:40:46 +0000 Commit: Jason A. Harmening CommitDate: 2025-10-14 18:48:51 +0000 unionfs: fix NULL deref on closing an fd passed through SCM_RIGHTS If the last reference to an open file is contained in an SCM_RIGHTS message in a UNIX domain socket, and that message is discarded without being read out by the receiver, VOP_CLOSE will ultimately be called with ap->a_td == NULL. Change unionfs_close() to check for this condition instead of blindly passing the thread to unionfs_find_node_status() which will try to dereference it. Also add relevant asserts on the node status lookup paths. PR: 289700 Reported by: asomers Reviewed by: asomers, olce MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53079 --- sys/fs/unionfs/union_subr.c | 2 ++ sys/fs/unionfs/union_vnops.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index a14f9ca74305..b6d6db60ca3d 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -587,6 +587,7 @@ unionfs_find_node_status(struct unionfs_node *unp, struct thread *td) struct unionfs_node_status *unsp; pid_t pid; + MPASS(td != NULL); pid = td->td_proc->p_pid; ASSERT_VOP_ELOCKED(UNIONFSTOV(unp), __func__); @@ -612,6 +613,7 @@ unionfs_get_node_status(struct unionfs_node *unp, struct thread *td, struct unionfs_node_status *unsp; pid_t pid; + MPASS(td != NULL); pid = td->td_proc->p_pid; KASSERT(NULL != unspp, ("%s: NULL status", __func__)); diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 627b2f6e9a1d..26fa14603c85 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -814,7 +814,7 @@ unionfs_close(struct vop_close_args *ap) unp = VTOUNIONFS(vp); lvp = unp->un_lowervp; uvp = unp->un_uppervp; - unsp = unionfs_find_node_status(unp, td); + unsp = (td != NULL) ? unionfs_find_node_status(unp, td) : NULL; if (unsp == NULL || (unsp->uns_lower_opencnt <= 0 && unsp->uns_upper_opencnt <= 0)) {