From: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: manfred@colorfullife.com, viro@zeniv.linux.org.uk,
brauner@kernel.org, chuck.lever@oracle.com, jlayton@kernel.org,
rstoyanov@fedoraproject.org, ptikhomirov@virtuozzo.com,
Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
Subject: [RFC PATCH 2/3] msg: move struct msg_msgseg and DATALEN_* to include/linux/msg.h
Date: Thu, 26 Mar 2026 00:30:24 +0530 [thread overview]
Message-ID: <20260325190025.40312-3-ssrane_b23@ee.vjti.ac.in> (raw)
In-Reply-To: <20260325190025.40312-1-ssrane_b23@ee.vjti.ac.in>
struct msg_msgseg and the DATALEN_MSG / DATALEN_SEG macros are
currently private to ipc/msgutil.c. struct msg_msg (already in the
public kernel header include/linux/msg.h) carries a pointer to
msg_msgseg, making it an incomplete type for all callers outside
msgutil.c.
Move the definition of struct msg_msgseg and the two DATALEN macros to
include/linux/msg.h so that other IPC code can safely copy
multi-segment message payloads into a kernel buffer under a spinlock,
without calling store_msg() which performs copy_to_user() and therefore
cannot be used under a spinlock.
ipc/msgutil.c already includes <linux/msg.h>, so it picks up the
definitions from the header with no functional change.
Signed-off-by: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
---
include/linux/msg.h | 13 +++++++++++++
ipc/msgutil.c | 7 -------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/include/linux/msg.h b/include/linux/msg.h
index 9a972a296b95..2d5353bace9a 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -5,6 +5,19 @@
#include <linux/list.h>
#include <uapi/linux/msg.h>
+/*
+ * Each message is stored in one or more page-sized segments.
+ * The first segment is embedded in struct msg_msg; overflow goes into
+ * chained struct msg_msgseg blocks.
+ */
+struct msg_msgseg {
+ struct msg_msgseg *next;
+ /* message data follows immediately */
+};
+
+#define DATALEN_MSG ((size_t)PAGE_SIZE - sizeof(struct msg_msg))
+#define DATALEN_SEG ((size_t)PAGE_SIZE - sizeof(struct msg_msgseg))
+
/* one msg_msg structure for each message */
struct msg_msg {
struct list_head m_list;
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index e28f0cecb2ec..9cd4b078d55c 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -31,13 +31,6 @@ struct ipc_namespace init_ipc_ns = {
.user_ns = &init_user_ns,
};
-struct msg_msgseg {
- struct msg_msgseg *next;
- /* the next part of the message follows immediately */
-};
-
-#define DATALEN_MSG ((size_t)PAGE_SIZE-sizeof(struct msg_msg))
-#define DATALEN_SEG ((size_t)PAGE_SIZE-sizeof(struct msg_msgseg))
static kmem_buckets *msg_buckets __ro_after_init;
--
2.34.1
next prev parent reply other threads:[~2026-03-25 19:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 19:00 [RFC PATCH 0/3] ipc/mqueue: add fcntl(F_MQ_PEEK) for non-destructive message inspection Shaurya Rane
2026-03-25 19:00 ` [RFC PATCH 1/3] mqueue: uapi: add struct mq_peek_attr and F_MQ_PEEK Shaurya Rane
2026-03-25 19:00 ` Shaurya Rane [this message]
2026-03-25 19:00 ` [RFC PATCH 3/3] ipc/mqueue: implement fcntl(F_MQ_PEEK) for non-destructive message inspection Shaurya Rane
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=20260325190025.40312-3-ssrane_b23@ee.vjti.ac.in \
--to=ssrane_b23@ee.vjti.ac.in \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=ptikhomirov@virtuozzo.com \
--cc=rstoyanov@fedoraproject.org \
--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