]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
percpu: use TYPEOF_UNQUAL() in *_cpu_ptr() accessors
authorUros Bizjak <ubizjak@gmail.com>
Mon, 27 Jan 2025 16:05:08 +0000 (17:05 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 17 Mar 2025 05:05:53 +0000 (22:05 -0700)
Use TYPEOF_UNQUAL() macro to declare the return type of *_cpu_ptr()
accessors in the generic named address space to avoid access to data from
pointer to non-enclosed address space type of errors.

Link: https://lkml.kernel.org/r/20250127160709.80604-5-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Acked-by: Nadav Amit <nadav.amit@gmail.com>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: Dennis Zhou <dennis@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Waiman Long <longman@redhat.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/x86/include/asm/percpu.h
include/linux/percpu-defs.h

index 666e4137b09f18806a25a93f2ba3ce6c73d0667e..27f668660abe5667b854c7e74c764d3eda316869 100644 (file)
        unsigned long tcp_ptr__ = raw_cpu_read_long(this_cpu_off);      \
                                                                        \
        tcp_ptr__ += (__force unsigned long)(_ptr);                     \
-       (typeof(*(_ptr)) __kernel __force *)tcp_ptr__;                  \
+       (TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)tcp_ptr__;           \
 })
 #else
-#define arch_raw_cpu_ptr(_ptr) ({ BUILD_BUG(); (typeof(_ptr))0; })
+#define arch_raw_cpu_ptr(_ptr)                                         \
+({                                                                     \
+       BUILD_BUG();                                                    \
+       (TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)0;                   \
+})
 #endif
 
 #define PER_CPU_VAR(var)       %__percpu_seg:(var)__percpu_rel
index 79b9402404f1fcd14b2b3b2aee34078a8daf6fd5..a7cf954ea99dcfa2ef637155477be894d65a8d1e 100644 (file)
@@ -221,7 +221,7 @@ do {                                                                        \
 } while (0)
 
 #define PERCPU_PTR(__p)                                                        \
-       (typeof(*(__p)) __force __kernel *)((__force unsigned long)(__p))
+       (TYPEOF_UNQUAL(*(__p)) __force __kernel *)((__force unsigned long)(__p))
 
 #ifdef CONFIG_SMP