* [PATCH 10/22] microblaze: include linux/cpu.h for trap_init() prototype
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
Microblaze runs into a single -Wmissing-prototypes warning when that is
enabled:
arch/microblaze/kernel/traps.c:21:6: warning: no previous prototype for 'trap_init' [-Wmissing-prototypes]
Include the right header to avoid this.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/alpha/kernel/traps.c | 1 +
arch/csky/include/asm/traps.h | 2 --
arch/csky/kernel/traps.c | 1 +
arch/m68k/coldfire/vectors.c | 3 +--
arch/m68k/coldfire/vectors.h | 3 ---
arch/microblaze/kernel/traps.c | 1 +
arch/sparc/kernel/traps_32.c | 1 +
arch/sparc/kernel/traps_64.c | 1 +
arch/x86/include/asm/traps.h | 1 -
arch/x86/kernel/traps.c | 1 +
10 files changed, 7 insertions(+), 8 deletions(-)
delete mode 100644 arch/m68k/coldfire/vectors.h
diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index d9a67b370e04..7fc72aeb7398 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -9,6 +9,7 @@
* This file initializes the trap entry points
*/
+#include <linux/cpu.h>
#include <linux/jiffies.h>
#include <linux/mm.h>
#include <linux/sched/signal.h>
diff --git a/arch/csky/include/asm/traps.h b/arch/csky/include/asm/traps.h
index 732c4aaa2e26..495ce318d569 100644
--- a/arch/csky/include/asm/traps.h
+++ b/arch/csky/include/asm/traps.h
@@ -55,6 +55,4 @@ asmlinkage void trap_c(struct pt_regs *regs);
asmlinkage void do_notify_resume(struct pt_regs *regs,
unsigned long thread_info_flags);
-void trap_init(void);
-
#endif /* __ASM_CSKY_TRAPS_H */
diff --git a/arch/csky/kernel/traps.c b/arch/csky/kernel/traps.c
index 6e426fba0119..c2246b07cc9c 100644
--- a/arch/csky/kernel/traps.c
+++ b/arch/csky/kernel/traps.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/cpu.h>
#include <linux/sched.h>
#include <linux/signal.h>
#include <linux/kernel.h>
diff --git a/arch/m68k/coldfire/vectors.c b/arch/m68k/coldfire/vectors.c
index c26c255b530d..4321fd89d83e 100644
--- a/arch/m68k/coldfire/vectors.c
+++ b/arch/m68k/coldfire/vectors.c
@@ -12,14 +12,13 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/irq.h>
+#include <linux/cpu.h>
#include <asm/traps.h>
#include <asm/machdep.h>
#include <asm/coldfire.h>
#include <asm/mcfsim.h>
#include <asm/mcfwdebug.h>
-#include "vectors.h"
-
/***************************************************************************/
#ifdef TRAP_DBG_INTERRUPT
diff --git a/arch/m68k/coldfire/vectors.h b/arch/m68k/coldfire/vectors.h
deleted file mode 100644
index 0b01450a4353..000000000000
--- a/arch/m68k/coldfire/vectors.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-void trap_init(void);
diff --git a/arch/microblaze/kernel/traps.c b/arch/microblaze/kernel/traps.c
index 94b6fe93147d..080aa769218d 100644
--- a/arch/microblaze/kernel/traps.c
+++ b/arch/microblaze/kernel/traps.c
@@ -8,6 +8,7 @@
* for more details.
*/
+#include <linux/cpu.h>
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/kallsyms.h>
diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
index 179aabfa712e..bb149f6cc34b 100644
--- a/arch/sparc/kernel/traps_32.c
+++ b/arch/sparc/kernel/traps_32.c
@@ -10,6 +10,7 @@
* I hate traps on the sparc, grrr...
*/
+#include <linux/cpu.h>
#include <linux/sched/mm.h>
#include <linux/sched/debug.h>
#include <linux/mm_types.h>
diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
index 08ffd17d5ec3..3631899f2394 100644
--- a/arch/sparc/kernel/traps_64.c
+++ b/arch/sparc/kernel/traps_64.c
@@ -9,6 +9,7 @@
* I like traps on v9, :))))
*/
+#include <linux/cpu.h>
#include <linux/extable.h>
#include <linux/sched/mm.h>
#include <linux/sched/debug.h>
diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
index b1c9cea6ba88..1f1deaecd364 100644
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -14,7 +14,6 @@
asmlinkage __visible notrace struct pt_regs *sync_regs(struct pt_regs *eregs);
asmlinkage __visible notrace
struct pt_regs *fixup_bad_iret(struct pt_regs *bad_regs);
-void __init trap_init(void);
asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *eregs);
#endif
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index c876f1d36a81..b0737a15c470 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -37,6 +37,7 @@
#include <linux/nmi.h>
#include <linux/mm.h>
#include <linux/smp.h>
+#include <linux/cpu.h>
#include <linux/io.h>
#include <linux/hardirq.h>
#include <linux/atomic.h>
--
2.39.2
^ permalink raw reply related
* [PATCH 11/22] x86: sta2x11: include header for sta2x11_get_instance() prototype
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
sta2x11_get_instance() is a global function declared in asm/sta2x11.h,
but this header is not included before the definition, causing a warning:
arch/x86/pci/sta2x11-fixup.c:95:26: error: no previous prototype for 'sta2x11_get_instance' [-Werror=missing-prototypes]
Add the missing #include.
Fixes: 83125a3a189e ("x86, platform: Initial support for sta2x11 I/O hub")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/x86/pci/sta2x11-fixup.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/pci/sta2x11-fixup.c b/arch/x86/pci/sta2x11-fixup.c
index 7368afc03998..8c8ddc4dcc08 100644
--- a/arch/x86/pci/sta2x11-fixup.c
+++ b/arch/x86/pci/sta2x11-fixup.c
@@ -14,6 +14,7 @@
#include <linux/dma-map-ops.h>
#include <linux/swiotlb.h>
#include <asm/iommu.h>
+#include <asm/sta2x11.h>
#define STA2X11_SWIOTLB_SIZE (4*1024*1024)
--
2.39.2
^ permalink raw reply related
* [PATCH 12/22] csky: fix arch_jump_label_transform_static override
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
The arch_jump_label_transform_static() function in csky was originally meant to
override the generic __weak function, but that got changed to an #ifndef check.
This showed up as a missing-prototype warning:
arch/csky/kernel/jump_label.c:43:6: error: no previous prototype for 'arch_jump_label_transform_static' [-Werror=missing-prototypes]
Change the method to use the new method of having a #define and a prototype
for the global function.
Fixes: 7e6b9db27de9 ("jump_label: make initial NOP patching the special case")
Fixes: 4e8bb4ba5a55 ("csky: Add jump-label implementation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/csky/include/asm/jump_label.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/csky/include/asm/jump_label.h b/arch/csky/include/asm/jump_label.h
index d488ba6084bc..98a3f4b168bd 100644
--- a/arch/csky/include/asm/jump_label.h
+++ b/arch/csky/include/asm/jump_label.h
@@ -43,5 +43,10 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key,
return true;
}
+enum jump_label_type;
+void arch_jump_label_transform_static(struct jump_entry *entry,
+ enum jump_label_type type);
+#define arch_jump_label_transform_static arch_jump_label_transform_static
+
#endif /* __ASSEMBLY__ */
#endif /* __ASM_CSKY_JUMP_LABEL_H */
--
2.39.2
^ permalink raw reply related
* [PATCH 13/22] arch: add do_page_fault prototypes
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
arch/alpha/mm/fault.c:85:1: error: no previous prototype for 'do_page_fault' [-Werror=missing-prototypes]
arch/csky/mm/fault.c:187:17: error: no previous prototype for 'do_page_fault' [-Werror=missing-prototypes]
arch/mips/mm/fault.c:323:17: error: no previous prototype for 'do_page_fault' [-Werror=missing-prototypes]
arch/nios2/mm/fault.c:43:17: error: no previous prototype for 'do_page_fault' [-Werror=missing-prototypes]
arch/sh/mm/fault.c:389:27: error: no previous prototype for 'do_page_fault' [-Werror=missing-prototypes]
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/alpha/include/asm/mmu_context.h | 2 ++
arch/csky/include/asm/traps.h | 2 ++
arch/mips/include/asm/traps.h | 3 +++
arch/nios2/include/asm/traps.h | 2 ++
arch/sh/include/asm/traps_32.h | 3 +++
5 files changed, 12 insertions(+)
diff --git a/arch/alpha/include/asm/mmu_context.h b/arch/alpha/include/asm/mmu_context.h
index 4eea7c616992..29a3e3a1f02b 100644
--- a/arch/alpha/include/asm/mmu_context.h
+++ b/arch/alpha/include/asm/mmu_context.h
@@ -183,6 +183,8 @@ ev4_switch_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm,
}
extern void __load_new_mm_context(struct mm_struct *);
+asmlinkage void do_page_fault(unsigned long address, unsigned long mmcsr,
+ long cause, struct pt_regs *regs);
#ifdef CONFIG_SMP
#define check_mmu_context() \
diff --git a/arch/csky/include/asm/traps.h b/arch/csky/include/asm/traps.h
index 495ce318d569..6bbbbe43165f 100644
--- a/arch/csky/include/asm/traps.h
+++ b/arch/csky/include/asm/traps.h
@@ -55,4 +55,6 @@ asmlinkage void trap_c(struct pt_regs *regs);
asmlinkage void do_notify_resume(struct pt_regs *regs,
unsigned long thread_info_flags);
+asmlinkage void do_page_fault(struct pt_regs *regs);
+
#endif /* __ASM_CSKY_TRAPS_H */
diff --git a/arch/mips/include/asm/traps.h b/arch/mips/include/asm/traps.h
index 15cde638b407..d4d9f8a8fdea 100644
--- a/arch/mips/include/asm/traps.h
+++ b/arch/mips/include/asm/traps.h
@@ -39,4 +39,7 @@ extern char except_vec_nmi[];
register_nmi_notifier(&fn##_nb); \
})
+asmlinkage void do_page_fault(struct pt_regs *regs,
+ unsigned long write, unsigned long address);
+
#endif /* _ASM_TRAPS_H */
diff --git a/arch/nios2/include/asm/traps.h b/arch/nios2/include/asm/traps.h
index 82a48473280d..afd77bef01c6 100644
--- a/arch/nios2/include/asm/traps.h
+++ b/arch/nios2/include/asm/traps.h
@@ -14,6 +14,8 @@
#ifndef __ASSEMBLY__
void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr);
+void do_page_fault(struct pt_regs *regs, unsigned long cause,
+ unsigned long address);
#endif
#endif /* _ASM_NIOS2_TRAPS_H */
diff --git a/arch/sh/include/asm/traps_32.h b/arch/sh/include/asm/traps_32.h
index 8c5bbb7b6053..8f14071bea72 100644
--- a/arch/sh/include/asm/traps_32.h
+++ b/arch/sh/include/asm/traps_32.h
@@ -43,6 +43,9 @@ static inline void trigger_address_error(void)
asmlinkage void do_address_error(struct pt_regs *regs,
unsigned long writeaccess,
unsigned long address);
+asmlinkage void do_page_fault(struct pt_regs *regs,
+ unsigned long error_code,
+ unsigned long address);
asmlinkage void do_divide_error(unsigned long r4);
asmlinkage void do_reserved_inst(void);
asmlinkage void do_illegal_slot_inst(void);
--
2.39.2
^ permalink raw reply related
* [PATCH 14/22] arch: add missing prepare_ftrace_return() prototypes
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
The prototype for prepare_ftrace_return() is architecture specific and
can't be in a global header. Since it's normally called from assembly,
it doesn't really need a prototype, but we get a warning if it's missing:
arch/csky/kernel/ftrace.c:147:6: error: no previous prototype for 'prepare_ftrace_return' [-Werror=missing-prototypes]
arch/microblaze/kernel/ftrace.c:22:6: error: no previous prototype for 'prepare_ftrace_return' [-Werror=missing-prototypes]
arch/mips/kernel/ftrace.c:305:6: error: no previous prototype for 'prepare_ftrace_return' [-Werror=missing-prototypes]
Add the prototypes for the three architectures that don't already have
one in asm/ftrace.h.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/csky/include/asm/ftrace.h | 4 ++++
arch/microblaze/include/asm/ftrace.h | 1 +
arch/mips/include/asm/ftrace.h | 4 ++++
3 files changed, 9 insertions(+)
diff --git a/arch/csky/include/asm/ftrace.h b/arch/csky/include/asm/ftrace.h
index 9b86341731b6..fd215c38ef27 100644
--- a/arch/csky/include/asm/ftrace.h
+++ b/arch/csky/include/asm/ftrace.h
@@ -26,5 +26,9 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
struct dyn_arch_ftrace {
};
+
+void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
+ unsigned long frame_pointer);
+
#endif /* !__ASSEMBLY__ */
#endif /* __ASM_CSKY_FTRACE_H */
diff --git a/arch/microblaze/include/asm/ftrace.h b/arch/microblaze/include/asm/ftrace.h
index 6a92bed37794..4ca38b92a3a2 100644
--- a/arch/microblaze/include/asm/ftrace.h
+++ b/arch/microblaze/include/asm/ftrace.h
@@ -10,6 +10,7 @@
#ifndef __ASSEMBLY__
extern void _mcount(void);
extern void ftrace_call_graph(void);
+void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr);
#endif
#ifdef CONFIG_DYNAMIC_FTRACE
diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
index db497a8167da..dc025888f6d2 100644
--- a/arch/mips/include/asm/ftrace.h
+++ b/arch/mips/include/asm/ftrace.h
@@ -85,6 +85,10 @@ struct dyn_arch_ftrace {
};
#endif /* CONFIG_DYNAMIC_FTRACE */
+
+void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra,
+ unsigned long fp);
+
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_FUNCTION_TRACER */
#endif /* _ASM_MIPS_FTRACE_H */
--
2.39.2
^ permalink raw reply related
* [PATCH 15/22] arch: vdso: consolidate gettime prototypes
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
The VDSO functions are defined as globals in the kernel sources but intended
to be called from userspace, so there is no need to declare them in a kernel
side header.
Without a prototype, this now causes warnings such as
arch/mips/vdso/vgettimeofday.c:14:5: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes]
arch/mips/vdso/vgettimeofday.c:28:5: error: no previous prototype for '__vdso_gettimeofday' [-Werror=missing-prototypes]
arch/mips/vdso/vgettimeofday.c:36:5: error: no previous prototype for '__vdso_clock_getres' [-Werror=missing-prototypes]
arch/mips/vdso/vgettimeofday.c:42:5: error: no previous prototype for '__vdso_clock_gettime64' [-Werror=missing-prototypes]
arch/sparc/vdso/vclock_gettime.c:254:1: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes]
arch/sparc/vdso/vclock_gettime.c:282:1: error: no previous prototype for '__vdso_clock_gettime_stick' [-Werror=missing-prototypes]
arch/sparc/vdso/vclock_gettime.c:307:1: error: no previous prototype for '__vdso_gettimeofday' [-Werror=missing-prototypes]
arch/sparc/vdso/vclock_gettime.c:343:1: error: no previous prototype for '__vdso_gettimeofday_stick' [-Werror=missing-prototypes]
Most architectures have already added workarounds for these by adding
declarations somewhere, but since these are all compatible, we should
really just have one copy, with an #ifdef check for the 32-bit vs
64-bit variant and use that everywhere.
Unfortunately, the sparc version is currently incompatible since
that never added support for __vdso_clock_gettime64() in 32-bit
userland. For the moment, I'm leaving this one out, as I can't
easily test it and it requires a larger rework.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm/include/asm/vdso.h | 5 -----
arch/arm/vdso/vgettimeofday.c | 1 +
arch/arm64/kernel/vdso32/vgettimeofday.c | 1 +
arch/csky/kernel/vdso/vgettimeofday.c | 11 +----------
arch/loongarch/vdso/vgettimeofday.c | 7 +------
arch/mips/vdso/vgettimeofday.c | 1 +
arch/riscv/kernel/vdso/vgettimeofday.c | 7 +------
arch/x86/entry/vdso/vclock_gettime.c | 10 +---------
arch/x86/include/asm/vdso/gettimeofday.h | 2 --
arch/x86/um/vdso/um_vdso.c | 1 +
include/vdso/gettime.h | 23 +++++++++++++++++++++++
11 files changed, 31 insertions(+), 38 deletions(-)
create mode 100644 include/vdso/gettime.h
diff --git a/arch/arm/include/asm/vdso.h b/arch/arm/include/asm/vdso.h
index 422c3afa806a..5b85889f82ee 100644
--- a/arch/arm/include/asm/vdso.h
+++ b/arch/arm/include/asm/vdso.h
@@ -24,11 +24,6 @@ static inline void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
#endif /* CONFIG_VDSO */
-int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts);
-int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts);
-int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
-int __vdso_clock_getres(clockid_t clock_id, struct old_timespec32 *res);
-
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c
index a003beacac76..3554aa35f1ba 100644
--- a/arch/arm/vdso/vgettimeofday.c
+++ b/arch/arm/vdso/vgettimeofday.c
@@ -8,6 +8,7 @@
#include <linux/types.h>
#include <asm/vdso.h>
#include <asm/unwind.h>
+#include <vdso/gettime.h>
int __vdso_clock_gettime(clockid_t clock,
struct old_timespec32 *ts)
diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c
index 5acff29c5991..e23c7f4ef26b 100644
--- a/arch/arm64/kernel/vdso32/vgettimeofday.c
+++ b/arch/arm64/kernel/vdso32/vgettimeofday.c
@@ -5,6 +5,7 @@
* Copyright (C) 2018 ARM Limited
*
*/
+#include <vdso/gettime.h>
int __vdso_clock_gettime(clockid_t clock,
struct old_timespec32 *ts)
diff --git a/arch/csky/kernel/vdso/vgettimeofday.c b/arch/csky/kernel/vdso/vgettimeofday.c
index c4831145eed5..55af30e83752 100644
--- a/arch/csky/kernel/vdso/vgettimeofday.c
+++ b/arch/csky/kernel/vdso/vgettimeofday.c
@@ -2,36 +2,27 @@
#include <linux/time.h>
#include <linux/types.h>
+#include <vdso/gettime.h>
extern
-int __vdso_clock_gettime(clockid_t clock,
- struct old_timespec32 *ts);
int __vdso_clock_gettime(clockid_t clock,
struct old_timespec32 *ts)
{
return __cvdso_clock_gettime32(clock, ts);
}
-int __vdso_clock_gettime64(clockid_t clock,
- struct __kernel_timespec *ts);
int __vdso_clock_gettime64(clockid_t clock,
struct __kernel_timespec *ts)
{
return __cvdso_clock_gettime(clock, ts);
}
-extern
-int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
- struct timezone *tz);
int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
struct timezone *tz)
{
return __cvdso_gettimeofday(tv, tz);
}
-extern
-int __vdso_clock_getres(clockid_t clock_id,
- struct old_timespec32 *res);
int __vdso_clock_getres(clockid_t clock_id,
struct old_timespec32 *res)
{
diff --git a/arch/loongarch/vdso/vgettimeofday.c b/arch/loongarch/vdso/vgettimeofday.c
index 8f22863bd7ea..0885c1f3a89d 100644
--- a/arch/loongarch/vdso/vgettimeofday.c
+++ b/arch/loongarch/vdso/vgettimeofday.c
@@ -5,23 +5,18 @@
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/
#include <linux/types.h>
+#include <vdso/gettime.h>
-extern
-int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts);
int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
{
return __cvdso_clock_gettime(clock, ts);
}
-extern
-int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
{
return __cvdso_gettimeofday(tv, tz);
}
-extern
-int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res);
int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res)
{
return __cvdso_clock_getres(clock_id, res);
diff --git a/arch/mips/vdso/vgettimeofday.c b/arch/mips/vdso/vgettimeofday.c
index 6b83b6376a4b..604afea3f336 100644
--- a/arch/mips/vdso/vgettimeofday.c
+++ b/arch/mips/vdso/vgettimeofday.c
@@ -9,6 +9,7 @@
*/
#include <linux/time.h>
#include <linux/types.h>
+#include <vdso/gettime.h>
#if _MIPS_SIM != _MIPS_SIM_ABI64
int __vdso_clock_gettime(clockid_t clock,
diff --git a/arch/riscv/kernel/vdso/vgettimeofday.c b/arch/riscv/kernel/vdso/vgettimeofday.c
index cc0d80699c31..b35057802584 100644
--- a/arch/riscv/kernel/vdso/vgettimeofday.c
+++ b/arch/riscv/kernel/vdso/vgettimeofday.c
@@ -8,23 +8,18 @@
#include <linux/time.h>
#include <linux/types.h>
+#include <vdso/gettime.h>
-extern
-int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts);
int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
{
return __cvdso_clock_gettime(clock, ts);
}
-extern
-int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
{
return __cvdso_gettimeofday(tv, tz);
}
-extern
-int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res);
int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res)
{
return __cvdso_clock_getres(clock_id, res);
diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c
index 7d70935b6758..0debc194bd78 100644
--- a/arch/x86/entry/vdso/vclock_gettime.c
+++ b/arch/x86/entry/vdso/vclock_gettime.c
@@ -11,12 +11,10 @@
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/types.h>
+#include <vdso/gettime.h>
#include "../../../../lib/vdso/gettimeofday.c"
-extern int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
-extern __kernel_old_time_t __vdso_time(__kernel_old_time_t *t);
-
int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
{
return __cvdso_gettimeofday(tv, tz);
@@ -35,9 +33,6 @@ __kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__v
#if defined(CONFIG_X86_64) && !defined(BUILD_VDSO32_64)
/* both 64-bit and x32 use these */
-extern int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts);
-extern int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res);
-
int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
{
return __cvdso_clock_gettime(clock, ts);
@@ -56,9 +51,6 @@ int clock_getres(clockid_t, struct __kernel_timespec *)
#else
/* i386 only */
-extern int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts);
-extern int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res);
-
int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts)
{
return __cvdso_clock_gettime32(clock, ts);
diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h
index c81858d903dc..a46edb0e0cf7 100644
--- a/arch/x86/include/asm/vdso/gettimeofday.h
+++ b/arch/x86/include/asm/vdso/gettimeofday.h
@@ -337,8 +337,6 @@ u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
}
#define vdso_calc_delta vdso_calc_delta
-int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts);
-
#endif /* !__ASSEMBLY__ */
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */
diff --git a/arch/x86/um/vdso/um_vdso.c b/arch/x86/um/vdso/um_vdso.c
index ff0f3b4b6c45..63768dd347ce 100644
--- a/arch/x86/um/vdso/um_vdso.c
+++ b/arch/x86/um/vdso/um_vdso.c
@@ -12,6 +12,7 @@
#include <linux/time.h>
#include <linux/getcpu.h>
#include <asm/unistd.h>
+#include <vdso/gettime.h>
int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
{
diff --git a/include/vdso/gettime.h b/include/vdso/gettime.h
new file mode 100644
index 000000000000..c50d152e7b3e
--- /dev/null
+++ b/include/vdso/gettime.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _VDSO_GETTIME_H
+#define _VDSO_GETTIME_H
+
+#include <linux/types.h>
+
+struct __kernel_timespec;
+struct timezone;
+
+#if !defined(CONFIG_64BIT) || defined(BUILD_VDSO32_64)
+struct old_timespec32;
+int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res);
+int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts);
+#else
+int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res);
+int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts);
+#endif
+
+__kernel_old_time_t __vdso_time(__kernel_old_time_t *t);
+int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
+int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts);
+
+#endif
--
2.39.2
^ permalink raw reply related
* [PATCH 16/22] bcachefs: mark bch2_target_to_text_sb() static
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
bch2_target_to_text_sb() is only called in the file it is defined in,
and it has no extern prototype:
fs/bcachefs/disk_groups.c:583:6: error: no previous prototype for 'bch2_target_to_text_sb' [-Werror=missing-prototypes]
Mark it static to avoid the warning and have the code better optimized.
Fixes: bf0d9e89de2e ("bcachefs: Split apart bch2_target_to_text(), bch2_target_to_text_sb()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/bcachefs/disk_groups.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c
index d613695abf9f..1f334124055b 100644
--- a/fs/bcachefs/disk_groups.c
+++ b/fs/bcachefs/disk_groups.c
@@ -580,7 +580,7 @@ void bch2_target_to_text(struct printbuf *out, struct bch_fs *c, unsigned v)
}
}
-void bch2_target_to_text_sb(struct printbuf *out, struct bch_sb *sb, unsigned v)
+static void bch2_target_to_text_sb(struct printbuf *out, struct bch_sb *sb, unsigned v)
{
struct target t = target_decode(v);
--
2.39.2
^ permalink raw reply related
* [PATCH 17/22] powerpc: ps3: move udbg_shutdown_ps3gelic prototype
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
Allmodconfig kernels produce a missing-prototypes warning:
arch/powerpc/platforms/ps3/gelic_udbg.c:239:6: error: no previous prototype for 'udbg_shutdown_ps3gelic' [-Werror=missing-prototypes]
Move the declaration from a local header to asm/ps3.h where it can be
seen from both the caller and the definition.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/powerpc/include/asm/ps3.h | 6 ++++++
arch/powerpc/platforms/ps3/gelic_udbg.c | 1 +
drivers/net/ethernet/toshiba/ps3_gelic_net.h | 6 ------
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
index a5f36546a052..d13d8fdc3411 100644
--- a/arch/powerpc/include/asm/ps3.h
+++ b/arch/powerpc/include/asm/ps3.h
@@ -514,4 +514,10 @@ u64 ps3_get_spe_id(void *arg);
void ps3_early_mm_init(void);
+#ifdef CONFIG_PPC_EARLY_DEBUG_PS3GELIC
+void udbg_shutdown_ps3gelic(void);
+#else
+static inline void udbg_shutdown_ps3gelic(void) {}
+#endif
+
#endif
diff --git a/arch/powerpc/platforms/ps3/gelic_udbg.c b/arch/powerpc/platforms/ps3/gelic_udbg.c
index 6b298010fd84..a5202c18c236 100644
--- a/arch/powerpc/platforms/ps3/gelic_udbg.c
+++ b/arch/powerpc/platforms/ps3/gelic_udbg.c
@@ -14,6 +14,7 @@
#include <linux/ip.h>
#include <linux/udp.h>
+#include <asm/ps3.h>
#include <asm/io.h>
#include <asm/udbg.h>
#include <asm/lv1call.h>
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.h b/drivers/net/ethernet/toshiba/ps3_gelic_net.h
index 0d98defb011e..0ec7412febc7 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.h
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.h
@@ -346,12 +346,6 @@ static inline void *port_priv(struct gelic_port *port)
return port->priv;
}
-#ifdef CONFIG_PPC_EARLY_DEBUG_PS3GELIC
-void udbg_shutdown_ps3gelic(void);
-#else
-static inline void udbg_shutdown_ps3gelic(void) {}
-#endif
-
int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask);
/* shared netdev ops */
void gelic_card_up(struct gelic_card *card);
--
2.39.2
^ permalink raw reply related
* [PATCH 18/22] powerpc: pasemi: mark pas_shutdown() static
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
Allmodconfig builds show a warning about one function that is accidentally
marked global:
arch/powerpc/platforms/pasemi/setup.c:67:6: error: no previous prototype for 'pas_shutdown' [-Werror=missing-prototypes]
Fixes: 656fdf3ad8e0 ("powerpc/pasemi: Add Nemo board device init code.")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/powerpc/platforms/pasemi/setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index ef985ba2bf21..0761d98e5be3 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -64,7 +64,7 @@ static void __noreturn pas_restart(char *cmd)
}
#ifdef CONFIG_PPC_PASEMI_NEMO
-void pas_shutdown(void)
+static void pas_shutdown(void)
{
/* Set the PLD bit that makes the SB600 think the power button is being pressed */
void __iomem *pld_map = ioremap(0xf5000000,4096);
--
2.39.2
^ permalink raw reply related
* [PATCH 19/22] powerpc: powermac: mark smp_psurge_{give,take}_timebase static
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
These functions are only called locally and should be static like the
other corresponding functions are:
arch/powerpc/platforms/powermac/smp.c:416:13: error: no previous prototype for 'smp_psurge_take_timebase' [-Werror=missing-prototypes]
416 | void __init smp_psurge_take_timebase(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/platforms/powermac/smp.c:432:13: error: no previous prototype for 'smp_psurge_give_timebase' [-Werror=missing-prototypes]
432 | void __init smp_psurge_give_timebase(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/powerpc/platforms/powermac/smp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index c83d1e14077e..15644be31990 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -413,7 +413,7 @@ static void __init smp_psurge_setup_cpu(int cpu_nr)
printk(KERN_ERR "Couldn't get primary IPI interrupt");
}
-void __init smp_psurge_take_timebase(void)
+static void __init smp_psurge_take_timebase(void)
{
if (psurge_type != PSURGE_DUAL)
return;
@@ -429,7 +429,7 @@ void __init smp_psurge_take_timebase(void)
set_dec(tb_ticks_per_jiffy/2);
}
-void __init smp_psurge_give_timebase(void)
+static void __init smp_psurge_give_timebase(void)
{
/* Nothing to do here */
}
--
2.39.2
^ permalink raw reply related
* [PATCH 20/22] usb: fsl-mph-dr-of: mark fsl_usb2_mpc5121_init() static
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
This function is only called locally and should always have been static:
drivers/usb/host/fsl-mph-dr-of.c:291:5: error: no previous prototype for 'fsl_usb2_mpc5121_init' [-Werror=missing-prototypes]
Fixes: 230f7ede6c2f ("USB: add USB EHCI support for MPC5121 SoC")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/usb/host/fsl-mph-dr-of.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 8508d37a2aff..6cdc3d805c32 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -288,7 +288,7 @@ static void fsl_usb2_mph_dr_of_remove(struct platform_device *ofdev)
#define PHYCTRL_LSFE (1 << 1) /* Line State Filter Enable */
#define PHYCTRL_PXE (1 << 0) /* PHY oscillator enable */
-int fsl_usb2_mpc5121_init(struct platform_device *pdev)
+static int fsl_usb2_mpc5121_init(struct platform_device *pdev)
{
struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct clk *clk;
--
2.39.2
^ permalink raw reply related
* [PATCH 21/22] fbdev/fsl-diu-fb: mark wr_reg_wa() static
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
wr_reg_wa() is not an appropriate name for a global function, and doesn't need
to be global anyway, so mark it static and avoid the warning:
drivers/video/fbdev/fsl-diu-fb.c:493:6: error: no previous prototype for 'wr_reg_wa' [-Werror=missing-prototypes]
Fixes: 0d9dab39fbbe ("powerpc/5121: fsl-diu-fb: fix issue with re-enabling DIU area descriptor")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/video/fbdev/fsl-diu-fb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c
index 7fbd9f069ac2..0bced82fa494 100644
--- a/drivers/video/fbdev/fsl-diu-fb.c
+++ b/drivers/video/fbdev/fsl-diu-fb.c
@@ -490,7 +490,7 @@ static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s)
* Workaround for failed writing desc register of planes.
* Needed with MPC5121 DIU rev 2.0 silicon.
*/
-void wr_reg_wa(u32 *reg, u32 val)
+static void wr_reg_wa(u32 *reg, u32 val)
{
do {
out_be32(reg, val);
--
2.39.2
^ permalink raw reply related
* Re: [PATCH net v1] net/smc: avoid data corruption caused by decline
From: Wenjia Zhang @ 2023-11-08 13:00 UTC (permalink / raw)
To: D. Wythe, kgraul, jaka, wintera
Cc: kuba, davem, netdev, linux-s390, linux-rdma
In-Reply-To: <1699436909-22767-1-git-send-email-alibuda@linux.alibaba.com>
On 08.11.23 10:48, D. Wythe wrote:
> From: "D. Wythe" <alibuda@linux.alibaba.com>
>
> We found a data corruption issue during testing of SMC-R on Redis
> applications.
>
> The benchmark has a low probability of reporting a strange error as
> shown below.
>
> "Error: Protocol error, got "\xe2" as reply type byte"
>
> Finally, we found that the retrieved error data was as follows:
>
> 0xE2 0xD4 0xC3 0xD9 0x04 0x00 0x2C 0x20 0xA6 0x56 0x00 0x16 0x3E 0x0C
> 0xCB 0x04 0x02 0x01 0x00 0x00 0x20 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xE2
>
> It is quite obvious that this is a SMC DECLINE message, which means that
> the applications received SMC protocol message.
> We found that this was caused by the following situations:
>
> client server
> proposal
> ------------->
> accept
> <-------------
> confirm
> ------------->
> wait confirm
>
> failed llc confirm
> x------
> (after 2s)timeout
> wait rsp
>
> wait decline
>
> (after 1s) timeout
> (after 2s) timeout
> decline
> -------------->
> decline
> <--------------
>
> As a result, a decline message was sent in the implementation, and this
> message was read from TCP by the already-fallback connection.
>
> This patch double the client timeout as 2x of the server value,
> With this simple change, the Decline messages should never cross or
> collide (during Confirm link timeout).
>
> This issue requires an immediate solution, since the protocol updates
> involve a more long-term solution.
>
> Fixes: 0fb0b02bd6fd ("net/smc: adapt SMC client code to use the LLC flow")
> Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
> ---
> net/smc/af_smc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index abd2667..5b91f55 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -599,7 +599,7 @@ static int smcr_clnt_conf_first_link(struct smc_sock *smc)
> int rc;
>
> /* receive CONFIRM LINK request from server over RoCE fabric */
> - qentry = smc_llc_wait(link->lgr, NULL, SMC_LLC_WAIT_TIME,
> + qentry = smc_llc_wait(link->lgr, NULL, 2 * SMC_LLC_WAIT_TIME,
> SMC_LLC_CONFIRM_LINK);
> if (!qentry) {
> struct smc_clc_msg_decline dclc;
I'm wondering if the double time (if sufficient) of timeout could be for
waiting for CLC_DECLINE on the client's side. i.e.
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 35ddebae8894..9b1feef1013d 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -605,7 +605,7 @@ static int smcr_clnt_conf_first_link(struct smc_sock
*smc)
struct smc_clc_msg_decline dclc;
rc = smc_clc_wait_msg(smc, &dclc, sizeof(dclc),
- SMC_CLC_DECLINE, CLC_WAIT_TIME_SHORT);
+ SMC_CLC_DECLINE, 2 *
CLC_WAIT_TIME_SHORT);
return rc == -EAGAIN ? SMC_CLC_DECL_TIMEOUT_CL : rc;
}
smc_llc_save_peer_uid(qentry);
Because the purpose is to let the server have the control to deline.
^ permalink raw reply related
* [PATCH 22/22] Makefile.extrawarn: turn on missing-prototypes globally
From: Arnd Bergmann @ 2023-11-08 12:58 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Masahiro Yamada, linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Geoff Levand, Palmer Dabbelt, Heiko Carstens,
John Paul Adrian Glaubitz, David S. Miller, Andy Lutomirski,
Thomas Gleixner, Ingo Molnar, x86, Helge Deller, Sudip Mukherjee,
Greg Kroah-Hartman, Timur Tabi, Kent Overstreet, David Woodhouse,
Naveen N. Rao, Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino,
Juri Lelli, Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd,
Richard Henderson, Ivan Kokshaysky, Yoshinori Sato, Rich Felker,
Palmer Dabbelt
In-Reply-To: <20231108125843.3806765-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
Over the years we went from > 1000 of warnings to under 100 earlier
this year, and I sent patches to address all the ones that I saw with
compile testing randcom configs on arm64, arm and x86 kernels. This is a
really useful warning, as it catches real bugs when there are mismatched
prototypes. In particular with kernel control flow integrity enabled,
those are no longer allowed.
I have done extensive testing to ensure that there are no new build
errors or warnings on any configuration of x86, arm and arm64 builds.
I also made sure that at least the both the normal defconfig and an
allmodconfig build is clean for arc, csky, loongarch, m68k, microblaze,
openrisc, parisc, powerpc, riscv, s390, and xtensa, with the respective
maintainers doing most of the patches.
At this point, there are five architectures with a number of known
regressions: alpha, nios2, mips, sh and sparc. In the previous version
of this patch, I had turned off the missing prototype warnings for the 15
architectures that still had issues, but since there are only five left,
I think we can leave the rest to the maintainers (Cc'd here) as well.
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-alpha@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Link: https://lore.kernel.org/lkml/20230810141947.1236730-1-arnd@kernel.org/
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
| 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 2fe6f2828d37..c9725685aa76 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -17,6 +17,8 @@ KBUILD_CFLAGS += -Wno-format-security
KBUILD_CFLAGS += -Wno-trigraphs
KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+KBUILD_CFLAGS += -Wmissing-declarations
+KBUILD_CFLAGS += -Wmissing-prototypes
ifneq ($(CONFIG_FRAME_WARN),0)
KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
@@ -95,10 +97,8 @@ export KBUILD_EXTRA_WARN
ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
-KBUILD_CFLAGS += -Wmissing-declarations
KBUILD_CFLAGS += $(call cc-option, -Wrestrict)
KBUILD_CFLAGS += -Wmissing-format-attribute
-KBUILD_CFLAGS += -Wmissing-prototypes
KBUILD_CFLAGS += -Wold-style-definition
KBUILD_CFLAGS += -Wmissing-include-dirs
KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
--
2.39.2
^ permalink raw reply related
* Re: [ANN] netdev development stats for 6.7
From: Andrew Lunn @ 2023-11-08 13:19 UTC (permalink / raw)
To: Hangbin Liu
Cc: Jakub Kicinski, netdev, netdev-driver-reviewers,
Stanislav Fomichev, Simon Horman,
Toke Høiland-Jørgensen
In-Reply-To: <ZUt9n0gwZR0kaKdF@Laptop-X1>
On Wed, Nov 08, 2023 at 08:22:55PM +0800, Hangbin Liu wrote:
> Hi Jakub,
> On Wed, Nov 01, 2023 at 04:29:06PM -0700, Jakub Kicinski wrote:
> > Top reviewers (thr): Top reviewers (msg):
> > 1 ( +2) [42] RedHat 1 ( +2) [71] RedHat
> > 2 ( ) [27] Meta 2 ( -1) [52] Meta
> > 3 ( +2) [23] Intel 3 ( +2) [46] Intel
> > 4 ( +2) [15] Google 4 ( +2) [33] Andrew Lunn
> > 5 ( -1) [12] nVidia 5 ( +2) [29] Google
> > 6 ( +1) [12] Andrew Lunn 6 ( -2) [23] nVidia
> > 7 ( +3) [ 7] Enfabrica 7 ( +4) [14] Broadcom
>
> I just noticed this stats report from Simon. Thanks for your work and
> sharing. I want to know if there is a way to bind my personal email
> with my company so my review could increase my company's score :)
Jonathan Corbet <corbet@lwn.net> maintains a list of email addresses
to organisations mapping. Let him know who you work for and the next
cycle you should count to your company.
Andrew
^ permalink raw reply
* pull-request: bpf 2023-11-08
From: Daniel Borkmann @ 2023-11-08 13:24 UTC (permalink / raw)
To: davem; +Cc: kuba, pabeni, edumazet, daniel, ast, andrii, martin.lau, netdev,
bpf
Hi David, hi Jakub, hi Paolo, hi Eric,
The following pull-request contains BPF updates for your *net* tree.
We've added 16 non-merge commits during the last 6 day(s) which contain
a total of 30 files changed, 341 insertions(+), 130 deletions(-).
The main changes are:
1) Fix a BPF verifier issue in precision tracking for BPF_ALU | BPF_TO_BE |
BPF_END where the source register was incorrectly marked as precise,
from Shung-Hsi Yu.
2) Fix a concurrency issue in bpf_timer where the former could still have
been alive after an application releases or unpins the map, from Hou Tao.
3) Fix a BPF verifier issue where immediates are incorrectly cast to u32
before being spilled and therefore losing sign information, from Hao Sun.
4) Fix a misplaced BPF_TRACE_ITER in check_css_task_iter_allowlist which
incorrectly compared bpf_prog_type with bpf_attach_type, from Chuyi Zhou.
5) Add __bpf_hook_{start,end} as well as __bpf_kfunc_{start,end}_defs macros,
migrate all BPF-related __diag callsites over to it, and add a new
__diag_ignore_all for -Wmissing-declarations to the macros to address
recent build warnings, from Dave Marchevsky.
6) Fix broken BPF selftest build of xdp_hw_metadata test on architectures
where char is not signed, from Björn Töpel.
7) Fix test_maps selftest to properly use LIBBPF_OPTS() macro to initialize
the bpf_map_create_opts, from Andrii Nakryiko.
8) Fix bpffs selftest to avoid unmounting /sys/kernel/debug as it may have
been mounted and used by other applications already, from Manu Bretelle.
9) Fix a build issue without CONFIG_CGROUPS wrt css_task open-coded
iterators, from Matthieu Baerts.
Please consider pulling these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git tags/for-netdev
Thanks a lot!
Also thanks to reporters, reviewers and testers of commits in this pull-request:
Anders Roxell, Andrii Nakryiko, David Vernet, Eduard Zingerman, Hsin-Wei
Hung, Jiri Olsa, kernel test robot, Larysa Zaremba, Mohamed Mahmoud,
Shung-Hsi Yu, Tao Lyu, Toke Høiland-Jørgensen, Yafang Shao, Yonghong Song
----------------------------------------------------------------
The following changes since commit 2b7ac0c87d985c92e519995853c52b9649ea4b07:
tools: ynl-gen: don't touch the output file if content is the same (2023-11-01 22:14:00 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git tags/for-netdev
for you to fetch changes up to 8e1b802503bb630eafc3e97b2daf755368ec96e1:
Merge branch 'Let BPF verifier consider {task,cgroup} is trusted in bpf_iter_reg' (2023-11-07 15:28:06 -0800)
----------------------------------------------------------------
bpf-for-netdev
----------------------------------------------------------------
Alexei Starovoitov (3):
Merge branch 'bpf-fix-incorrect-immediate-spill'
Merge branch 'relax-allowlist-for-open-coded-css_task-iter'
Merge branch 'bpf-fix-precision-tracking-for-bpf_alu-bpf_to_be-bpf_end'
Andrii Nakryiko (1):
selftests/bpf: fix test_maps' use of bpf_map_create_opts
Björn Töpel (1):
selftests/bpf: Fix broken build where char is unsigned
Chuyi Zhou (5):
bpf: Relax allowlist for css_task iter
selftests/bpf: Add tests for css_task iter combining with cgroup iter
selftests/bpf: Add test for using css_task iter in sleepable progs
bpf: Let verifier consider {task,cgroup} is trusted in bpf_iter_reg
selftests/bpf: get trusted cgrp from bpf_iter__cgroup directly
Dave Marchevsky (2):
bpf: Add __bpf_kfunc_{start,end}_defs macros
bpf: Add __bpf_hook_{start,end} macros
Hao Sun (2):
bpf: Fix check_stack_write_fixed_off() to correctly spill imm
selftests/bpf: Add test for immediate spilled to stack
Hou Tao (1):
bpf: Check map->usercnt after timer->timer is assigned
Manu Bretelle (1):
selftests/bpf: fix test_bpffs
Martin KaFai Lau (1):
Merge branch 'Let BPF verifier consider {task,cgroup} is trusted in bpf_iter_reg'
Matthieu Baerts (1):
bpf: fix compilation error without CGROUPS
Shung-Hsi Yu (2):
bpf: Fix precision tracking for BPF_ALU | BPF_TO_BE | BPF_END
selftests/bpf: precision tracking test for BPF_NEG and BPF_END
Documentation/bpf/kfuncs.rst | 6 +-
include/linux/btf.h | 11 +++
kernel/bpf/bpf_iter.c | 6 +-
kernel/bpf/cgroup_iter.c | 8 +-
kernel/bpf/cpumask.c | 6 +-
kernel/bpf/helpers.c | 39 +++++----
kernel/bpf/map_iter.c | 6 +-
kernel/bpf/task_iter.c | 24 +++---
kernel/bpf/verifier.c | 33 ++++++--
kernel/cgroup/rstat.c | 9 +--
kernel/trace/bpf_trace.c | 6 +-
net/bpf/test_run.c | 7 +-
net/core/filter.c | 13 +--
net/core/xdp.c | 6 +-
net/ipv4/fou_bpf.c | 6 +-
net/netfilter/nf_conntrack_bpf.c | 6 +-
net/netfilter/nf_nat_bpf.c | 6 +-
net/socket.c | 8 +-
net/xfrm/xfrm_interface_bpf.c | 6 +-
.../selftests/bpf/bpf_testmod/bpf_testmod.c | 6 +-
.../selftests/bpf/map_tests/map_percpu_stats.c | 20 ++---
.../testing/selftests/bpf/prog_tests/cgroup_iter.c | 33 ++++++++
tools/testing/selftests/bpf/prog_tests/iters.c | 1 +
.../testing/selftests/bpf/prog_tests/test_bpffs.c | 11 ++-
tools/testing/selftests/bpf/prog_tests/verifier.c | 2 +
tools/testing/selftests/bpf/progs/iters_css_task.c | 55 +++++++++++++
.../selftests/bpf/progs/iters_task_failure.c | 4 +-
.../selftests/bpf/progs/verifier_precision.c | 93 ++++++++++++++++++++++
tools/testing/selftests/bpf/verifier/bpf_st_mem.c | 32 ++++++++
tools/testing/selftests/bpf/xdp_hw_metadata.c | 2 +-
30 files changed, 341 insertions(+), 130 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/verifier_precision.c
^ permalink raw reply
* Re: [PATCH net-next v8 5/7] net: phy: nxp-c45-tja11xx: add MACsec support
From: Radu Pirea (OSS) @ 2023-11-08 13:50 UTC (permalink / raw)
To: Sabrina Dubroca
Cc: davem, edumazet, kuba, pabeni, andrew, hkallweit1, linux,
richardcochran, linux-kernel, netdev, sebastian.tobuschat
In-Reply-To: <ZTuE99jyr9gW3O1S@hog>
On 27.10.2023 12:37, Sabrina Dubroca wrote:
>> +static int nxp_c45_mdo_add_secy(struct macsec_context *ctx)
>> +{
> [...]
>> + phy_secy = kzalloc(sizeof(*phy_secy), GFP_KERNEL);
>> + if (!phy_secy)
>> + return -ENOMEM;
>> +
>> + INIT_LIST_HEAD(&phy_secy->sa_list);
>> + phy_secy->secy = ctx->secy;
>> + phy_secy->secy_id = idx;
>> +
>> + /* If the point to point mode should be enabled, we should have only
>> + * one SecY enabled, respectively the new one.
>> + */
>> + can_rx_sc0_impl = list_count_nodes(&priv->macsec->secy_list) == 0;
>> + if (!nxp_c45_secy_valid(phy_secy, can_rx_sc0_impl)) {
>> + kfree_sensitive(phy_secy);
>
> kfree is enough here, no keying information has been stored in
> phy_secy.
Agreed. No key is stored in the driver. Changed kfree_sensitive calls to
kfree calls.
>
>> + return -EINVAL;
>> + }
>> +
>> + nxp_c45_select_secy(phydev, phy_secy->secy_id);
>> + nxp_c45_set_sci(phydev, MACSEC_TXSC_SCI_1H, ctx->secy->sci);
>> + nxp_c45_tx_sc_set_flt(phydev, phy_secy);
>> + nxp_c45_tx_sc_update(phydev, phy_secy);
>> + if (phy_interrupt_is_valid(phydev))
>> + nxp_c45_secy_irq_en(phydev, phy_secy, true);
>
> Can macsec be used reliably in case we skip enabling the IRQ?
>
IMO yes. macsec_pn_wrapped will not be called anymore if the TX PN
overflows and no frame will go out via controlled port reusing the PNs,
but this should not be an issue. The MKA should not wait until
macsec_pn_wrapped is called and should change the keys before the PN
overflow happens.
--
Radu P.
^ permalink raw reply
* Re: [PATCH v9 bpf-next 02/17] bpf: add BPF token delegation mount options to BPF FS
From: Christian Brauner @ 2023-11-08 13:51 UTC (permalink / raw)
To: Andrii Nakryiko
Cc: bpf, netdev, paul, linux-fsdevel, linux-security-module, keescook,
kernel-team, sargun
In-Reply-To: <20231103190523.6353-3-andrii@kernel.org>
On Fri, Nov 03, 2023 at 12:05:08PM -0700, Andrii Nakryiko wrote:
> Add few new mount options to BPF FS that allow to specify that a given
> BPF FS instance allows creation of BPF token (added in the next patch),
> and what sort of operations are allowed under BPF token. As such, we get
> 4 new mount options, each is a bit mask
> - `delegate_cmds` allow to specify which bpf() syscall commands are
> allowed with BPF token derived from this BPF FS instance;
> - if BPF_MAP_CREATE command is allowed, `delegate_maps` specifies
> a set of allowable BPF map types that could be created with BPF token;
> - if BPF_PROG_LOAD command is allowed, `delegate_progs` specifies
> a set of allowable BPF program types that could be loaded with BPF token;
> - if BPF_PROG_LOAD command is allowed, `delegate_attachs` specifies
> a set of allowable BPF program attach types that could be loaded with
> BPF token; delegate_progs and delegate_attachs are meant to be used
> together, as full BPF program type is, in general, determined
> through both program type and program attach type.
>
> Currently, these mount options accept the following forms of values:
> - a special value "any", that enables all possible values of a given
> bit set;
> - numeric value (decimal or hexadecimal, determined by kernel
> automatically) that specifies a bit mask value directly;
> - all the values for a given mount option are combined, if specified
> multiple times. E.g., `mount -t bpf nodev /path/to/mount -o
> delegate_maps=0x1 -o delegate_maps=0x2` will result in a combined 0x3
> mask.
>
> Ideally, more convenient (for humans) symbolic form derived from
> corresponding UAPI enums would be accepted (e.g., `-o
> delegate_progs=kprobe|tracepoint`) and I intend to implement this, but
> it requires a bunch of UAPI header churn, so I postponed it until this
> feature lands upstream or at least there is a definite consensus that
> this feature is acceptable and is going to make it, just to minimize
> amount of wasted effort and not increase amount of non-essential code to
> be reviewed.
>
> Attentive reader will notice that BPF FS is now marked as
> FS_USERNS_MOUNT, which theoretically makes it mountable inside non-init
> user namespace as long as the process has sufficient *namespaced*
> capabilities within that user namespace. But in reality we still
> restrict BPF FS to be mountable only by processes with CAP_SYS_ADMIN *in
> init userns* (extra check in bpf_fill_super()). FS_USERNS_MOUNT is added
> to allow creating BPF FS context object (i.e., fsopen("bpf")) from
> inside unprivileged process inside non-init userns, to capture that
> userns as the owning userns. It will still be required to pass this
> context object back to privileged process to instantiate and mount it.
>
> This manipulation is important, because capturing non-init userns as the
> owning userns of BPF FS instance (super block) allows to use that userns
> to constraint BPF token to that userns later on (see next patch). So
> creating BPF FS with delegation inside unprivileged userns will restrict
> derived BPF token objects to only "work" inside that intended userns,
> making it scoped to a intended "container".
>
> There is a set of selftests at the end of the patch set that simulates
> this sequence of steps and validates that everything works as intended.
> But careful review is requested to make sure there are no missed gaps in
> the implementation and testing.
>
> All this is based on suggestions and discussions with Christian Brauner
> ([0]), to the best of my ability to follow all the implications.
"who will not be held responsible for any CVE future or present as he's
not sure whether bpf token is a good idea in general"
I'm not opposing it because it's really not my subsystem. But it'd be
nice if you also added a disclaimer that I'm not endorsing this. :)
A comment below.
>
> [0] https://lore.kernel.org/bpf/20230704-hochverdient-lehne-eeb9eeef785e@brauner/
>
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> ---
> include/linux/bpf.h | 10 ++++++
> kernel/bpf/inode.c | 88 +++++++++++++++++++++++++++++++++++++++------
> 2 files changed, 88 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index b4825d3cdb29..df50a7bf1a77 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -1562,6 +1562,16 @@ struct bpf_link_primer {
> u32 id;
> };
>
> +struct bpf_mount_opts {
> + umode_t mode;
> +
> + /* BPF token-related delegation options */
> + u64 delegate_cmds;
> + u64 delegate_maps;
> + u64 delegate_progs;
> + u64 delegate_attachs;
> +};
> +
> struct bpf_struct_ops_value;
> struct btf_member;
>
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index 1aafb2ff2e95..e49e93bc65e3 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -20,6 +20,7 @@
> #include <linux/filter.h>
> #include <linux/bpf.h>
> #include <linux/bpf_trace.h>
> +#include <linux/kstrtox.h>
> #include "preload/bpf_preload.h"
>
> enum bpf_type {
> @@ -599,10 +600,31 @@ EXPORT_SYMBOL(bpf_prog_get_type_path);
> */
> static int bpf_show_options(struct seq_file *m, struct dentry *root)
> {
> + struct bpf_mount_opts *opts = root->d_sb->s_fs_info;
> umode_t mode = d_inode(root)->i_mode & S_IALLUGO & ~S_ISVTX;
>
> if (mode != S_IRWXUGO)
> seq_printf(m, ",mode=%o", mode);
> +
> + if (opts->delegate_cmds == ~0ULL)
> + seq_printf(m, ",delegate_cmds=any");
> + else if (opts->delegate_cmds)
> + seq_printf(m, ",delegate_cmds=0x%llx", opts->delegate_cmds);
> +
> + if (opts->delegate_maps == ~0ULL)
> + seq_printf(m, ",delegate_maps=any");
> + else if (opts->delegate_maps)
> + seq_printf(m, ",delegate_maps=0x%llx", opts->delegate_maps);
> +
> + if (opts->delegate_progs == ~0ULL)
> + seq_printf(m, ",delegate_progs=any");
> + else if (opts->delegate_progs)
> + seq_printf(m, ",delegate_progs=0x%llx", opts->delegate_progs);
> +
> + if (opts->delegate_attachs == ~0ULL)
> + seq_printf(m, ",delegate_attachs=any");
> + else if (opts->delegate_attachs)
> + seq_printf(m, ",delegate_attachs=0x%llx", opts->delegate_attachs);
> return 0;
> }
>
> @@ -626,22 +648,27 @@ static const struct super_operations bpf_super_ops = {
>
> enum {
> OPT_MODE,
> + OPT_DELEGATE_CMDS,
> + OPT_DELEGATE_MAPS,
> + OPT_DELEGATE_PROGS,
> + OPT_DELEGATE_ATTACHS,
> };
>
> static const struct fs_parameter_spec bpf_fs_parameters[] = {
> fsparam_u32oct ("mode", OPT_MODE),
> + fsparam_string ("delegate_cmds", OPT_DELEGATE_CMDS),
> + fsparam_string ("delegate_maps", OPT_DELEGATE_MAPS),
> + fsparam_string ("delegate_progs", OPT_DELEGATE_PROGS),
> + fsparam_string ("delegate_attachs", OPT_DELEGATE_ATTACHS),
> {}
> };
>
> -struct bpf_mount_opts {
> - umode_t mode;
> -};
> -
> static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
> {
> - struct bpf_mount_opts *opts = fc->fs_private;
> + struct bpf_mount_opts *opts = fc->s_fs_info;
> struct fs_parse_result result;
> - int opt;
> + int opt, err;
> + u64 msk;
>
> opt = fs_parse(fc, bpf_fs_parameters, param, &result);
> if (opt < 0) {
> @@ -665,6 +692,25 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
> case OPT_MODE:
> opts->mode = result.uint_32 & S_IALLUGO;
> break;
> + case OPT_DELEGATE_CMDS:
> + case OPT_DELEGATE_MAPS:
> + case OPT_DELEGATE_PROGS:
> + case OPT_DELEGATE_ATTACHS:
> + if (strcmp(param->string, "any") == 0) {
> + msk = ~0ULL;
> + } else {
> + err = kstrtou64(param->string, 0, &msk);
> + if (err)
> + return err;
> + }
> + switch (opt) {
> + case OPT_DELEGATE_CMDS: opts->delegate_cmds |= msk; break;
> + case OPT_DELEGATE_MAPS: opts->delegate_maps |= msk; break;
> + case OPT_DELEGATE_PROGS: opts->delegate_progs |= msk; break;
> + case OPT_DELEGATE_ATTACHS: opts->delegate_attachs |= msk; break;
> + default: return -EINVAL;
> + }
> + break;
> }
So just to repeat that this will allow a container to set it's own
delegation options:
# unprivileged container
fd_fs = fsopen();
fsconfig(fd_fs, FSCONFIG_BLA_BLA, "give-me-all-the-delegation");
# Now hand of that fd_fs to a privileged process
fsconfig(fd_fs, FSCONFIG_CREATE_CMD, ...)
This means the container manager can't be part of your threat model
because you need to trust it to set delegation options.
But if the container manager is part of your threat model then you can
never trust an fd_fs handed to you because the container manager might
have enabled arbitrary delegation privileges.
There's ways around this:
(1) kernel: Account for this in the kernel and require privileges when
setting delegation options.
(2) userspace: A trusted helper that allocates an fs_context fd in
the target user namespace, then sets delegation options and creates
superblock.
(1) Is more restrictive but also more secure. (2) is less restrictive
but requires more care from userspace.
Either way I would probably consider writing a document detailing
various delegation scenarios and possible pitfalls and implications
before advertising it.
If you choose (2) then you also need to be aware that the security of
this also hinges on bpffs not allowing to reconfigure parameters once it
has been mounted. Otherwise an unprivileged container can change
delegation options.
I would recommend that you either add a dummy bpf_reconfigure() method
with a comment in it or you add a comment on top of bpf_context_ops.
Something like:
/*
* Unprivileged mounts of bpffs are owned by the user namespace they are
* mounted in. That means unprivileged users can change vfs mount
* options (ro<->rw, nosuid, etc.).
*
* They currently cannot change bpffs specific mount options such as
* delegation settings. If that is ever implemented it is necessary to
* require rivileges in the initial namespace. Otherwise unprivileged
* users can change delegation options to whatever they want.
*/
^ permalink raw reply
* Re: [PATCH] Documentation: Document the Netlink spec
From: Donald Hunter @ 2023-11-08 14:03 UTC (permalink / raw)
To: Breno Leitao; +Cc: corbet, linux-doc, netdev, kuba, pabeni, edumazet
In-Reply-To: <20231103135622.250314-1-leitao@debian.org>
Breno Leitao <leitao@debian.org> writes:
> This is a Sphinx extension that parses the Netlink YAML spec files
> (Documentation/netlink/specs/), and generates a rst file to be
> displayed into Documentation pages.
>
> Create a new Documentation/networking/netlink_spec page, and a sub-page
> for each Netlink spec that needs to be documented, such as ethtool,
> devlink, netdev, etc.
>
> Create a Sphinx directive extension that reads the YAML spec
> (located under Documentation/netlink/specs), parses it and returns a RST
> string that is inserted where the Sphinx directive was called.
This is great! Looks like I need to fill in some missing docs in the
specs I have contributed.
I wonder if the generated .rst content can be adjusted to improve the
resulting HTML.
There are a couple of places where paragraph text is indented and I
don't think it needs to be, e.g. the 'Summary' doc.
A lot of the .rst content seems to be over-indented which causes
blockquote tags to be generated in the HTML. That combined with a
mixture of bullets and definition lists at the same indentation level
seems to produce HTML with inconsistent indentation.
I quickly hacked the diff below to see if it would improve the HTML
rendering. I think the HTML has fewer odd constructs and the indentation
seems better to my eye. My main aim was to ensure that for a given
section, each indentation level uses the same construct, whether it be a
definition list or a bullet list.
It would be great to generate links from e.g. an attribute-set to its
definition.
Did you intentionally leave out the protocol values?
It looks like parse_entries will need to be extended to include the type
information for struct members, similar to how attribute sets are shown.
I'd be happy to look at this as a follow up patch, unless you get there
first.
Thanks,
Donald.
diff --git a/Documentation/sphinx/netlink_spec.py b/Documentation/sphinx/netlink_spec.py
index 80756e72ed4f..66ba9106b4ea 100755
--- a/Documentation/sphinx/netlink_spec.py
+++ b/Documentation/sphinx/netlink_spec.py
@@ -92,7 +92,7 @@ def parse_mcast_group(mcast_group: List[Dict[str, Any]]) -> str:
"""Parse 'multicast' group list and return a formatted string"""
lines = []
for group in mcast_group:
- lines.append(rst_paragraph(group["name"], 1))
+ lines.append(rst_bullet(group["name"]))
return "\n".join(lines)
@@ -101,7 +101,7 @@ def parse_do(do_dict: Dict[str, Any], level: int = 0) -> str:
"""Parse 'do' section and return a formatted string"""
lines = []
for key in do_dict.keys():
- lines.append(rst_bullet(bold(key), level + 1))
+ lines.append(" " + bold(key))
lines.append(parse_do_attributes(do_dict[key], level + 1) + "\n")
return "\n".join(lines)
@@ -124,18 +124,19 @@ def parse_operations(operations: List[Dict[str, Any]]) -> str:
for operation in operations:
lines.append(rst_subsubtitle(operation["name"]))
lines.append(rst_paragraph(operation["doc"]) + "\n")
- if "do" in operation:
- lines.append(rst_paragraph(bold("do"), 1))
- lines.append(parse_do(operation["do"], 1))
- if "dump" in operation:
- lines.append(rst_paragraph(bold("dump"), 1))
- lines.append(parse_do(operation["dump"], 1))
for key in operation.keys():
if key in preprocessed:
# Skip the special fields
continue
- lines.append(rst_fields(key, operation[key], 1))
+ lines.append(rst_fields(key, operation[key], 0))
+
+ if "do" in operation:
+ lines.append(rst_paragraph(":do:", 0))
+ lines.append(parse_do(operation["do"], 0))
+ if "dump" in operation:
+ lines.append(rst_paragraph(":dump:", 0))
+ lines.append(parse_do(operation["dump"], 0))
# New line after fields
lines.append("\n")
@@ -150,7 +151,7 @@ def parse_entries(entries: List[Dict[str, Any]], level: int) -> str:
if isinstance(entry, dict):
# entries could be a list or a dictionary
lines.append(
- rst_fields(entry.get("name"), sanitize(entry.get("doc")), level)
+ rst_fields(entry.get("name"), sanitize(entry.get("doc") or ""), level)
)
elif isinstance(entry, list):
lines.append(rst_list_inline(entry, level))
@@ -172,16 +173,16 @@ def parse_definitions(defs: Dict[str, Any]) -> str:
for k in definition.keys():
if k in preprocessed + ignored:
continue
- lines.append(rst_fields(k, sanitize(definition[k]), 1))
+ lines.append(rst_fields(k, sanitize(definition[k]), 0))
# Field list needs to finish with a new line
lines.append("\n")
if "entries" in definition:
- lines.append(rst_paragraph(bold("Entries"), 1))
- lines.append(parse_entries(definition["entries"], 2))
+ lines.append(rst_paragraph(":entries:", 0))
+ lines.append(parse_entries(definition["entries"], 1))
if "members" in definition:
- lines.append(rst_paragraph(bold("members"), 1))
- lines.append(parse_entries(definition["members"], 2))
+ lines.append(rst_paragraph(":members:", 0))
+ lines.append(parse_entries(definition["members"], 1))
return "\n".join(lines)
@@ -201,12 +202,12 @@ def parse_attributes_set(entries: List[Dict[str, Any]]) -> str:
# Add the attribute type in the same line
attr_line += f" ({inline(type_)})"
- lines.append(rst_bullet(attr_line, 2))
+ lines.append(rst_bullet(attr_line, 1))
for k in attr.keys():
if k in preprocessed + ignored:
continue
- lines.append(rst_fields(k, sanitize(attr[k]), 3))
+ lines.append(rst_fields(k, sanitize(attr[k]), 2))
lines.append("\n")
return "\n".join(lines)
@@ -218,7 +219,7 @@ def parse_yaml(obj: Dict[str, Any]) -> str:
# This is coming from the RST
lines.append(rst_subtitle("Summary"))
- lines.append(rst_paragraph(obj["doc"], 1))
+ lines.append(rst_paragraph(obj["doc"], 0))
# Operations
lines.append(rst_subtitle("Operations"))
^ permalink raw reply related
* Re: [PATCH] Documentation: Document the Netlink spec
From: Donald Hunter @ 2023-11-08 14:08 UTC (permalink / raw)
To: Breno Leitao; +Cc: corbet, linux-doc, netdev, kuba, pabeni, edumazet
In-Reply-To: <m2y1f8mjex.fsf@gmail.com>
Donald Hunter <donald.hunter@gmail.com> writes:
>
> I quickly hacked the diff below to see if it would improve the HTML
> rendering. I think the HTML has fewer odd constructs and the indentation
> seems better to my eye. My main aim was to ensure that for a given
> section, each indentation level uses the same construct, whether it be a
> definition list or a bullet list.
Or what Jakub said, use more (sub)+titles and fewer bullet lists.
^ permalink raw reply
* Re: [PATCH 17/22] powerpc: ps3: move udbg_shutdown_ps3gelic prototype
From: Geoff Levand @ 2023-11-08 14:18 UTC (permalink / raw)
To: Arnd Bergmann, Andrew Morton, linux-kernel, Masahiro Yamada,
linux-kbuild
Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
Catalin Marinas, Will Deacon, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Guo Ren, Peter Zijlstra, Ard Biesheuvel,
Huacai Chen, Greg Ungerer, Michal Simek, Thomas Bogendoerfer,
Dinh Nguyen, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Palmer Dabbelt, Heiko Carstens, John Paul Adrian Glaubitz,
David S. Miller, Andy Lutomirski, Thomas Gleixner, Ingo Molnar,
x86, Helge Deller, Sudip Mukherjee, Greg Kroah-Hartman,
Timur Tabi, Kent Overstreet, David Woodhouse, Naveen N. Rao,
Anil S Keshavamurthy, Kees Cook, Vincenzo Frascino, Juri Lelli,
Vincent Guittot, Nathan Chancellor, Nick Desaulniers,
Nicolas Schier, Al Viro, Uwe Kleine-König, linux-alpha,
linux-snps-arc, linux-arm-kernel, linux-trace-kernel, linux-csky,
loongarch, linux-m68k, linux-mips, linuxppc-dev, linux-riscv,
linux-s390, linux-sh, sparclinux, netdev, linux-parisc, linux-usb,
linux-fbdev, dri-devel, linux-bcachefs, linux-mtd
In-Reply-To: <20231108125843.3806765-18-arnd@kernel.org>
Hi Arnd,
On 11/8/23 12:58, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Allmodconfig kernels produce a missing-prototypes warning:
>
> arch/powerpc/platforms/ps3/gelic_udbg.c:239:6: error: no previous prototype for 'udbg_shutdown_ps3gelic' [-Werror=missing-prototypes]
>
> Move the declaration from a local header to asm/ps3.h where it can be
> seen from both the caller and the definition.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/powerpc/include/asm/ps3.h | 6 ++++++
> arch/powerpc/platforms/ps3/gelic_udbg.c | 1 +
> drivers/net/ethernet/toshiba/ps3_gelic_net.h | 6 ------
> 3 files changed, 7 insertions(+), 6 deletions(-)
Seems good to me. I'll test it next chance I get.
Signed-off-by: Geoff Levand <geoff@infradead.org>
^ permalink raw reply
* Re: [PATCH] boning: use a read-write lock in bonding_show_bonds()
From: Eric Dumazet @ 2023-11-08 14:19 UTC (permalink / raw)
To: Haifeng Xu; +Cc: j.vosburgh, andy, davem, kuba, pabeni, netdev, linux-kernel
In-Reply-To: <20231108064641.65209-1-haifeng.xu@shopee.com>
On Wed, Nov 8, 2023 at 7:47 AM Haifeng Xu <haifeng.xu@shopee.com> wrote:
>
> call stack:
These stacks should either be removed from the changelog, or moved
_after_ the description
of the problem. These are normal looking call stacks, you are not
fixing a crash or deadlock.
> ......
> PID: 210933 TASK: ffff92424e5ec080 CPU: 13 COMMAND: "kworker/u96:2"
> [ffffa7a8e96bbac0] __schedule at ffffffffb0719898
> [ffffa7a8e96bbb48] schedule at ffffffffb0719e9e
> [ffffa7a8e96bbb68] rwsem_down_write_slowpath at ffffffffafb3167a
> [ffffa7a8e96bbc00] down_write at ffffffffb071bfc1
> [ffffa7a8e96bbc18] kernfs_remove_by_name_ns at ffffffffafe3593e
> [ffffa7a8e96bbc48] sysfs_unmerge_group at ffffffffafe38922
> [ffffa7a8e96bbc68] dpm_sysfs_remove at ffffffffb021c96a
> [ffffa7a8e96bbc80] device_del at ffffffffb0209af8
> [ffffa7a8e96bbcd0] netdev_unregister_kobject at ffffffffb04a6b0e
> [ffffa7a8e96bbcf8] unregister_netdevice_many at ffffffffb046d3d9
> [ffffa7a8e96bbd60] default_device_exit_batch at ffffffffb046d8d1
> [ffffa7a8e96bbdd0] ops_exit_list at ffffffffb045e21d
> [ffffa7a8e96bbe00] cleanup_net at ffffffffb045ea46
> [ffffa7a8e96bbe60] process_one_work at ffffffffafad94bb
> [ffffa7a8e96bbeb0] worker_thread at ffffffffafad96ad
> [ffffa7a8e96bbf10] kthread at ffffffffafae132a
> [ffffa7a8e96bbf50] ret_from_fork at ffffffffafa04b92
>
> 290858 PID: 278176 TASK: ffff925deb39a040 CPU: 32 COMMAND: "node-exporter"
> [ffffa7a8d14dbb80] __schedule at ffffffffb0719898
> [ffffa7a8d14dbc08] schedule at ffffffffb0719e9e
> [ffffa7a8d14dbc28] schedule_preempt_disabled at ffffffffb071a24e
> [ffffa7a8d14dbc38] __mutex_lock at ffffffffb071af28
> [ffffa7a8d14dbcb8] __mutex_lock_slowpath at ffffffffb071b1a3
> [ffffa7a8d14dbcc8] mutex_lock at ffffffffb071b1e2
> [ffffa7a8d14dbce0] rtnl_lock at ffffffffb047f4b5
> [ffffa7a8d14dbcf0] bonding_show_bonds at ffffffffc079b1a1 [bonding]
> [ffffa7a8d14dbd20] class_attr_show at ffffffffb02117ce
> [ffffa7a8d14dbd30] sysfs_kf_seq_show at ffffffffafe37ba1
> [ffffa7a8d14dbd50] kernfs_seq_show at ffffffffafe35c07
> [ffffa7a8d14dbd60] seq_read_iter at ffffffffafd9fce0
> [ffffa7a8d14dbdc0] kernfs_fop_read_iter at ffffffffafe36a10
> [ffffa7a8d14dbe00] new_sync_read at ffffffffafd6de23
> [ffffa7a8d14dbe90] vfs_read at ffffffffafd6e64e
> [ffffa7a8d14dbed0] ksys_read at ffffffffafd70977
> [ffffa7a8d14dbf10] __x64_sys_read at ffffffffafd70a0a
> [ffffa7a8d14dbf20] do_syscall_64 at ffffffffb070bf1c
> [ffffa7a8d14dbf50] entry_SYSCALL_64_after_hwframe at ffffffffb080007c
> ......
>
> Problem description:
>
> Thread 210933 holds the rtnl_mutex and tries to acquire the kernfs_rwsem,
> but there are many readers which hold the kernfs_rwsem, so it has to sleep
> for a long time to wait the readers release the lock. Thread 278176 and any
> other threads which call bonding_show_bonds() also need to wait because
> they try to accuire the rtnl_mutex.
acquire
>
> bonding_show_bonds() uses rtnl_mutex to protect the bond_list traversal.
> However, the addition and deletion of bond_list are only performed in
> bond_init()/bond_uninit(), so we can intoduce a separate read-write lock
introduce
> to synchronize bond list mutation.
>
> What's the benefits of this change?
>
> 1) All threads which call bonding_show_bonds() only wait when the
> registration or unregistration of bond device happens.
>
> 2) There are many other users of rtnl_mutex, so bonding_show_bonds()
> won't compete with them.
>
> In a word, this change reduces the lock contention of rtnl_mutex.
>
This looks good to me, but please note:
1) This is net-next material, please resend next week, because
net-next is currently closed during the merge window.
2) Using a spell checker would point few typos (including in the title
"boning" -> "bonding")
Thanks.
^ permalink raw reply
* Re: [PATCH net v3 1/4] net: ethernet: cortina: Fix MTU max setting
From: Vladimir Oltean @ 2023-11-08 14:26 UTC (permalink / raw)
To: Linus Walleij
Cc: Hans Ulli Kroll, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michał Mirosław, Andrew Lunn,
linux-arm-kernel, netdev, linux-kernel
In-Reply-To: <20231107-gemini-largeframe-fix-v3-1-e3803c080b75@linaro.org>
On Tue, Nov 07, 2023 at 10:54:26AM +0100, Linus Walleij wrote:
> The RX max frame size is over 10000 for the Gemini ethernet,
> but the TX max frame size is actually just 2047 (0x7ff after
> checking the datasheet). Reflect this in what we offer to Linux,
> cap the MTU at the TX max frame minus ethernet headers.
>
> Use the BIT() macro for related bit flags so these TX settings
> are consistent.
What does this second paragraph intend to say? The patch doesn't use the
BIT() macro.
^ permalink raw reply
* Re: [PATCH v9 bpf-next 03/17] bpf: introduce BPF token object
From: Christian Brauner @ 2023-11-08 14:28 UTC (permalink / raw)
To: Andrii Nakryiko
Cc: bpf, netdev, paul, linux-fsdevel, linux-security-module, keescook,
kernel-team, sargun
In-Reply-To: <20231103190523.6353-4-andrii@kernel.org>
On Fri, Nov 03, 2023 at 12:05:09PM -0700, Andrii Nakryiko wrote:
> Add new kind of BPF kernel object, BPF token. BPF token is meant to
> allow delegating privileged BPF functionality, like loading a BPF
> program or creating a BPF map, from privileged process to a *trusted*
> unprivileged process, all while have a good amount of control over which
> privileged operations could be performed using provided BPF token.
>
> This is achieved through mounting BPF FS instance with extra delegation
> mount options, which determine what operations are delegatable, and also
> constraining it to the owning user namespace (as mentioned in the
> previous patch).
>
> BPF token itself is just a derivative from BPF FS and can be created
> through a new bpf() syscall command, BPF_TOKEN_CREATE, which accepts
> a path specification (using the usual fd + string path combo) to a BPF
> FS mount. Currently, BPF token "inherits" delegated command, map types,
> prog type, and attach type bit sets from BPF FS as is. In the future,
> having an BPF token as a separate object with its own FD, we can allow
> to further restrict BPF token's allowable set of things either at the creation
> time or after the fact, allowing the process to guard itself further
> from, e.g., unintentionally trying to load undesired kind of BPF
> programs. But for now we keep things simple and just copy bit sets as is.
>
> When BPF token is created from BPF FS mount, we take reference to the
> BPF super block's owning user namespace, and then use that namespace for
> checking all the {CAP_BPF, CAP_PERFMON, CAP_NET_ADMIN, CAP_SYS_ADMIN}
> capabilities that are normally only checked against init userns (using
> capable()), but now we check them using ns_capable() instead (if BPF
> token is provided). See bpf_token_capable() for details.
>
> Such setup means that BPF token in itself is not sufficient to grant BPF
> functionality. User namespaced process has to *also* have necessary
> combination of capabilities inside that user namespace. So while
> previously CAP_BPF was useless when granted within user namespace, now
> it gains a meaning and allows container managers and sys admins to have
> a flexible control over which processes can and need to use BPF
> functionality within the user namespace (i.e., container in practice).
> And BPF FS delegation mount options and derived BPF tokens serve as
> a per-container "flag" to grant overall ability to use bpf() (plus further
> restrict on which parts of bpf() syscalls are treated as namespaced).
>
> Note also, BPF_TOKEN_CREATE command itself requires ns_capable(CAP_BPF)
> within the BPF FS owning user namespace, rounding up the ns_capable()
> story of BPF token.
>
> The alternative to creating BPF token object was:
> a) not having any extra object and just pasing BPF FS path to each
> relevant bpf() command. This seems suboptimal as it's racy (mount
> under the same path might change in between checking it and using it
> for bpf() command). And also less flexible if we'd like to further
I don't understand "mount under the same path might change in between
checking it and using it for bpf() command".
Just require userspace to open() the bpffs instance and pass that fd to
bpf() just as you're doing right now. If that is racy then the current
implementation is even more so because it is passing:
bpffs_path_fd
bpffs_pathname
and then performs a lookup. More on that below.
I want to point out that most of this code here is unnecessary if you
use the bpffs fd itself as a token. But that's your decision. I'm just
saying that I'm not sure the critique that it's racy is valid.
> restrict ourselves compared to all the delegated functionality
> allowed on BPF FS.
> b) use non-bpf() interface, e.g., ioctl(), but otherwise also create
> a dedicated FD that would represent a token-like functionality. This
> doesn't seem superior to having a proper bpf() command, so
> BPF_TOKEN_CREATE was chosen.
>
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> ---
> include/linux/bpf.h | 41 +++++++
> include/uapi/linux/bpf.h | 39 +++++++
> kernel/bpf/Makefile | 2 +-
> kernel/bpf/inode.c | 17 ++-
> kernel/bpf/syscall.c | 17 +++
> kernel/bpf/token.c | 197 +++++++++++++++++++++++++++++++++
> tools/include/uapi/linux/bpf.h | 39 +++++++
> 7 files changed, 342 insertions(+), 10 deletions(-)
> create mode 100644 kernel/bpf/token.c
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index df50a7bf1a77..5ab418c78876 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -51,6 +51,10 @@ struct module;
> struct bpf_func_state;
> struct ftrace_ops;
> struct cgroup;
> +struct bpf_token;
> +struct user_namespace;
> +struct super_block;
> +struct inode;
>
> extern struct idr btf_idr;
> extern spinlock_t btf_idr_lock;
> @@ -1572,6 +1576,13 @@ struct bpf_mount_opts {
> u64 delegate_attachs;
> };
>
> +struct bpf_token {
> + struct work_struct work;
> + atomic64_t refcnt;
> + struct user_namespace *userns;
> + u64 allowed_cmds;
> +};
> +
> struct bpf_struct_ops_value;
> struct btf_member;
>
> @@ -2029,6 +2040,7 @@ static inline void bpf_enable_instrumentation(void)
> migrate_enable();
> }
>
> +extern const struct super_operations bpf_super_ops;
> extern const struct file_operations bpf_map_fops;
> extern const struct file_operations bpf_prog_fops;
> extern const struct file_operations bpf_iter_fops;
> @@ -2163,6 +2175,8 @@ static inline void bpf_map_dec_elem_count(struct bpf_map *map)
>
> extern int sysctl_unprivileged_bpf_disabled;
>
> +bool bpf_token_capable(const struct bpf_token *token, int cap);
> +
> static inline bool bpf_allow_ptr_leaks(void)
> {
> return perfmon_capable();
> @@ -2197,8 +2211,17 @@ int bpf_link_new_fd(struct bpf_link *link);
> struct bpf_link *bpf_link_get_from_fd(u32 ufd);
> struct bpf_link *bpf_link_get_curr_or_next(u32 *id);
>
> +void bpf_token_inc(struct bpf_token *token);
> +void bpf_token_put(struct bpf_token *token);
> +int bpf_token_create(union bpf_attr *attr);
> +struct bpf_token *bpf_token_get_from_fd(u32 ufd);
> +
> +bool bpf_token_allow_cmd(const struct bpf_token *token, enum bpf_cmd cmd);
> +
> int bpf_obj_pin_user(u32 ufd, int path_fd, const char __user *pathname);
> int bpf_obj_get_user(int path_fd, const char __user *pathname, int flags);
> +struct inode *bpf_get_inode(struct super_block *sb, const struct inode *dir,
> + umode_t mode);
>
> #define BPF_ITER_FUNC_PREFIX "bpf_iter_"
> #define DEFINE_BPF_ITER_FUNC(target, args...) \
> @@ -2561,6 +2584,24 @@ static inline int bpf_obj_get_user(const char __user *pathname, int flags)
> return -EOPNOTSUPP;
> }
>
> +static inline bool bpf_token_capable(const struct bpf_token *token, int cap)
> +{
> + return capable(cap) || (cap != CAP_SYS_ADMIN && capable(CAP_SYS_ADMIN));
> +}
> +
> +static inline void bpf_token_inc(struct bpf_token *token)
> +{
> +}
> +
> +static inline void bpf_token_put(struct bpf_token *token)
> +{
> +}
> +
> +static inline struct bpf_token *bpf_token_get_from_fd(u32 ufd)
> +{
> + return ERR_PTR(-EOPNOTSUPP);
> +}
> +
> static inline void __dev_flush(void)
> {
> }
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 0f6cdf52b1da..f75f289f1749 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -847,6 +847,37 @@ union bpf_iter_link_info {
> * Returns zero on success. On error, -1 is returned and *errno*
> * is set appropriately.
> *
> + * BPF_TOKEN_CREATE
> + * Description
> + * Create BPF token with embedded information about what
> + * BPF-related functionality it allows:
> + * - a set of allowed bpf() syscall commands;
> + * - a set of allowed BPF map types to be created with
> + * BPF_MAP_CREATE command, if BPF_MAP_CREATE itself is allowed;
> + * - a set of allowed BPF program types and BPF program attach
> + * types to be loaded with BPF_PROG_LOAD command, if
> + * BPF_PROG_LOAD itself is allowed.
> + *
> + * BPF token is created (derived) from an instance of BPF FS,
> + * assuming it has necessary delegation mount options specified.
> + * BPF FS mount is specified with openat()-style path FD + string.
> + * This BPF token can be passed as an extra parameter to various
> + * bpf() syscall commands to grant BPF subsystem functionality to
> + * unprivileged processes.
> + *
> + * When created, BPF token is "associated" with the owning
> + * user namespace of BPF FS instance (super block) that it was
> + * derived from, and subsequent BPF operations performed with
> + * BPF token would be performing capabilities checks (i.e.,
> + * CAP_BPF, CAP_PERFMON, CAP_NET_ADMIN, CAP_SYS_ADMIN) within
> + * that user namespace. Without BPF token, such capabilities
> + * have to be granted in init user namespace, making bpf()
> + * syscall incompatible with user namespace, for the most part.
> + *
> + * Return
> + * A new file descriptor (a nonnegative integer), or -1 if an
> + * error occurred (in which case, *errno* is set appropriately).
> + *
> * NOTES
> * eBPF objects (maps and programs) can be shared between processes.
> *
> @@ -901,6 +932,8 @@ enum bpf_cmd {
> BPF_ITER_CREATE,
> BPF_LINK_DETACH,
> BPF_PROG_BIND_MAP,
> + BPF_TOKEN_CREATE,
> + __MAX_BPF_CMD,
> };
>
> enum bpf_map_type {
> @@ -1709,6 +1742,12 @@ union bpf_attr {
> __u32 flags; /* extra flags */
> } prog_bind_map;
>
> + struct { /* struct used by BPF_TOKEN_CREATE command */
> + __u32 flags;
> + __u32 bpffs_path_fd;
> + __aligned_u64 bpffs_pathname;
> + } token_create;
> +
> } __attribute__((aligned(8)));
>
> /* The description below is an attempt at providing documentation to eBPF
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index f526b7573e97..4ce95acfcaa7 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -6,7 +6,7 @@ cflags-nogcse-$(CONFIG_X86)$(CONFIG_CC_IS_GCC) := -fno-gcse
> endif
> CFLAGS_core.o += $(call cc-disable-warning, override-init) $(cflags-nogcse-yy)
>
> -obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o log.o
> +obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o log.o token.o
> obj-$(CONFIG_BPF_SYSCALL) += bpf_iter.o map_iter.o task_iter.o prog_iter.o link_iter.o
> obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o bpf_lru_list.o lpm_trie.o map_in_map.o bloom_filter.o
> obj-$(CONFIG_BPF_SYSCALL) += local_storage.o queue_stack_maps.o ringbuf.o
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index e49e93bc65e3..3418a0edf7b4 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -99,9 +99,9 @@ static const struct inode_operations bpf_prog_iops = { };
> static const struct inode_operations bpf_map_iops = { };
> static const struct inode_operations bpf_link_iops = { };
>
> -static struct inode *bpf_get_inode(struct super_block *sb,
> - const struct inode *dir,
> - umode_t mode)
> +struct inode *bpf_get_inode(struct super_block *sb,
> + const struct inode *dir,
> + umode_t mode)
> {
> struct inode *inode;
>
> @@ -602,11 +602,13 @@ static int bpf_show_options(struct seq_file *m, struct dentry *root)
> {
> struct bpf_mount_opts *opts = root->d_sb->s_fs_info;
> umode_t mode = d_inode(root)->i_mode & S_IALLUGO & ~S_ISVTX;
> + u64 mask;
>
> if (mode != S_IRWXUGO)
> seq_printf(m, ",mode=%o", mode);
>
> - if (opts->delegate_cmds == ~0ULL)
> + mask = (1ULL << __MAX_BPF_CMD) - 1;
> + if ((opts->delegate_cmds & mask) == mask)
> seq_printf(m, ",delegate_cmds=any");
> else if (opts->delegate_cmds)
> seq_printf(m, ",delegate_cmds=0x%llx", opts->delegate_cmds);
> @@ -639,7 +641,7 @@ static void bpf_free_inode(struct inode *inode)
> free_inode_nonrcu(inode);
> }
>
> -static const struct super_operations bpf_super_ops = {
> +const struct super_operations bpf_super_ops = {
> .statfs = simple_statfs,
> .drop_inode = generic_delete_inode,
> .show_options = bpf_show_options,
> @@ -814,10 +816,7 @@ static int bpf_get_tree(struct fs_context *fc)
>
> static void bpf_free_fc(struct fs_context *fc)
> {
> - struct bpf_mount_opts *opts = fc->s_fs_info;
> -
> - if (opts)
> - kfree(opts);
> + kfree(fc->s_fs_info);
> }
>
> static const struct fs_context_operations bpf_context_ops = {
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index ad4d8e433ccc..0565e46509a6 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -5346,6 +5346,20 @@ static int bpf_prog_bind_map(union bpf_attr *attr)
> return ret;
> }
>
> +#define BPF_TOKEN_CREATE_LAST_FIELD token_create.bpffs_pathname
> +
> +static int token_create(union bpf_attr *attr)
> +{
> + if (CHECK_ATTR(BPF_TOKEN_CREATE))
> + return -EINVAL;
> +
> + /* no flags are supported yet */
> + if (attr->token_create.flags)
> + return -EINVAL;
> +
> + return bpf_token_create(attr);
> +}
> +
> static int __sys_bpf(int cmd, bpfptr_t uattr, unsigned int size)
> {
> union bpf_attr attr;
> @@ -5479,6 +5493,9 @@ static int __sys_bpf(int cmd, bpfptr_t uattr, unsigned int size)
> case BPF_PROG_BIND_MAP:
> err = bpf_prog_bind_map(&attr);
> break;
> + case BPF_TOKEN_CREATE:
> + err = token_create(&attr);
> + break;
> default:
> err = -EINVAL;
> break;
> diff --git a/kernel/bpf/token.c b/kernel/bpf/token.c
> new file mode 100644
> index 000000000000..32fa395f829b
> --- /dev/null
> +++ b/kernel/bpf/token.c
> @@ -0,0 +1,197 @@
> +#include <linux/bpf.h>
> +#include <linux/vmalloc.h>
> +#include <linux/fdtable.h>
> +#include <linux/file.h>
> +#include <linux/fs.h>
> +#include <linux/kernel.h>
> +#include <linux/idr.h>
> +#include <linux/namei.h>
> +#include <linux/user_namespace.h>
> +
> +bool bpf_token_capable(const struct bpf_token *token, int cap)
> +{
> + /* BPF token allows ns_capable() level of capabilities */
> + if (token) {
> + if (ns_capable(token->userns, cap))
> + return true;
> + if (cap != CAP_SYS_ADMIN && ns_capable(token->userns, CAP_SYS_ADMIN))
> + return true;
> + }
> + /* otherwise fallback to capable() checks */
> + return capable(cap) || (cap != CAP_SYS_ADMIN && capable(CAP_SYS_ADMIN));
> +}
> +
> +void bpf_token_inc(struct bpf_token *token)
> +{
> + atomic64_inc(&token->refcnt);
> +}
> +
> +static void bpf_token_free(struct bpf_token *token)
> +{
> + put_user_ns(token->userns);
> + kvfree(token);
> +}
> +
> +static void bpf_token_put_deferred(struct work_struct *work)
> +{
> + struct bpf_token *token = container_of(work, struct bpf_token, work);
> +
> + bpf_token_free(token);
> +}
> +
> +void bpf_token_put(struct bpf_token *token)
> +{
> + if (!token)
> + return;
> +
> + if (!atomic64_dec_and_test(&token->refcnt))
> + return;
> +
> + INIT_WORK(&token->work, bpf_token_put_deferred);
> + schedule_work(&token->work);
> +}
> +
> +static int bpf_token_release(struct inode *inode, struct file *filp)
> +{
> + struct bpf_token *token = filp->private_data;
> +
> + bpf_token_put(token);
> + return 0;
> +}
> +
> +static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
> +{
> + struct bpf_token *token = filp->private_data;
> + u64 mask;
> +
> + BUILD_BUG_ON(__MAX_BPF_CMD >= 64);
> + mask = (1ULL << __MAX_BPF_CMD) - 1;
> + if ((token->allowed_cmds & mask) == mask)
> + seq_printf(m, "allowed_cmds:\tany\n");
> + else
> + seq_printf(m, "allowed_cmds:\t0x%llx\n", token->allowed_cmds);
> +}
> +
> +#define BPF_TOKEN_INODE_NAME "bpf-token"
> +
> +static const struct inode_operations bpf_token_iops = { };
> +
> +static const struct file_operations bpf_token_fops = {
> + .release = bpf_token_release,
> + .show_fdinfo = bpf_token_show_fdinfo,
> +};
> +
> +int bpf_token_create(union bpf_attr *attr)
> +{
> + struct bpf_mount_opts *mnt_opts;
> + struct bpf_token *token = NULL;
> + struct user_namespace *userns;
> + struct inode *inode;
> + struct file *file;
> + struct path path;
> + umode_t mode;
> + int err, fd;
> +
> + err = user_path_at(attr->token_create.bpffs_path_fd,
> + u64_to_user_ptr(attr->token_create.bpffs_pathname),
> + LOOKUP_FOLLOW | LOOKUP_EMPTY, &path);
Do you really need bpffs_path_fd and bpffs_pathname?
This seems unnecessar as you're forcing a lookup that's best done in
userspace through regular open() apis. So I would just make this:
struct { /* struct used by BPF_TOKEN_CREATE command */
__u32 flags;
__u32 bpffs_path_fd;
} token_create;
In bpf_token_create() you can then just do:
struct fd f;
struct path path;
f = fdget(attr->token_create.bpffs_path_fd);
if (!f.file)
return -EBADF;
*path = f.file->f_path;
path_get(path);
fdput(f);
> + if (err)
> + return err;
> +
> + if (path.mnt->mnt_root != path.dentry) {
> + err = -EINVAL;
> + goto out_path;
> + }
> + if (path.mnt->mnt_sb->s_op != &bpf_super_ops) {
> + err = -EINVAL;
> + goto out_path;
> + }
> + err = path_permission(&path, MAY_ACCESS);
> + if (err)
> + goto out_path;
> +
> + userns = path.dentry->d_sb->s_user_ns;
> + if (!ns_capable(userns, CAP_BPF)) {
> + err = -EPERM;
> + goto out_path;
> + }
> +
> + mode = S_IFREG | ((S_IRUSR | S_IWUSR) & ~current_umask());
> + inode = bpf_get_inode(path.mnt->mnt_sb, NULL, mode);
> + if (IS_ERR(inode)) {
> + err = PTR_ERR(inode);
> + goto out_path;
> + }
> +
> + inode->i_op = &bpf_token_iops;
> + inode->i_fop = &bpf_token_fops;
> + clear_nlink(inode); /* make sure it is unlinked */
> +
> + file = alloc_file_pseudo(inode, path.mnt, BPF_TOKEN_INODE_NAME, O_RDWR, &bpf_token_fops);
> + if (IS_ERR(file)) {
> + iput(inode);
> + err = PTR_ERR(file);
> + goto out_path;
> + }
> +
> + token = kvzalloc(sizeof(*token), GFP_USER);
> + if (!token) {
> + err = -ENOMEM;
> + goto out_file;
> + }
> +
> + atomic64_set(&token->refcnt, 1);
> +
> + /* remember bpffs owning userns for future ns_capable() checks */
> + token->userns = get_user_ns(userns);
> +
> + mnt_opts = path.dentry->d_sb->s_fs_info;
> + token->allowed_cmds = mnt_opts->delegate_cmds;
> +
> + fd = get_unused_fd_flags(O_CLOEXEC);
> + if (fd < 0) {
> + err = fd;
> + goto out_token;
> + }
> +
> + file->private_data = token;
> + fd_install(fd, file);
> +
> + path_put(&path);
> + return fd;
> +
> +out_token:
> + bpf_token_free(token);
> +out_file:
> + fput(file);
> +out_path:
> + path_put(&path);
> + return err;
> +}
> +
> +struct bpf_token *bpf_token_get_from_fd(u32 ufd)
> +{
> + struct fd f = fdget(ufd);
> + struct bpf_token *token;
> +
> + if (!f.file)
> + return ERR_PTR(-EBADF);
> + if (f.file->f_op != &bpf_token_fops) {
> + fdput(f);
> + return ERR_PTR(-EINVAL);
> + }
> +
> + token = f.file->private_data;
> + bpf_token_inc(token);
> + fdput(f);
> +
> + return token;
> +}
> +
> +bool bpf_token_allow_cmd(const struct bpf_token *token, enum bpf_cmd cmd)
> +{
> + if (!token)
> + return false;
> +
> + return token->allowed_cmds & (1ULL << cmd);
> +}
> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
> index 0f6cdf52b1da..f75f289f1749 100644
> --- a/tools/include/uapi/linux/bpf.h
> +++ b/tools/include/uapi/linux/bpf.h
> @@ -847,6 +847,37 @@ union bpf_iter_link_info {
> * Returns zero on success. On error, -1 is returned and *errno*
> * is set appropriately.
> *
> + * BPF_TOKEN_CREATE
> + * Description
> + * Create BPF token with embedded information about what
> + * BPF-related functionality it allows:
> + * - a set of allowed bpf() syscall commands;
> + * - a set of allowed BPF map types to be created with
> + * BPF_MAP_CREATE command, if BPF_MAP_CREATE itself is allowed;
> + * - a set of allowed BPF program types and BPF program attach
> + * types to be loaded with BPF_PROG_LOAD command, if
> + * BPF_PROG_LOAD itself is allowed.
> + *
> + * BPF token is created (derived) from an instance of BPF FS,
> + * assuming it has necessary delegation mount options specified.
> + * BPF FS mount is specified with openat()-style path FD + string.
> + * This BPF token can be passed as an extra parameter to various
> + * bpf() syscall commands to grant BPF subsystem functionality to
> + * unprivileged processes.
> + *
> + * When created, BPF token is "associated" with the owning
> + * user namespace of BPF FS instance (super block) that it was
> + * derived from, and subsequent BPF operations performed with
> + * BPF token would be performing capabilities checks (i.e.,
> + * CAP_BPF, CAP_PERFMON, CAP_NET_ADMIN, CAP_SYS_ADMIN) within
> + * that user namespace. Without BPF token, such capabilities
> + * have to be granted in init user namespace, making bpf()
> + * syscall incompatible with user namespace, for the most part.
> + *
> + * Return
> + * A new file descriptor (a nonnegative integer), or -1 if an
> + * error occurred (in which case, *errno* is set appropriately).
> + *
> * NOTES
> * eBPF objects (maps and programs) can be shared between processes.
> *
> @@ -901,6 +932,8 @@ enum bpf_cmd {
> BPF_ITER_CREATE,
> BPF_LINK_DETACH,
> BPF_PROG_BIND_MAP,
> + BPF_TOKEN_CREATE,
> + __MAX_BPF_CMD,
> };
>
> enum bpf_map_type {
> @@ -1709,6 +1742,12 @@ union bpf_attr {
> __u32 flags; /* extra flags */
> } prog_bind_map;
>
> + struct { /* struct used by BPF_TOKEN_CREATE command */
> + __u32 flags;
> + __u32 bpffs_path_fd;
> + __aligned_u64 bpffs_pathname;
> + } token_create;
> +
> } __attribute__((aligned(8)));
>
> /* The description below is an attempt at providing documentation to eBPF
> --
> 2.34.1
>
^ permalink raw reply
* Re: [PATCH net 2/3] dpll: fix pin dump crash for rebound module
From: Jiri Pirko @ 2023-11-08 14:30 UTC (permalink / raw)
To: Arkadiusz Kubalewski
Cc: netdev, vadim.fedorenko, michal.michalik, milena.olech, pabeni,
kuba
In-Reply-To: <20231108103226.1168500-3-arkadiusz.kubalewski@intel.com>
Wed, Nov 08, 2023 at 11:32:25AM CET, arkadiusz.kubalewski@intel.com wrote:
>When a kernel module is unbound but the pin resources were not entirely
>freed (other kernel module instance have had kept the reference to that
>pin), and kernel module is again bound, the pin properties would not be
>updated (the properties are only assigned when memory for the pin is
>allocated), prop pointer still points to the kernel module memory of
>the kernel module which was deallocated on the unbind.
>
>If the pin dump is invoked in this state, the result is a kernel crash.
>Prevent the crash by storing persistent pin properties in dpll subsystem,
>copy the content from the kernel module when pin is allocated, instead of
>using memory of the kernel module.
>
>Fixes: 9431063ad323 ("dpll: core: Add DPLL framework base functions")
>Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions")
>Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
>---
> drivers/dpll/dpll_core.c | 4 ++--
> drivers/dpll/dpll_core.h | 4 ++--
> drivers/dpll/dpll_netlink.c | 28 ++++++++++++++--------------
> 3 files changed, 18 insertions(+), 18 deletions(-)
>
>diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
>index 3568149b9562..4077b562ba3b 100644
>--- a/drivers/dpll/dpll_core.c
>+++ b/drivers/dpll/dpll_core.c
>@@ -442,7 +442,7 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
> ret = -EINVAL;
> goto err;
> }
>- pin->prop = prop;
>+ memcpy(&pin->prop, prop, sizeof(pin->prop));
Odd, you don't care about the pointer within this structure?
> refcount_set(&pin->refcount, 1);
> xa_init_flags(&pin->dpll_refs, XA_FLAGS_ALLOC);
> xa_init_flags(&pin->parent_refs, XA_FLAGS_ALLOC);
>@@ -634,7 +634,7 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
> unsigned long i, stop;
> int ret;
>
>- if (WARN_ON(parent->prop->type != DPLL_PIN_TYPE_MUX))
>+ if (WARN_ON(parent->prop.type != DPLL_PIN_TYPE_MUX))
> return -EINVAL;
>
> if (WARN_ON(!ops) ||
>diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
>index 5585873c5c1b..717f715015c7 100644
>--- a/drivers/dpll/dpll_core.h
>+++ b/drivers/dpll/dpll_core.h
>@@ -44,7 +44,7 @@ struct dpll_device {
> * @module: module of creator
> * @dpll_refs: hold referencees to dplls pin was registered with
> * @parent_refs: hold references to parent pins pin was registered with
>- * @prop: pointer to pin properties given by registerer
>+ * @prop: pin properties copied from the registerer
> * @rclk_dev_name: holds name of device when pin can recover clock from it
> * @refcount: refcount
> **/
>@@ -55,7 +55,7 @@ struct dpll_pin {
> struct module *module;
> struct xarray dpll_refs;
> struct xarray parent_refs;
>- const struct dpll_pin_properties *prop;
>+ struct dpll_pin_properties prop;
> refcount_t refcount;
> };
>
>diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
>index 93fc6c4b8a78..963bbbbe6660 100644
>--- a/drivers/dpll/dpll_netlink.c
>+++ b/drivers/dpll/dpll_netlink.c
>@@ -278,17 +278,17 @@ dpll_msg_add_pin_freq(struct sk_buff *msg, struct dpll_pin *pin,
> if (nla_put_64bit(msg, DPLL_A_PIN_FREQUENCY, sizeof(freq), &freq,
> DPLL_A_PIN_PAD))
> return -EMSGSIZE;
>- for (fs = 0; fs < pin->prop->freq_supported_num; fs++) {
>+ for (fs = 0; fs < pin->prop.freq_supported_num; fs++) {
> nest = nla_nest_start(msg, DPLL_A_PIN_FREQUENCY_SUPPORTED);
> if (!nest)
> return -EMSGSIZE;
>- freq = pin->prop->freq_supported[fs].min;
>+ freq = pin->prop.freq_supported[fs].min;
> if (nla_put_64bit(msg, DPLL_A_PIN_FREQUENCY_MIN, sizeof(freq),
> &freq, DPLL_A_PIN_PAD)) {
> nla_nest_cancel(msg, nest);
> return -EMSGSIZE;
> }
>- freq = pin->prop->freq_supported[fs].max;
>+ freq = pin->prop.freq_supported[fs].max;
> if (nla_put_64bit(msg, DPLL_A_PIN_FREQUENCY_MAX, sizeof(freq),
> &freq, DPLL_A_PIN_PAD)) {
> nla_nest_cancel(msg, nest);
>@@ -304,9 +304,9 @@ static bool dpll_pin_is_freq_supported(struct dpll_pin *pin, u32 freq)
> {
> int fs;
>
>- for (fs = 0; fs < pin->prop->freq_supported_num; fs++)
>- if (freq >= pin->prop->freq_supported[fs].min &&
>- freq <= pin->prop->freq_supported[fs].max)
>+ for (fs = 0; fs < pin->prop.freq_supported_num; fs++)
>+ if (freq >= pin->prop.freq_supported[fs].min &&
>+ freq <= pin->prop.freq_supported[fs].max)
> return true;
> return false;
> }
>@@ -403,7 +403,7 @@ static int
> dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
> struct netlink_ext_ack *extack)
> {
>- const struct dpll_pin_properties *prop = pin->prop;
>+ const struct dpll_pin_properties *prop = &pin->prop;
> struct dpll_pin_ref *ref;
> int ret;
>
>@@ -696,7 +696,7 @@ dpll_pin_on_pin_state_set(struct dpll_pin *pin, u32 parent_idx,
> int ret;
>
> if (!(DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE &
>- pin->prop->capabilities)) {
>+ pin->prop.capabilities)) {
> NL_SET_ERR_MSG(extack, "state changing is not allowed");
> return -EOPNOTSUPP;
> }
>@@ -732,7 +732,7 @@ dpll_pin_state_set(struct dpll_device *dpll, struct dpll_pin *pin,
> int ret;
>
> if (!(DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE &
>- pin->prop->capabilities)) {
>+ pin->prop.capabilities)) {
> NL_SET_ERR_MSG(extack, "state changing is not allowed");
> return -EOPNOTSUPP;
> }
>@@ -759,7 +759,7 @@ dpll_pin_prio_set(struct dpll_device *dpll, struct dpll_pin *pin,
> int ret;
>
> if (!(DPLL_PIN_CAPABILITIES_PRIORITY_CAN_CHANGE &
>- pin->prop->capabilities)) {
>+ pin->prop.capabilities)) {
> NL_SET_ERR_MSG(extack, "prio changing is not allowed");
> return -EOPNOTSUPP;
> }
>@@ -787,7 +787,7 @@ dpll_pin_direction_set(struct dpll_pin *pin, struct dpll_device *dpll,
> int ret;
>
> if (!(DPLL_PIN_CAPABILITIES_DIRECTION_CAN_CHANGE &
>- pin->prop->capabilities)) {
>+ pin->prop.capabilities)) {
> NL_SET_ERR_MSG(extack, "direction changing is not allowed");
> return -EOPNOTSUPP;
> }
>@@ -817,8 +817,8 @@ dpll_pin_phase_adj_set(struct dpll_pin *pin, struct nlattr *phase_adj_attr,
> int ret;
>
> phase_adj = nla_get_s32(phase_adj_attr);
>- if (phase_adj > pin->prop->phase_range.max ||
>- phase_adj < pin->prop->phase_range.min) {
>+ if (phase_adj > pin->prop.phase_range.max ||
>+ phase_adj < pin->prop.phase_range.min) {
> NL_SET_ERR_MSG_ATTR(extack, phase_adj_attr,
> "phase adjust value not supported");
> return -EINVAL;
>@@ -999,7 +999,7 @@ dpll_pin_find(u64 clock_id, struct nlattr *mod_name_attr,
> unsigned long i;
>
> xa_for_each_marked(&dpll_pin_xa, i, pin, DPLL_REGISTERED) {
>- prop = pin->prop;
>+ prop = &pin->prop;
> cid_match = clock_id ? pin->clock_id == clock_id : true;
> mod_match = mod_name_attr && module_name(pin->module) ?
> !nla_strcmp(mod_name_attr,
>--
>2.38.1
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox