From: David Hildenbrand <david@redhat.com>
To: Arnd Bergmann <arnd@kernel.org>,
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>, Zi Yan <ziy@nvidia.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH 2/2] mm, cma: use literal printf format string
Date: Mon, 24 Feb 2025 15:37:13 +0100 [thread overview]
Message-ID: <697ca5a0-174f-441e-a27e-6a1652235a87@redhat.com> (raw)
In-Reply-To: <20250224141120.1240534-2-arnd@kernel.org>
On 24.02.25 15:07, Arnd Bergmann wrote:
> 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);
>
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-02-24 14:38 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 ` [PATCH 2/2] mm, cma: use literal printf format string Arnd Bergmann
2025-02-24 14:27 ` Zi Yan
2025-02-24 14:37 ` David Hildenbrand [this message]
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=697ca5a0-174f-441e-a27e-6a1652235a87@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--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