Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,stable@vger.kernel.org,
	manfred@colorfullife.com,dave@stgolabs.net,akpm@linux-foundation.org,
	songhh06101@gmail.com
Subject: [merged mm-nonmm-hotfixes-stable] ipc-msg-keep-expelled-receivers-from-taking-new-messages.patch removed from -mm tree
Date: Tue, 01 Dec 2026 19:50:58 -0800	[thread overview]
Message-ID: <20261202035058.71EB31F000C1@smtp.kernel.org> (raw)


The quilt patch titled
     Subject: ipc/msg: keep expelled receivers from taking new messages
has been removed from the -mm tree.  Its filename was
     ipc-msg-keep-expelled-receivers-from-taking-new-messages.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: keep expelled receivers from taking new messages
Date: Wed, 18 Nov 2026 12:28:21 +0900

Patch series "ipc/msg: prevent reads after queue permission revocation".

A process whose read access to a SysV message queue was revoked by IPC_SET
can receive a message sent afterward.  A blocked receiver needs no
capability and can have a different UID from the queue owner.  Patch 1
prevents delivery to a receiver awakened by IPC_SET.  Patch 2 closes the
window between the read permission check and waiter insertion.

IPC_SET wakes all blocked receivers, including those whose read access is
unchanged.  Each leaves q_receivers when it runs; a receiver that must
wait again rejoins at the tail, so IPC_SET can change their FIFO order. 
Until they run, a sender queues a message instead of handing it to one of
them.  An authorized receiver may then take it from the queue.

Waking only receivers whose access was revoked is not a small change. 
IPC_SET runs in the setter's context, but ipcperms() checks current's
credentials and invokes the security hook.  Deciding which waiters lost
access would need a way to check each receiver's credentials and security
policy, with appropriate audit behavior.  Leave that separate from this
fix; IPC_SET is infrequent, and the existing wake-all behavior remains.

This patch (of 2):

IPC_SET sets a blocked receiver's result to -EAGAIN so it retries its read
permission check.  expunge_all() leaves the receiver on q_receivers; a
sender can hand it a new message before it wakes.  If IPC_SET revoked its
read access, it receives data that was sent after the revocation.

Mark every receiver that expunge_all() touched and skip it in
pipelined_send().  Keep it linked until it wakes so IPC_RMID can still
find it and change its result to -EIDRM.  The sender queues the message
instead.  On retry, a receiver with read access can take it from the
queue; a receiver whose read access was revoked gets -EACCES.

Signed-off-by: Hyunho Song <songhh06101@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Hyunho Song <songhh06101@gmail.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, 7 insertions(+)

--- a/ipc/msg.c~ipc-msg-keep-expelled-receivers-from-taking-new-messages
+++ a/ipc/msg.c
@@ -82,6 +82,7 @@ struct msg_receiver {
 	long			r_maxsize;
 
 	struct msg_msg		*r_msg;
+	bool			r_expunge;
 };
 
 /* one msg_sender for each sleeping sender */
@@ -255,6 +256,8 @@ static void expunge_all(struct msg_queue
 		struct task_struct *r_tsk;
 
 		r_tsk = get_task_struct(msr->r_tsk);
+		/* IPC_RMID must still find this waiter and set -EIDRM. */
+		msr->r_expunge = true;
 
 		/* see MSG_BARRIER for purpose/pairing */
 		smp_store_release(&msr->r_msg, ERR_PTR(res));
@@ -819,6 +822,9 @@ static inline int pipelined_send(struct
 	struct msg_receiver *msr, *t;
 
 	list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) {
+		/* IPC_SET needs the receiver to recheck its access. */
+		if (msr->r_expunge)
+			continue;
 		if (testmsg(msg, msr->r_msgtype, msr->r_mode) &&
 		    !security_msg_queue_msgrcv(&msq->q_perm, msg, msr->r_tsk,
 					       msr->r_msgtype, msr->r_mode)) {
@@ -1178,6 +1184,7 @@ static long do_msgrcv(int msqid, void __
 			goto out_unlock0;
 		}
 
+		msr_d.r_expunge = false;
 		list_add_tail(&msr_d.r_list, &msq->q_receivers);
 		msr_d.r_tsk = current;
 		msr_d.r_msgtype = msgtyp;
_

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



                 reply	other threads:[~2026-12-02  3:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261202035058.71EB31F000C1@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=manfred@colorfullife.com \
    --cc=mm-commits@vger.kernel.org \
    --cc=songhh06101@gmail.com \
    --cc=stable@vger.kernel.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