All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged mm-nonmm-hotfixes-stable] ipc-msg-serialize-receive-permission-checks-with-ipc_set.patch removed from -mm tree
@ 2026-12-02  3:50 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-12-02  3:50 UTC (permalink / raw)
  To: mm-commits, stable, manfred, dave, akpm, songhh06101


The quilt patch titled
     Subject: ipc/msg: serialize receive permission checks with IPC_SET
has been removed from the -mm tree.  Its filename was
     ipc-msg-serialize-receive-permission-checks-with-ipc_set.patch

This patch was dropped because it was merged into the mm-nonmm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Hyunho Song <songhh06101@gmail.com>
Subject: ipc/msg: serialize receive permission checks with IPC_SET
Date: Sun, 22 Nov 2026 18:37:35 -0800

do_msgrcv() checks read permission before taking the queue lock.  IPC_SET
can revoke access after that check and before the receiver joins
q_receivers.  It then misses the IPC_SET wakeup and can receive a later
message despite losing access.

Take the queue lock before the receive loop so the permission check,
message lookup and insertion into q_receivers are serialized with IPC_SET.
The receiver releases the lock before sleeping.  On an -EAGAIN wakeup it
reacquires the lock, removes itself from q_receivers, and keeps the lock
for the next permission check.  The earlier revision [1] unlocked at the
bottom of the loop only to lock again at the top.

Signed-off-by: Hyunho Song <songhh06101@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Hyunho Song <songhh06101@gmail.com>
Suggested-by: Manfred Spraul <manfred@colorfullife.com>
Reviewed-by: Manfred Spraul <manfred@colorfullife.com>
Tested-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: <stable@vger.kernel.org>

 ipc/msg.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

--- a/ipc/msg.c~ipc-msg-serialize-receive-permission-checks-with-ipc_set
+++ a/ipc/msg.c
@@ -1132,14 +1132,13 @@ static long do_msgrcv(int msqid, void __
 		return PTR_ERR(msq);
 	}
 
+	ipc_lock_object(&msq->q_perm);
 	for (;;) {
 		struct msg_receiver msr_d;
 
 		msg = ERR_PTR(-EACCES);
 		if (ipcperms(ns, &msq->q_perm, S_IRUGO))
-			goto out_unlock1;
-
-		ipc_lock_object(&msq->q_perm);
+			goto out_unlock0;
 
 		/* raced with RMID? */
 		if (!ipc_valid_object(&msq->q_perm)) {
@@ -1248,8 +1247,6 @@ static long do_msgrcv(int msqid, void __
 			msg = ERR_PTR(-ERESTARTNOHAND);
 			goto out_unlock0;
 		}
-
-		ipc_unlock_object(&msq->q_perm);
 	}
 
 out_unlock0:
_

Patches currently in -mm which might be from songhh06101@gmail.com are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-02  3:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  3:50 [merged mm-nonmm-hotfixes-stable] ipc-msg-serialize-receive-permission-checks-with-ipc_set.patch removed from -mm tree Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.