From dc01a3b9db43abf95b801c9694980777a329e303 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 23 Feb 2021 10:44:08 +0100 Subject: um: Fix tag order in stub_32.h "static void inline" is the wrong way around, fix that. Reported-by: kernel test robot Fixes: 9f0b4807a44f ("um: rework userspace stubs to not hard-code stub location") Signed-off-by: Johannes Berg Signed-off-by: Richard Weinberger --- arch/x86/um/shared/sysdep/stub_32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/um/shared/sysdep/stub_32.h b/arch/x86/um/shared/sysdep/stub_32.h index c3891c1ada26..b95db9daf0e8 100644 --- a/arch/x86/um/shared/sysdep/stub_32.h +++ b/arch/x86/um/shared/sysdep/stub_32.h @@ -77,7 +77,7 @@ static inline void trap_myself(void) __asm("int3"); } -static void inline remap_stack_and_trap(void) +static inline void remap_stack_and_trap(void) { __asm__ volatile ( "movl %%esp,%%ebx ;" -- cgit v1.2.3 From d5027ca63e0e778b641cf23e3f5c6d6212cf412b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 5 Mar 2021 21:43:15 +0100 Subject: um: Mark all kernel symbols as local Ritesh reported a bug [1] against UML, noting that it crashed on startup. The backtrace shows the following (heavily redacted): (gdb) bt ... #26 0x0000000060015b5d in sem_init () at ipc/sem.c:268 #27 0x00007f89906d92f7 in ?? () from /lib/x86_64-linux-gnu/libcom_err.so.2 #28 0x00007f8990ab8fb2 in call_init (...) at dl-init.c:72 ... #40 0x00007f89909bf3a6 in nss_load_library (...) at nsswitch.c:359 ... #44 0x00007f8990895e35 in _nss_compat_getgrnam_r (...) at nss_compat/compat-grp.c:486 #45 0x00007f8990968b85 in __getgrnam_r [...] #46 0x00007f89909d6b77 in grantpt [...] #47 0x00007f8990a9394e in __GI_openpty [...] #48 0x00000000604a1f65 in openpty_cb (...) at arch/um/os-Linux/sigio.c:407 #49 0x00000000604a58d0 in start_idle_thread (...) at arch/um/os-Linux/skas/process.c:598 #50 0x0000000060004a3d in start_uml () at arch/um/kernel/skas/process.c:45 #51 0x00000000600047b2 in linux_main (...) at arch/um/kernel/um_arch.c:334 #52 0x000000006000574f in main (...) at arch/um/os-Linux/main.c:144 indicating that the UML function openpty_cb() calls openpty(), which internally calls __getgrnam_r(), which causes the nsswitch machinery to get started. This loads, through lots of indirection that I snipped, the libcom_err.so.2 library, which (in an unknown function, "??") calls sem_init(). Now, of course it wants to get libpthread's sem_init(), since it's linked against libpthread. However, the dynamic linker looks up that symbol against the binary first, and gets the kernel's sem_init(). Hajime Tazaki noted that "objcopy -L" can localize a symbol, so the dynamic linker wouldn't do the lookup this way. I tried, but for some reason that didn't seem to work. Doing the same thing in the linker script instead does seem to work, though I cannot entirely explain - it *also* works if I just add "VERSION { { global: *; }; }" instead, indicating that something else is happening that I don't really understand. It may be that explicitly doing that marks them with some kind of empty version, and that's different from the default. Explicitly marking them with a version breaks kallsyms, so that doesn't seem to be possible. Marking all the symbols as local seems correct, and does seem to address the issue, so do that. Also do it for static link, nsswitch libraries could still be loaded there. [1] https://bugs.debian.org/983379 Reported-by: Ritesh Raj Sarraf Signed-off-by: Johannes Berg Acked-By: Anton Ivanov Tested-By: Ritesh Raj Sarraf Signed-off-by: Richard Weinberger --- arch/um/kernel/dyn.lds.S | 6 ++++++ arch/um/kernel/uml.lds.S | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S index dacbfabf66d8..2f2a8ce92f1e 100644 --- a/arch/um/kernel/dyn.lds.S +++ b/arch/um/kernel/dyn.lds.S @@ -6,6 +6,12 @@ OUTPUT_ARCH(ELF_ARCH) ENTRY(_start) jiffies = jiffies_64; +VERSION { + { + local: *; + }; +} + SECTIONS { PROVIDE (__executable_start = START); diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S index 45d957d7004c..7a8e2b123e29 100644 --- a/arch/um/kernel/uml.lds.S +++ b/arch/um/kernel/uml.lds.S @@ -7,6 +7,12 @@ OUTPUT_ARCH(ELF_ARCH) ENTRY(_start) jiffies = jiffies_64; +VERSION { + { + local: *; + }; +} + SECTIONS { /* This must contain the right address - not quite the default ELF one.*/ -- cgit v1.2.3 From ea8e896cc15e8fac586d018733fd67f56cd721cc Mon Sep 17 00:00:00 2001 From: Yang Li Date: Wed, 10 Mar 2021 16:49:08 +0800 Subject: um: Remove unneeded variable 'ret' Fix the following coccicheck warning: ./arch/um/drivers/hostaudio_kern.c:125:10-14: Unneeded variable: "mask". Return "0" on line 131 Reported-by: Abaci Robot Signed-off-by: Yang Li Signed-off-by: Richard Weinberger --- arch/um/drivers/hostaudio_kern.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c index d35d3f305a31..5b064d360cb7 100644 --- a/arch/um/drivers/hostaudio_kern.c +++ b/arch/um/drivers/hostaudio_kern.c @@ -122,13 +122,11 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer, static __poll_t hostaudio_poll(struct file *file, struct poll_table_struct *wait) { - __poll_t mask = 0; - #ifdef DEBUG printk(KERN_DEBUG "hostaudio: poll called (unimplemented)\n"); #endif - return mask; + return 0; } static long hostaudio_ioctl(struct file *file, -- cgit v1.2.3 From ad3d19911632debc886ef4a992d41d6de7927006 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 15 Mar 2021 23:47:31 +0100 Subject: um: Disable CONFIG_GCOV with MODULES CONFIG_GCOV doesn't work with modules, and for various reasons it cannot work, see also https://lore.kernel.org/r/d36ea54d8c0a8dd706826ba844a6f27691f45d55.camel@sipsolutions.net Make CONFIG_GCOV depend on !MODULES to avoid anyone running into issues there. This also means we need not export the gcov symbols. Signed-off-by: Johannes Berg Signed-off-by: Richard Weinberger --- arch/um/Kconfig.debug | 1 + arch/um/kernel/Makefile | 1 - arch/um/kernel/gmon_syms.c | 16 ---------------- 3 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 arch/um/kernel/gmon_syms.c diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug index 315d368e63ad..1dfb2959c73b 100644 --- a/arch/um/Kconfig.debug +++ b/arch/um/Kconfig.debug @@ -17,6 +17,7 @@ config GCOV bool "Enable gcov support" depends on DEBUG_INFO depends on !KCOV + depends on !MODULES help This option allows developers to retrieve coverage data from a UML session. diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 5aa882011e04..e698e0c7dbdc 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile @@ -21,7 +21,6 @@ obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \ obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o obj-$(CONFIG_GPROF) += gprof_syms.o -obj-$(CONFIG_GCOV) += gmon_syms.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_STACKTRACE) += stacktrace.o diff --git a/arch/um/kernel/gmon_syms.c b/arch/um/kernel/gmon_syms.c deleted file mode 100644 index 9361a8eb9bf1..000000000000 --- a/arch/um/kernel/gmon_syms.c +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - */ - -#include - -extern void __bb_init_func(void *) __attribute__((weak)); -EXPORT_SYMBOL(__bb_init_func); - -extern void __gcov_init(void *) __attribute__((weak)); -EXPORT_SYMBOL(__gcov_init); -extern void __gcov_merge_add(void *, unsigned int) __attribute__((weak)); -EXPORT_SYMBOL(__gcov_merge_add); -extern void __gcov_exit(void) __attribute__((weak)); -EXPORT_SYMBOL(__gcov_exit); -- cgit v1.2.3 From 24271ffed750bc84ea8f73bbab30c59d53f56171 Mon Sep 17 00:00:00 2001 From: Yang Li Date: Wed, 17 Mar 2021 15:11:36 +0800 Subject: um: Replace if (cond) BUG() with BUG_ON() Fix the following coccinelle reports: ./arch/um/kernel/mem.c:77:3-6: WARNING: Use BUG_ON instead of if condition followed by BUG. Reported-by: Abaci Robot Signed-off-by: Yang Li Signed-off-by: Richard Weinberger --- arch/um/kernel/mem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 9242dc91d751..22e28bfb22cc 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -73,8 +73,7 @@ static void __init one_page_table_init(pmd_t *pmd) set_pmd(pmd, __pmd(_KERNPG_TABLE + (unsigned long) __pa(pte))); - if (pte != pte_offset_kernel(pmd, 0)) - BUG(); + BUG_ON(pte != pte_offset_kernel(pmd, 0)); } } -- cgit v1.2.3 From a730af6e3114d549555f4b130c216bad1c3aa80e Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 4 Apr 2021 11:20:44 -0700 Subject: um: Add 2 missing libs to fix various build errors Fix many build errors (at least 18 build error reports) for uml on i386 by adding 2 more library object files. All missing symbols are either cmpxchg8b_emu or atomic*386. Here are a few examples of the build errors that are eliminated: /usr/bin/ld: core.c:(.text+0xd83): undefined reference to `cmpxchg8b_emu' /usr/bin/ld: core.c:(.text+0x2bb2): undefined reference to `atomic64_add_386' /usr/bin/ld: core.c:(.text+0x2c5d): undefined reference to `atomic64_xchg_386' syscall.c:(.text+0x2f49): undefined reference to `atomic64_set_386' /usr/bin/ld: syscall.c:(.text+0x2f54): undefined reference to `atomic64_set_386' syscall.c:(.text+0x33a4): undefined reference to `atomic64_inc_386' /usr/bin/ld: syscall.c:(.text+0x33ac): undefined reference to `atomic64_inc_386' /usr/bin/ld: net/ipv4/inet_timewait_sock.o: in function `inet_twsk_alloc': inet_timewait_sock.c:(.text+0x3d1): undefined reference to `atomic64_read_386' /usr/bin/ld: inet_timewait_sock.c:(.text+0x3dd): undefined reference to `atomic64_set_386' /usr/bin/ld: net/ipv4/inet_connection_sock.o: in function `inet_csk_clone_lock': inet_connection_sock.c:(.text+0x1d74): undefined reference to `atomic64_read_386' /usr/bin/ld: inet_connection_sock.c:(.text+0x1d80): undefined reference to `atomic64_set_386' /usr/bin/ld: net/ipv4/tcp_input.o: in function `inet_reqsk_alloc': tcp_input.c:(.text+0xa345): undefined reference to `atomic64_set_386' /usr/bin/ld: net/mac80211/wpa.o: in function `ieee80211_crypto_tkip_encrypt': wpa.c:(.text+0x739): undefined reference to `atomic64_inc_return_386' Signed-off-by: Randy Dunlap Reported-by: kernel test robot Cc: Brendan Jackman Cc: Alexei Starovoitov Cc: kbuild-all@lists.01.org Cc: Jeff Dike Cc: Richard Weinberger Cc: Anton Ivanov Cc: linux-um@lists.infradead.org Cc: Johannes Berg Cc: Johannes Berg Signed-off-by: Richard Weinberger --- arch/x86/um/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile index 77f70b969d14..5ccb18290d71 100644 --- a/arch/x86/um/Makefile +++ b/arch/x86/um/Makefile @@ -21,6 +21,7 @@ obj-y += checksum_32.o syscalls_32.o obj-$(CONFIG_ELF_CORE) += elfcore.o subarch-y = ../lib/string_32.o ../lib/atomic64_32.o ../lib/atomic64_cx8_32.o +subarch-y += ../lib/cmpxchg8b_emu.o ../lib/atomic64_386_32.o subarch-y += ../kernel/sys_ia32.o else -- cgit v1.2.3 From c521db95d4e3f7ba7dd8fd0679ff148d848c1d4b Mon Sep 17 00:00:00 2001 From: Yang Li Date: Tue, 6 Apr 2021 10:00:50 +0800 Subject: um: Remove unused including Fix the following versioncheck warning: ./arch/um/drivers/vector_kern.c: 11 linux/version.h not needed. Reported-by: Abaci Robot Signed-off-by: Yang Li Signed-off-by: Richard Weinberger --- arch/um/drivers/vector_kern.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c index 47a02e60898d..d27a2a9faf3e 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c @@ -8,7 +8,6 @@ * Copyright (C) 2001 by various other people who didn't put their name here. */ -#include #include #include #include -- cgit v1.2.3 From 6e166319a63448c1ba9e310ddd94c8e3e9ac4e3c Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 13 Apr 2021 23:43:48 -0700 Subject: um: pgtable.h: Fix W=1 warning for empty body in 'do' statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the common kernel style to eliminate a warning: ./arch/um/include/asm/pgtable.h:305:47: warning: suggest braces around empty body in ‘do’ statement [-Wempty-body] #define update_mmu_cache(vma,address,ptep) do ; while (0) ^ mm/filemap.c:3212:3: note: in expansion of macro ‘update_mmu_cache’ update_mmu_cache(vma, addr, vmf->pte); ^~~~~~~~~~~~~~~~ Signed-off-by: Randy Dunlap Cc: Jeff Dike Cc: Richard Weinberger Cc: Anton Ivanov Cc: linux-um@lists.infradead.org Signed-off-by: Richard Weinberger --- arch/um/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h index def376194dce..b9e20bbe2f75 100644 --- a/arch/um/include/asm/pgtable.h +++ b/arch/um/include/asm/pgtable.h @@ -302,7 +302,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) struct mm_struct; extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr); -#define update_mmu_cache(vma,address,ptep) do ; while (0) +#define update_mmu_cache(vma,address,ptep) do {} while (0) /* Encode and de-code a swap entry */ #define __swp_type(x) (((x).val >> 5) & 0x1f) -- cgit v1.2.3 From 1a594f0afa2b176531e600a6bf8074849fe2a780 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 13 Apr 2021 23:43:49 -0700 Subject: um: elf.h: Fix W=1 warning for empty body in 'do' statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the common kernel style to eliminate a warning: ./arch/x86/um/asm/elf.h:215:32: warning: suggest braces around empty body in ‘do’ statement [-Wempty-body] #define SET_PERSONALITY(ex) do ; while(0) ^ Signed-off-by: Randy Dunlap Cc: Jeff Dike Cc: Richard Weinberger Cc: Anton Ivanov Cc: linux-um@lists.infradead.org Signed-off-by: Richard Weinberger --- arch/x86/um/asm/elf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h index c907b20d4993..dcaf3b38a9e0 100644 --- a/arch/x86/um/asm/elf.h +++ b/arch/x86/um/asm/elf.h @@ -212,6 +212,6 @@ extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu); extern long elf_aux_hwcap; #define ELF_HWCAP (elf_aux_hwcap) -#define SET_PERSONALITY(ex) do ; while(0) +#define SET_PERSONALITY(ex) do {} while(0) #endif -- cgit v1.2.3 From ed102bf2afed226703eaf85a704755bdbea34583 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Thu, 15 Apr 2021 10:13:52 -0700 Subject: um: Fix W=1 missing-include-dirs warnings Currently when using "W=1" with UML builds, there are over 700 warnings like so: CC arch/um/drivers/stderr_console.o cc1: warning: ./arch/um/include/uapi: No such file or directory [-Wmissing-include-dirs] but arch/um/ does not have include/uapi/ at all, so add that subdir and put one Kbuild file into it (since git does not track empty subdirs). Signed-off-by: Randy Dunlap Cc: Masahiro Yamada Cc: Michal Marek Cc: linux-kbuild@vger.kernel.org Cc: Jeff Dike Cc: Richard Weinberger Cc: Anton Ivanov Cc: linux-um@lists.infradead.org Reviewed-by: Masahiro Yamada Signed-off-by: Richard Weinberger --- arch/um/include/uapi/asm/Kbuild | 1 + 1 file changed, 1 insertion(+) create mode 100644 arch/um/include/uapi/asm/Kbuild diff --git a/arch/um/include/uapi/asm/Kbuild b/arch/um/include/uapi/asm/Kbuild new file mode 100644 index 000000000000..f66554cd5c45 --- /dev/null +++ b/arch/um/include/uapi/asm/Kbuild @@ -0,0 +1 @@ +# SPDX-License-Identifier: GPL-2.0 -- cgit v1.2.3