mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Shubhang Kaushik (Ampere)" <sh@gentwo.org>
Cc: Shuah Khan <shuah@kernel.org>, Lu Shuaibing <shuaibinglu@126.com>,
	Shubhang Kaushik <shubhang@os.amperecomputing.com>,
	"Christopher Lameter (Ampere)" <cl@gentwo.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Manfred Spraul <manfred@colorfullife.com>,
	Jan Koester <jan.koester@tuxist.de>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] ipc/msg: prevent msg_qbytes limit bypass in IPC_SET
Date: Wed, 28 Oct 2026 23:35:02 -0700	[thread overview]
Message-ID: <20261028233502.e7ab1c2ba951d2015d8a1fa9@linux-foundation.org> (raw)
In-Reply-To: <20261027-ipc-msg-qbytes-v2-1-48d8f72f1359@gentwo.org>

On Tue, 27 Oct 2026 23:42:51 -0700 "Shubhang Kaushik (Ampere)" <sh@gentwo.org> wrote:

> The msg_qbytes field in the msqid64_ds userspace ABI is an unsigned
> long. Commit 889b331724c82 ("ipc/msg.c: consolidate all xxxctl_down()
> functions") passed that value to msgctl_down() as an int.
> 
> An unprivileged owner can set msg_qbytes to UINT_MAX. The narrowing
> conversion produces -1 on supported Linux targets, so the check against
> the int-valued msg_ctlmnb sysctl does not reject the request:
> 
> 	if (msg_qbytes > ns->msg_ctlmnb &&
> 	    !capable(CAP_SYS_RESOURCE))
> 
> The value is then assigned to the unsigned long q_qbytes field, setting
> it to ULONG_MAX. This bypasses the CAP_SYS_RESOURCE requirement for
> increasing a queue above MSGMNB.
> 
> It also bypasses the effective per-queue message-count limit: zero-length
> messages consume kernel memory but not queue bytes. An unprivileged queue
> owner can therefore cause memory pressure or exhaustion beyond the
> configured per-queue allowance, subject to other resource limits.
> 
> Keep msg_qbytes as unsigned long through validation and assignment.
> Also preserve its type in ipcctl_obtain_check(), which supplies it to
> the unsigned-long audit field.
> 
> Add a regression test which drops CAP_SYS_RESOURCE and verifies that
> IPC_SET with UINT_MAX fails with EPERM. Skip the test when capabilities
> or System V message queues are unavailable.

Thanks.  Sashiko AI review asked a thing:

https://sashiko.dev/#/patchset/20261027-ipc-msg-qbytes-v2-1-48d8f72f1359@gentwo.org

      reply	other threads:[~2026-10-29  6:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  6:42 Shubhang Kaushik (Ampere)
2026-10-29  6:35 ` Andrew Morton [this message]

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=20261028233502.e7ab1c2ba951d2015d8a1fa9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=dave@stgolabs.net \
    --cc=jan.koester@tuxist.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=sh@gentwo.org \
    --cc=shuah@kernel.org \
    --cc=shuaibinglu@126.com \
    --cc=shubhang@os.amperecomputing.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

all inboxes | Powered by JetHome®