From: Deepanshu Kartikey <kartikey406@gmail.com>
To: brauner@kernel.org, viro@zeniv.linux.org.uk, neil@brown.name,
amir73il@gmail.com, jlayton@kernel.org
Cc: linux-kernel@vger.kernel.org,
Deepanshu Kartikey <kartikey406@gmail.com>,
syzbot+b74150fd2ef40e716ca2@syzkaller.appspot.com
Subject: [PATCH] ipc/mqueue: fix dentry refcount imbalance in prepare_open()
Date: Sun, 30 Nov 2025 14:57:31 +0530 [thread overview]
Message-ID: <20251130092731.726288-1-kartikey406@gmail.com> (raw)
When opening an existing message queue, prepare_open() does not increment
the dentry refcount, but end_creating() always calls dput(). This causes
a refcount imbalance that triggers a WARN_ON_ONCE in fast_dput() when the
file is later closed.
The creation path via vfs_mkobj() correctly increments the refcount, but
the "already exists" path was missing the corresponding dget().
Add the missing dget() call when opening an existing queue to balance the
dput() in end_creating().
Reported-by: syzbot+b74150fd2ef40e716ca2@syzkaller.appspot.com
Closes: https://syzkaller.appspot.com/bug?extid=b74150fd2ef40e716ca2
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
ipc/mqueue.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 328bcc3ee3ad..63ff2c322549 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -883,6 +883,7 @@ static int prepare_open(struct dentry *dentry, int oflag, int ro,
if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY))
return -EINVAL;
acc = oflag2acc[oflag & O_ACCMODE];
+ dget(dentry);
return inode_permission(&nop_mnt_idmap, d_inode(dentry), acc);
}
--
2.43.0
next reply other threads:[~2025-11-30 9:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-30 9:27 Deepanshu Kartikey [this message]
2025-11-30 9:57 ` Amir Goldstein
2025-11-30 22:27 ` NeilBrown
2025-12-01 8:49 ` Amir Goldstein
2025-12-01 8:57 ` NeilBrown
2025-12-01 9:00 ` Al Viro
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=20251130092731.726288-1-kartikey406@gmail.com \
--to=kartikey406@gmail.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil@brown.name \
--cc=syzbot+b74150fd2ef40e716ca2@syzkaller.appspot.com \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®