Yesterday a user reported a panic in fusefs, bug 289686 . From inspection, it appears that unionfs is vulnerable to the same panic. The steps to reproduce the panic would be: * A process opens a regular file on a unionfs file system * That process sends the file descriptor through a unix domain socket, using SCM_RIGHTS * That process closes the original file descriptor * Whatever process (which might be the same one) that owns the receiving side of the unix domain socket closes it, without reading the file descriptor out first. * That will cause unp_dispose to attempt to close every file descriptor residing in the socket's receive buffer. * Several frames down the stack, that will call VOP_CLOSE with ap->a_td == NULL * unionfs_close will pass ap->a_td to unionfs_find_node_status, without checking it. * unionfs_find_node_status will attempt to dereference it, without checking it either. Note that I haven't attempted to trigger the panic myself.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=880d180bb21c764aec6bd5bc8c0a6b07b8c2e199 commit 880d180bb21c764aec6bd5bc8c0a6b07b8c2e199 Author: Jason A. Harmening <jah@FreeBSD.org> AuthorDate: 2025-10-13 20:40:46 +0000 Commit: Jason A. Harmening <jah@FreeBSD.org> 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(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8a873a86059f13c829315b7867e188d27e314b51 commit 8a873a86059f13c829315b7867e188d27e314b51 Author: Jason A. Harmening <jah@FreeBSD.org> AuthorDate: 2025-10-13 20:40:46 +0000 Commit: Jason A. Harmening <jah@FreeBSD.org> CommitDate: 2025-11-03 04:32:50 +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 Differential Revision: https://reviews.freebsd.org/D53079 (cherry picked from commit 880d180bb21c764aec6bd5bc8c0a6b07b8c2e199) sys/fs/unionfs/union_subr.c | 2 ++ sys/fs/unionfs/union_vnops.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
^Triage: set mfc-stable14? flag. Please just close if no MFC planned.