From: Arnd Bergmann <arnd@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Nathan Chancellor <nathan@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Frank van der Linden <fvdl@google.com>,
David Hildenbrand <david@redhat.com>, Zi Yan <ziy@nvidia.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: [PATCH 2/2] mm, cma: use literal printf format string
Date: Mon, 24 Feb 2025 15:07:36 +0100 [thread overview]
Message-ID: <20250224141120.1240534-2-arnd@kernel.org> (raw)
In-Reply-To: <20250224141120.1240534-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
Using a variable string as a printf format can be a security issue
that clang warns about when extra warnings are enabled:
mm/cma.c:239:37: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
239 | snprintf(cma->name, CMA_MAX_NAME, name);
| ^~~~
This one does not appear to be a security issue since the string is
not user controlled, but it's better to avoid the warning.
Use "%s" as the format instead and just pass the name as the argument.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
mm/cma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/cma.c b/mm/cma.c
index ef0206c0f16d..09322b8284bd 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -236,7 +236,7 @@ static int __init cma_new_area(const char *name, phys_addr_t size,
cma_area_count++;
if (name)
- snprintf(cma->name, CMA_MAX_NAME, name);
+ snprintf(cma->name, CMA_MAX_NAME, "%s", name);
else
snprintf(cma->name, CMA_MAX_NAME, "cma%d\n", cma_area_count);
--
2.39.5
next prev parent reply other threads:[~2025-02-24 14:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 14:07 [PATCH 1/2] mm, cma: fix 32-bit warning Arnd Bergmann
2025-02-24 14:07 ` Arnd Bergmann [this message]
2025-02-24 14:27 ` [PATCH 2/2] mm, cma: use literal printf format string Zi Yan
2025-02-24 14:37 ` David Hildenbrand
2025-02-24 17:02 ` Frank van der Linden
2025-02-24 14:26 ` [PATCH 1/2] mm, cma: fix 32-bit warning Zi Yan
2025-02-24 14:36 ` David Hildenbrand
2025-02-24 17:00 ` Frank van der Linden
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=20250224141120.1240534-2-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=david@redhat.com \
--cc=fvdl@google.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=ziy@nvidia.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