From: Rosen Penev <rosenp@gmail.com>
To: linux-cifs@vger.kernel.org
Cc: Namjae Jeon <linkinjeon@kernel.org>,
Steve French <smfrench@gmail.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Tom Talpey <tom@talpey.com>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-kernel@vger.kernel.org (open list),
linux-hardening@vger.kernel.org (open list:KERNEL HARDENING (not
covered by other areas):Keyword:\b__counted_by(_le|_be)?\b)
Subject: [PATCH] ksmbd: ipc: use kzalloc_flex and __counted_by
Date: Thu, 5 Mar 2026 22:35:22 -0800 [thread overview]
Message-ID: <20260306063522.439782-1-rosenp@gmail.com> (raw)
The former is just a nice macro and the latter allows runtime analysis
of the allocation and its size.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
fs/smb/server/transport_ipc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/smb/server/transport_ipc.c b/fs/smb/server/transport_ipc.c
index 2dbabe2d8005..f7aa427a06fe 100644
--- a/fs/smb/server/transport_ipc.c
+++ b/fs/smb/server/transport_ipc.c
@@ -55,7 +55,7 @@ static bool ksmbd_ipc_validate_version(struct genl_info *m)
struct ksmbd_ipc_msg {
unsigned int type;
unsigned int sz;
- unsigned char payload[];
+ unsigned char payload[] __counted_by(sz);
};
struct ipc_msg_table_entry {
@@ -242,9 +242,8 @@ static void ipc_update_last_active(void)
static struct ksmbd_ipc_msg *ipc_msg_alloc(size_t sz)
{
struct ksmbd_ipc_msg *msg;
- size_t msg_sz = sz + sizeof(struct ksmbd_ipc_msg);
- msg = kvzalloc(msg_sz, KSMBD_DEFAULT_GFP);
+ msg = kvzalloc_flex(*msg, payload, sz, KSMBD_DEFAULT_GFP);
if (msg)
msg->sz = sz;
return msg;
--
2.53.0
next reply other threads:[~2026-03-06 6:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 6:35 Rosen Penev [this message]
2026-03-25 5:03 ` [PATCH] ksmbd: ipc: use kzalloc_flex and __counted_by Namjae Jeon
2026-03-25 6:26 ` Namjae Jeon
2026-03-25 6:27 ` Rosen Penev
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=20260306063522.439782-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=tom@talpey.com \
/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