From: Arnd Bergmann <arnd@kernel.org>
To: Kees Cook <keescook@chromium.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Nathan Chancellor <nathan@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: [PATCH] ALSA: asihpi: work around clang-17+ false positive fortify-string warning
Date: Wed, 28 Feb 2024 15:01:45 +0100 [thread overview]
Message-ID: <20240228140152.1824901-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
One of the memory copies in this driver triggers a warning about a
possible out of range access:
In file included from /home/arnd/arm-soc/sound/pci/asihpi/hpimsgx.c:13:
/home/arnd/arm-soc/include/linux/fortify-string.h:553:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
553 | __write_overflow_field(p_size_field, size);
| ^
Adding a range check avoids the problem, though I don't quite see
why it warns in the first place if clang has no knowledge of the
actual range of the type, or why I never saw the warning in previous
randconfig tests.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
sound/pci/asihpi/hpimsgx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c
index d0caef299481..4f245c3956b1 100644
--- a/sound/pci/asihpi/hpimsgx.c
+++ b/sound/pci/asihpi/hpimsgx.c
@@ -576,6 +576,9 @@ static u16 adapter_prepare(u16 adapter)
/* Open the adapter and streams */
u16 i;
+ if (adapter >= ARRAY_SIZE(rESP_HPI_ADAPTER_OPEN))
+ return 0;
+
/* call to HPI_ADAPTER_OPEN */
hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
HPI_ADAPTER_OPEN);
--
2.39.2
next reply other threads:[~2024-02-28 14:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 14:01 Arnd Bergmann [this message]
2024-02-28 14:37 ` [PATCH] ALSA: asihpi: work around clang-17+ false positive fortify-string warning Takashi Iwai
2024-02-28 15:03 ` Arnd Bergmann
2024-02-28 16:24 ` Takashi Iwai
2024-02-28 17:23 ` Arnd Bergmann
2024-02-28 17:39 ` Clang __bos vs loop unrolling (was Re: [PATCH] ALSA: asihpi: work around clang-17+ false positive fortify-string warning) Kees Cook
2024-02-29 1:20 ` Bill Wendling
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=20240228140152.1824901-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=justinstitt@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.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