* [PATCH] ASoC: kirkwood: Iterate over array indexes instead of using pointer math
@ 2023-01-27 22:41 Kees Cook
2023-01-28 17:18 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2023-01-27 22:41 UTC (permalink / raw)
To: Liam Girdwood
Cc: Kees Cook, Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
linux-kernel, linux-hardening
Walking the dram->cs array was seen as accesses beyond the first array
item by the compiler. Instead, use the array index directly. This allows
for run-time bounds checking under CONFIG_UBSAN_BOUNDS as well. Seen
with GCC 13 with -fstrict-flex-arrays:
../sound/soc/kirkwood/kirkwood-dma.c: In function
'kirkwood_dma_conf_mbus_windows.constprop':
../sound/soc/kirkwood/kirkwood-dma.c:90:24: warning: array subscript 0 is outside array bounds of 'const struct mbus_dram_window[0]' [-Warray-bounds=]
90 | if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) {
| ~~^~~~~~
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
sound/soc/kirkwood/kirkwood-dma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
index 700a18561a94..640cebd2983e 100644
--- a/sound/soc/kirkwood/kirkwood-dma.c
+++ b/sound/soc/kirkwood/kirkwood-dma.c
@@ -86,7 +86,7 @@ kirkwood_dma_conf_mbus_windows(void __iomem *base, int win,
/* try to find matching cs for current dma address */
for (i = 0; i < dram->num_cs; i++) {
- const struct mbus_dram_window *cs = dram->cs + i;
+ const struct mbus_dram_window *cs = &dram->cs[i];
if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) {
writel(cs->base & 0xffff0000,
base + KIRKWOOD_AUDIO_WIN_BASE_REG(win));
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ASoC: kirkwood: Iterate over array indexes instead of using pointer math
2023-01-27 22:41 [PATCH] ASoC: kirkwood: Iterate over array indexes instead of using pointer math Kees Cook
@ 2023-01-28 17:18 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2023-01-28 17:18 UTC (permalink / raw)
To: Liam Girdwood, Kees Cook
Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel,
linux-hardening
On Fri, 27 Jan 2023 14:41:29 -0800, Kees Cook wrote:
> Walking the dram->cs array was seen as accesses beyond the first array
> item by the compiler. Instead, use the array index directly. This allows
> for run-time bounds checking under CONFIG_UBSAN_BOUNDS as well. Seen
> with GCC 13 with -fstrict-flex-arrays:
>
> ../sound/soc/kirkwood/kirkwood-dma.c: In function
> 'kirkwood_dma_conf_mbus_windows.constprop':
> ../sound/soc/kirkwood/kirkwood-dma.c:90:24: warning: array subscript 0 is outside array bounds of 'const struct mbus_dram_window[0]' [-Warray-bounds=]
> 90 | if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) {
> | ~~^~~~~~
>
> [...]
Applied to
broonie/sound.git for-next
Thanks!
[1/1] ASoC: kirkwood: Iterate over array indexes instead of using pointer math
commit: b3bcedc0402fcdc5c8624c433562d9d1882749d8
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-28 17:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-27 22:41 [PATCH] ASoC: kirkwood: Iterate over array indexes instead of using pointer math Kees Cook
2023-01-28 17:18 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox