* [PATCH] m68k: cmpxchg: Dereference matching size
@ 2022-02-02 22:53 Kees Cook
2022-02-03 8:13 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2022-02-02 22:53 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Kees Cook, Greg Ungerer, Mark Rutland, Peter Zijlstra (Intel),
Arnd Bergmann, linux-kernel, linux-m68k, linux-hardening
Similar to the recent arm64 fix[1], avoid overly wide casts in the cmpxchg
implementation. Avoid this warning under -Warray-bounds with GCC 11:
net/sched/cls_tcindex.c: In function 'tcindex_set_parms':
./arch/m68k/include/asm/cmpxchg.h:64:17: warning: array subscript 'volatile struct __xchg_dummy[0]' is partly outside array bounds of 'struct tcf_result[1]' [-Warray-bounds]
64 | __asm__ __volatile__
| ^~~~~~~
net/sched/cls_tcindex.c:338:27: note: while referencing 'cr'
338 | struct tcf_result cr = {};
| ^~
No binary output differences are seen from this change.
[1] commit 3364c6ce23c6 ("arm64: atomics: lse: Dereference matching size")
Signed-off-by: Kees Cook <keescook@chromium.org>
---
arch/m68k/include/asm/cmpxchg.h | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/m68k/include/asm/cmpxchg.h b/arch/m68k/include/asm/cmpxchg.h
index e8ca4b0ccefa..6cf464cdab06 100644
--- a/arch/m68k/include/asm/cmpxchg.h
+++ b/arch/m68k/include/asm/cmpxchg.h
@@ -4,8 +4,7 @@
#include <linux/irqflags.h>
-struct __xchg_dummy { unsigned long a[100]; };
-#define __xg(x) ((volatile struct __xchg_dummy *)(x))
+#define __xg(type, x) ((volatile type *)(x))
extern unsigned long __invalid_xchg_size(unsigned long, volatile void *, int);
@@ -50,7 +49,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
"1:\n\t"
"casb %0,%1,%2\n\t"
"jne 1b"
- : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
+ : "=&d" (x) : "d" (x), "m" (*__xg(u8, ptr)) : "memory");
break;
case 2:
__asm__ __volatile__
@@ -58,7 +57,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
"1:\n\t"
"casw %0,%1,%2\n\t"
"jne 1b"
- : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
+ : "=&d" (x) : "d" (x), "m" (*__xg(u16, ptr)) : "memory");
break;
case 4:
__asm__ __volatile__
@@ -66,7 +65,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
"1:\n\t"
"casl %0,%1,%2\n\t"
"jne 1b"
- : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
+ : "=&d" (x) : "d" (x), "m" (*__xg(u32, ptr)) : "memory");
break;
default:
x = __invalid_xchg_size(x, ptr, size);
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] m68k: cmpxchg: Dereference matching size
2022-02-02 22:53 [PATCH] m68k: cmpxchg: Dereference matching size Kees Cook
@ 2022-02-03 8:13 ` Geert Uytterhoeven
2022-02-03 16:42 ` Kees Cook
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2022-02-03 8:13 UTC (permalink / raw)
To: Kees Cook
Cc: Greg Ungerer, Mark Rutland, Peter Zijlstra (Intel),
Arnd Bergmann, Linux Kernel Mailing List, linux-m68k,
linux-hardening
Hi Kees,
On Wed, Feb 2, 2022 at 11:53 PM Kees Cook <keescook@chromium.org> wrote:
> Similar to the recent arm64 fix[1], avoid overly wide casts in the cmpxchg
> implementation. Avoid this warning under -Warray-bounds with GCC 11:
>
> net/sched/cls_tcindex.c: In function 'tcindex_set_parms':
> ./arch/m68k/include/asm/cmpxchg.h:64:17: warning: array subscript 'volatile struct __xchg_dummy[0]' is partly outside array bounds of 'struct tcf_result[1]' [-Warray-bounds]
> 64 | __asm__ __volatile__
> | ^~~~~~~
> net/sched/cls_tcindex.c:338:27: note: while referencing 'cr'
> 338 | struct tcf_result cr = {};
> | ^~
>
> No binary output differences are seen from this change.
>
> [1] commit 3364c6ce23c6 ("arm64: atomics: lse: Dereference matching size")
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Thanks for your patch!
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Do you want me to queue this in the m68k for-v5.18 branch, or do
you want to take it yourself, together with commit a8712a32665f9b1a
("Makefile: Enable -Warray-bounds") in linux-next that triggers this?
In case of the latter:
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Please let me know. Thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] m68k: cmpxchg: Dereference matching size
2022-02-03 8:13 ` Geert Uytterhoeven
@ 2022-02-03 16:42 ` Kees Cook
0 siblings, 0 replies; 3+ messages in thread
From: Kees Cook @ 2022-02-03 16:42 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Greg Ungerer, Mark Rutland, Peter Zijlstra (Intel),
Arnd Bergmann, Linux Kernel Mailing List, linux-m68k,
linux-hardening
On Thu, Feb 03, 2022 at 09:13:30AM +0100, Geert Uytterhoeven wrote:
> Hi Kees,
>
> On Wed, Feb 2, 2022 at 11:53 PM Kees Cook <keescook@chromium.org> wrote:
> > Similar to the recent arm64 fix[1], avoid overly wide casts in the cmpxchg
> > implementation. Avoid this warning under -Warray-bounds with GCC 11:
> >
> > net/sched/cls_tcindex.c: In function 'tcindex_set_parms':
> > ./arch/m68k/include/asm/cmpxchg.h:64:17: warning: array subscript 'volatile struct __xchg_dummy[0]' is partly outside array bounds of 'struct tcf_result[1]' [-Warray-bounds]
> > 64 | __asm__ __volatile__
> > | ^~~~~~~
> > net/sched/cls_tcindex.c:338:27: note: while referencing 'cr'
> > 338 | struct tcf_result cr = {};
> > | ^~
> >
> > No binary output differences are seen from this change.
> >
> > [1] commit 3364c6ce23c6 ("arm64: atomics: lse: Dereference matching size")
> >
> > Signed-off-by: Kees Cook <keescook@chromium.org>
>
> Thanks for your patch!
>
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
> Do you want me to queue this in the m68k for-v5.18 branch, or do
> you want to take it yourself, together with commit a8712a32665f9b1a
> ("Makefile: Enable -Warray-bounds") in linux-next that triggers this?
> In case of the latter:
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Given how -next is being ordered, it's probably best to go via my tree.
Thanks for the review!
-Kees
>
> Please let me know. Thanks!
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-03 16:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02 22:53 [PATCH] m68k: cmpxchg: Dereference matching size Kees Cook
2022-02-03 8:13 ` Geert Uytterhoeven
2022-02-03 16:42 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).