public inbox for astral-devel@lists.astral-os.org
 help / color / mirror / Atom feed
From: Matheus <matheus@astral-os.org>
To: astral-devel@lists.astral-os.org
Subject: [PATCH 2/5] vfs: fix UAF on VOP_RELEASE
Date: Mon,  5 Oct 2026 15:01:49 -0300	[thread overview]
Message-ID: <20261005180152.53359-3-matheus@astral-os.org> (raw)
In-Reply-To: <20261005180152.53359-1-matheus@astral-os.org>

From: Matheus <matheusuky@gmail.com>

---
 kernel-src/include/kernel/vfs.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel-src/include/kernel/vfs.h b/kernel-src/include/kernel/vfs.h
index cbb16098..04661cbd 100644
--- a/kernel-src/include/kernel/vfs.h
+++ b/kernel-src/include/kernel/vfs.h
@@ -242,12 +242,13 @@ typedef struct vops_t {
 #define VOP_SYNC(v) (v)->ops->sync(v)
 #define VOP_ADVLOCK(v, o, a) (v)->ops->advlock(v, o, a)
 #define VOP_HOLD(v) __atomic_add_fetch(&(v)->refcount, 1, __ATOMIC_SEQ_CST)
-#define VOP_RELEASE(v) {\
-		if (__atomic_sub_fetch(&(v)->refcount, 1, __ATOMIC_SEQ_CST) == 0) {\
-			vfs_inactive(v); \
+#define VOP_RELEASE(v) do { \
+		vnode_t *vop_release_node = (v); \
+		if (__atomic_sub_fetch(&vop_release_node->refcount, 1, __ATOMIC_SEQ_CST) == 0) { \
 			(v) = NULL; \
+			vfs_inactive(vop_release_node); \
 		} \
-	}
+	} while (0)
 
 #define VFS_STUB(x) static int x () { return ENODEV; }
 
-- 
2.43.0


  parent reply	other threads:[~2026-10-05 18:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 18:01 [PATCH 0/5] devfs: add anonymous register/remove Matheus
2026-10-05 18:01 ` [PATCH 1/5] statvfs: handle vnodes without a vfs Matheus
2026-10-05 18:01 ` Matheus [this message]
2026-10-05 18:01 ` [PATCH 3/5] tty: fix lifetime issue in tty_unregister() Matheus
2026-10-05 18:01 ` [PATCH 4/5] devfs: add anonymous variants to register/remove Matheus
2026-10-05 18:01 ` [PATCH 5/5] pty: use new anonymous devfs operations Matheus

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=20261005180152.53359-3-matheus@astral-os.org \
    --to=matheus@astral-os.org \
    --cc=astral-devel@lists.astral-os.org \
    /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