2020-11-08 05:20:20

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 00/19] Add generic user_landing tracking

Started from discussion [1], where was noted that currently a couple of
architectures support mremap() for vdso/sigpage, but not munmap().
If an application maps something on the ex-place of vdso/sigpage,
later after processing signal it will land there (good luck!)

Patches set is based on linux-next (next-20201106) and it depends on
changes in x86/cleanups (those reclaim TIF_IA32/TIF_X32) and also
on my changes in akpm (fixing several mremap() issues).

Logically, the patches set divides on:
- patch 1: cleanup for patches in x86/cleanups
- patches 2-11: cleanups for arch_setup_additional_pages()
- patches 12-13: x86 signal changes for unmapped vdso
- patches 14-19: provide generic user_landing in mm_struct

In the end, besides cleanups, it's now more predictable what happens for
applications with unmapped vdso on architectures those support .mremap()
for vdso/sigpage.

I'm aware of only one user that unmaps vdso - Valgrind [2].
(there possibly are more, but this one is "special", it unmaps vdso, but
not vvar, which confuses CRIU [Checkpoint Restore In Userspace], that's
why I'm aware of it)

Patches as a .git branch:
https://github.com/0x7f454c46/linux/tree/setup_additional_pages

[1]: https://lore.kernel.org/linux-arch/CAJwJo6ZANqYkSHbQ+3b+Fi_VT80MtrzEV5yreQAWx-L8j8x2zA@mail.gmail.com/
[2]: https://github.com/checkpoint-restore/criu/issues/488

Cc: Alexander Viro <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Guo Ren <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Russell King <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vincenzo Frascino <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]

Dmitry Safonov (19):
x86/elf: Check in_x32_syscall() in compat_arch_setup_additional_pages()
elf: Move arch_setup_additional_pages() to generic elf.h
arm64: Use in_compat_task() in arch_setup_additional_pages()
x86: Remove compat_arch_setup_additional_pages()
elf: Remove compat_arch_setup_additional_pages()
elf/vdso: Reuse arch_setup_additional_pages() parameters
elf: Use sysinfo_ehdr in ARCH_DLINFO()
arm/vdso: Remove vdso pointer from mm->context
s390/vdso: Remove vdso_base pointer from mm->context
sparc/vdso: Remove vdso pointer from mm->context
mm/mmap: Make vm_special_mapping::mremap return void
x86/signal: Land on &frame->retcode when vdso isn't mapped
x86/signal: Check if vdso_image_32 is mapped before trying to land on it
mm: Add user_landing in mm_struct
x86/vdso: Migrate to user_landing
arm/vdso: Migrate to user_landing
arm64/vdso: Migrate compat signals to user_landing
arm64/vdso: Migrate native signals to user_landing
mips/vdso: Migrate to user_landing

arch/alpha/include/asm/elf.h | 2 +-
arch/arm/Kconfig | 2 +
arch/arm/include/asm/elf.h | 10 +---
arch/arm/include/asm/mmu.h | 3 -
arch/arm/include/asm/vdso.h | 6 +-
arch/arm/kernel/process.c | 14 +----
arch/arm/kernel/signal.c | 6 +-
arch/arm/kernel/vdso.c | 20 ++-----
arch/arm64/Kconfig | 2 +
arch/arm64/include/asm/elf.h | 27 ++-------
arch/arm64/kernel/signal.c | 10 +++-
arch/arm64/kernel/signal32.c | 17 ++++--
arch/arm64/kernel/vdso.c | 47 ++++++---------
arch/csky/Kconfig | 1 +
arch/csky/include/asm/elf.h | 4 --
arch/csky/kernel/vdso.c | 3 +-
arch/hexagon/Kconfig | 1 +
arch/hexagon/include/asm/elf.h | 6 --
arch/hexagon/kernel/vdso.c | 3 +-
arch/ia64/include/asm/elf.h | 2 +-
arch/mips/Kconfig | 2 +
arch/mips/include/asm/elf.h | 10 +---
arch/mips/kernel/signal.c | 11 ++--
arch/mips/kernel/vdso.c | 5 +-
arch/mips/vdso/genvdso.c | 9 ---
arch/nds32/Kconfig | 1 +
arch/nds32/include/asm/elf.h | 8 +--
arch/nds32/kernel/vdso.c | 3 +-
arch/nios2/Kconfig | 1 +
arch/nios2/include/asm/elf.h | 4 --
arch/nios2/mm/init.c | 2 +-
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/elf.h | 9 +--
arch/powerpc/kernel/vdso.c | 3 +-
arch/riscv/Kconfig | 1 +
arch/riscv/include/asm/elf.h | 10 +---
arch/riscv/kernel/vdso.c | 9 +--
arch/s390/Kconfig | 1 +
arch/s390/include/asm/elf.h | 10 +---
arch/s390/include/asm/mmu.h | 1 -
arch/s390/kernel/vdso.c | 13 +---
arch/sh/Kconfig | 1 +
arch/sh/include/asm/elf.h | 16 ++---
arch/sh/kernel/vsyscall/vsyscall.c | 3 +-
arch/sparc/Kconfig | 1 +
arch/sparc/include/asm/elf_64.h | 11 +---
arch/sparc/include/asm/mmu_64.h | 1 -
arch/sparc/vdso/vma.c | 18 +++---
arch/x86/Kconfig | 2 +
arch/x86/entry/common.c | 8 ++-
arch/x86/entry/vdso/vma.c | 72 ++++++++++++-----------
arch/x86/ia32/ia32_signal.c | 18 +++---
arch/x86/include/asm/compat.h | 6 ++
arch/x86/include/asm/elf.h | 44 +++++---------
arch/x86/include/asm/mmu.h | 1 -
arch/x86/include/asm/vdso.h | 4 ++
arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 3 +-
arch/x86/kernel/signal.c | 25 ++++----
arch/x86/um/asm/elf.h | 9 +--
arch/x86/um/vdso/vma.c | 2 +-
fs/Kconfig.binfmt | 3 +
fs/aio.c | 3 +-
fs/binfmt_elf.c | 19 +++---
fs/binfmt_elf_fdpic.c | 17 +++---
fs/compat_binfmt_elf.c | 12 ----
include/linux/elf.h | 24 ++++++--
include/linux/mm.h | 3 +-
include/linux/mm_types.h | 12 +++-
mm/Kconfig | 3 +
mm/mmap.c | 21 ++++++-
mm/mremap.c | 2 +-
71 files changed, 308 insertions(+), 356 deletions(-)


base-commit: c34f157421f6905e6b4a79a312e9175dce2bc607
--
2.28.0


2020-11-08 05:20:20

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 07/19] elf: Use sysinfo_ehdr in ARCH_DLINFO()

Instead mm->context.vdso use the pointer provided by elf loader.
That allows to drop the pointer on arm/s390/sparc.

Cc: Christian Borntraeger <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: [email protected]
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/alpha/include/asm/elf.h | 2 +-
arch/arm/include/asm/elf.h | 5 ++---
arch/arm64/include/asm/elf.h | 18 +++++-------------
arch/ia64/include/asm/elf.h | 2 +-
arch/mips/include/asm/elf.h | 5 ++---
arch/nds32/include/asm/elf.h | 5 ++---
arch/powerpc/include/asm/elf.h | 4 ++--
arch/riscv/include/asm/elf.h | 5 ++---
arch/s390/include/asm/elf.h | 5 ++---
arch/sh/include/asm/elf.h | 10 +++++-----
arch/sparc/include/asm/elf_64.h | 5 ++---
arch/x86/include/asm/elf.h | 33 ++++++++++++++-------------------
arch/x86/um/asm/elf.h | 4 ++--
fs/binfmt_elf.c | 6 +++---
fs/binfmt_elf_fdpic.c | 11 ++++++-----
15 files changed, 51 insertions(+), 69 deletions(-)

diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
index 8049997fa372..701e820f28f0 100644
--- a/arch/alpha/include/asm/elf.h
+++ b/arch/alpha/include/asm/elf.h
@@ -155,7 +155,7 @@ extern int alpha_l2_cacheshape;
extern int alpha_l3_cacheshape;

/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
NEW_AUX_ENT(AT_L1I_CACHESHAPE, alpha_l1i_cacheshape); \
NEW_AUX_ENT(AT_L1D_CACHESHAPE, alpha_l1d_cacheshape); \
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 1f4b91a17a91..7bb07056242f 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -133,10 +133,9 @@ extern void elf_set_personality(const struct elf32_hdr *);
#define SET_PERSONALITY(ex) elf_set_personality(&(ex))

#ifdef CONFIG_VDSO
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (elf_addr_t)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
} while (0)
#endif

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index a81953bcc1cf..e62818967a69 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -165,10 +165,9 @@ typedef struct user_fpsimd_state elf_fpregset_t;
})

/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (elf_addr_t)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
\
/* \
* Should always be nonzero unless there's a kernel bug. \
@@ -223,19 +222,12 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
set_thread_flag(TIF_32BIT); \
})
#ifdef CONFIG_COMPAT_VDSO
-#define COMPAT_ARCH_DLINFO \
+#define COMPAT_ARCH_DLINFO(sysinfo_ehdr) \
do { \
- /* \
- * Note that we use Elf64_Off instead of elf_addr_t because \
- * elf_addr_t in compat is defined as Elf32_Addr and casting \
- * current->mm->context.vdso to it triggers a cast warning of \
- * cast from pointer to integer of different size. \
- */ \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (Elf64_Off)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
} while (0)
#else
-#define COMPAT_ARCH_DLINFO
+#define COMPAT_ARCH_DLINFO(sysinfo_ehdr)
#endif

#endif /* CONFIG_COMPAT */
diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
index 6629301a2620..a257e5abddce 100644
--- a/arch/ia64/include/asm/elf.h
+++ b/arch/ia64/include/asm/elf.h
@@ -208,7 +208,7 @@ struct task_struct;
#define GATE_EHDR ((const struct elfhdr *) GATE_ADDR)

/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
extern char __kernel_syscall_via_epc[]; \
NEW_AUX_ENT(AT_SYSINFO, (unsigned long) __kernel_syscall_via_epc); \
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index 6665cf7870b3..5bdc8d00ac37 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -474,10 +474,9 @@ extern const char *__elf_base_platform;
#endif

/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (unsigned long)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
} while (0)

#ifdef CONFIG_MIPS_FP_SUPPORT
diff --git a/arch/nds32/include/asm/elf.h b/arch/nds32/include/asm/elf.h
index 36cec4ae5a84..4f5894208efe 100644
--- a/arch/nds32/include/asm/elf.h
+++ b/arch/nds32/include/asm/elf.h
@@ -165,13 +165,12 @@ struct elf32_hdr;
#define FPU_AUX_ENT NEW_AUX_ENT(AT_IGNORE, 0)
#endif

-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
/* Optional FPU initialization */ \
FPU_AUX_ENT; \
\
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (elf_addr_t)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
} while (0)

#endif
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index ba0e1e331088..b1ae4411f4bd 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -155,7 +155,7 @@ extern int ucache_bsize;
* even if DLINFO_ARCH_ITEMS goes to zero or is undefined.
* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes
*/
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
/* Handle glibc compatibility. */ \
NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \
@@ -164,7 +164,7 @@ do { \
NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize); \
NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize); \
NEW_AUX_ENT(AT_UCACHEBSIZE, ucache_bsize); \
- VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso_base); \
+ VDSO_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
ARCH_DLINFO_CACHE_GEOMETRY; \
} while (0)

diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h
index 628444d3bbab..3c270c7c32f3 100644
--- a/arch/riscv/include/asm/elf.h
+++ b/arch/riscv/include/asm/elf.h
@@ -58,10 +58,9 @@ extern unsigned long elf_hwcap;
#define ELF_PLATFORM (NULL)

#ifdef CONFIG_MMU
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (elf_addr_t)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
NEW_AUX_ENT(AT_L1I_CACHESIZE, \
get_cache_size(1, CACHE_TYPE_INST)); \
NEW_AUX_ENT(AT_L1I_CACHEGEOMETRY, \
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index f6ce9df8a996..1087a52f3257 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -269,11 +269,10 @@ do { \
#define STACK_RND_MASK MMAP_RND_MASK

/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
if (vdso_enabled) \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (unsigned long)current->mm->context.vdso_base); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
} while (0)

#endif
diff --git a/arch/sh/include/asm/elf.h b/arch/sh/include/asm/elf.h
index 9b3e22e771a1..03b813c0bc39 100644
--- a/arch/sh/include/asm/elf.h
+++ b/arch/sh/include/asm/elf.h
@@ -170,13 +170,13 @@ extern void __kernel_vsyscall;
#define VDSO_BASE ((unsigned long)current->mm->context.vdso)
#define VDSO_SYM(x) (VDSO_BASE + (unsigned long)(x))

-#define VSYSCALL_AUX_ENT \
+#define VSYSCALL_AUX_ENT(sysinfo_ehdr) \
if (vdso_enabled) \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
else \
NEW_AUX_ENT(AT_IGNORE, 0)
#else
-#define VSYSCALL_AUX_ENT NEW_AUX_ENT(AT_IGNORE, 0)
+#define VSYSCALL_AUX_ENT(sysinfo_ehdr) NEW_AUX_ENT(AT_IGNORE, 0)
#endif /* CONFIG_VSYSCALL */

#ifdef CONFIG_SH_FPU
@@ -188,13 +188,13 @@ extern void __kernel_vsyscall;
extern int l1i_cache_shape, l1d_cache_shape, l2_cache_shape;

/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
/* Optional FPU initialization */ \
FPU_AUX_ENT; \
\
/* Optional vsyscall entry */ \
- VSYSCALL_AUX_ENT; \
+ VSYSCALL_AUX_ENT(sysinfo_ehdr); \
\
/* Cache desc */ \
NEW_AUX_ENT(AT_L1I_CACHESHAPE, l1i_cache_shape); \
diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
index 63a622c36df3..1e7295b5ae2f 100644
--- a/arch/sparc/include/asm/elf_64.h
+++ b/arch/sparc/include/asm/elf_64.h
@@ -213,12 +213,11 @@ do { if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \

extern unsigned int vdso_enabled;

-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
extern struct adi_config adi_state; \
if (vdso_enabled) \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (unsigned long)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
NEW_AUX_ENT(AT_ADI_BLKSZ, adi_state.caps.blksz); \
NEW_AUX_ENT(AT_ADI_NBITS, adi_state.caps.nbits); \
NEW_AUX_ENT(AT_ADI_UEONADI, adi_state.caps.ue_on_adi); \
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 51a08f6b18e5..ace9e9da3521 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -306,11 +306,14 @@ extern u32 elf_hwcap2;

struct task_struct;

-#define ARCH_DLINFO_IA32 \
+#define VDSO_ENTRY(sysinfo_ehdr) \
+ (sysinfo_ehdr + vdso_image_32.sym___kernel_vsyscall)
+
+#define ARCH_DLINFO_IA32(sysinfo_ehdr) \
do { \
- if (VDSO_CURRENT_BASE) { \
- NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \
+ if (sysinfo_ehdr) { \
+ NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY(sysinfo_ehdr)); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
} \
} while (0)

@@ -344,39 +347,31 @@ extern bool mmap_address_hint_valid(unsigned long addr, unsigned long len);
#define __STACK_RND_MASK(is32bit) ((is32bit) ? 0x7ff : 0x3fffff)
#define STACK_RND_MASK __STACK_RND_MASK(mmap_is_ia32())

-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
if (vdso64_enabled) \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (unsigned long __force)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
} while (0)

/* As a historical oddity, the x32 and x86_64 vDSOs are controlled together. */
-#define ARCH_DLINFO_X32 \
+#define ARCH_DLINFO_X32(sysinfo_ehdr) \
do { \
if (vdso64_enabled) \
- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
- (unsigned long __force)current->mm->context.vdso); \
+ NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
} while (0)

#define AT_SYSINFO 32

-#define COMPAT_ARCH_DLINFO \
+#define COMPAT_ARCH_DLINFO(sysinfo_ehdr) \
if (exec->e_machine == EM_X86_64) \
- ARCH_DLINFO_X32; \
+ ARCH_DLINFO_X32(sysinfo_ehdr); \
else \
- ARCH_DLINFO_IA32
+ ARCH_DLINFO_IA32(sysinfo_ehdr)

#define COMPAT_ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)

#endif /* !CONFIG_X86_32 */

-#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
-
-#define VDSO_ENTRY \
- ((unsigned long)current->mm->context.vdso + \
- vdso_image_32.sym___kernel_vsyscall)
-
/* Do not change the values. See get_align_mask() */
enum align_flags {
ALIGN_VA_32 = BIT(0),
diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h
index 7bc1d9d94d66..953c6b7f992e 100644
--- a/arch/x86/um/asm/elf.h
+++ b/arch/x86/um/asm/elf.h
@@ -88,7 +88,7 @@ extern unsigned long __kernel_vsyscall;
#define AT_SYSINFO 32
#define AT_SYSINFO_EHDR 33

-#define ARCH_DLINFO \
+#define ARCH_DLINFO(sysinfo_ehdr) \
do { \
if ( vsyscall_ehdr ) { \
NEW_AUX_ENT(AT_SYSINFO, __kernel_vsyscall); \
@@ -183,7 +183,7 @@ do { \

extern unsigned long um_vdso_addr;
#define AT_SYSINFO_EHDR 33
-#define ARCH_DLINFO NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr)
+#define ARCH_DLINFO(sysinfo_ehdr) NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr)

#endif

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 049ff514aa19..bc81f29b3cfb 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -171,7 +171,7 @@ static int padzero(unsigned long elf_bss)
static int
create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec,
unsigned long load_addr, unsigned long interp_load_addr,
- unsigned long e_entry)
+ unsigned long e_entry, unsigned long sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
unsigned long p = bprm->p;
@@ -251,7 +251,7 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec,
* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT() in
* ARCH_DLINFO changes
*/
- ARCH_DLINFO;
+ ARCH_DLINFO(sysinfo_ehdr);
#endif
NEW_AUX_ENT(AT_HWCAP, ELF_HWCAP);
NEW_AUX_ENT(AT_PAGESZ, ELF_EXEC_PAGESIZE);
@@ -1255,7 +1255,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
goto out;

retval = create_elf_tables(bprm, elf_ex,
- load_addr, interp_load_addr, e_entry);
+ load_addr, interp_load_addr, e_entry, sysinfo_ehdr);
if (retval < 0)
goto out;

diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index c9ee3c240855..f0e4803ab6ca 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -63,7 +63,7 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *, struct file *,

static int create_elf_fdpic_tables(struct linux_binprm *, struct mm_struct *,
struct elf_fdpic_params *,
- struct elf_fdpic_params *);
+ struct elf_fdpic_params *, unsigned long);

#ifndef CONFIG_MMU
static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *,
@@ -434,8 +434,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
current->mm->start_stack = current->mm->start_brk + stack_size;
#endif

- if (create_elf_fdpic_tables(bprm, current->mm,
- &exec_params, &interp_params) < 0)
+ if (create_elf_fdpic_tables(bprm, current->mm, &exec_params,
+ &interp_params, sysinfo_ehdr) < 0)
goto error;

kdebug("- start_code %lx", current->mm->start_code);
@@ -496,7 +496,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
static int create_elf_fdpic_tables(struct linux_binprm *bprm,
struct mm_struct *mm,
struct elf_fdpic_params *exec_params,
- struct elf_fdpic_params *interp_params)
+ struct elf_fdpic_params *interp_params,
+ unsigned long sysinfo_ehdr)
{
const struct cred *cred = current_cred();
unsigned long sp, csp, nitems;
@@ -664,7 +665,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
/* ARCH_DLINFO must come last so platform specific code can enforce
* special alignment requirements on the AUXV if necessary (eg. PPC).
*/
- ARCH_DLINFO;
+ ARCH_DLINFO(sysinfo_ehdr);
#endif
#undef NEW_AUX_ENT

--
2.28.0

2020-11-08 05:20:22

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 14/19] mm: Add user_landing in mm_struct

Instead of having every architecture to define vdso_base/vdso_addr etc,
provide a generic mechanism to track landing in userspace.
It'll minimize per-architecture difference, the number of callbacks to
provide.

Originally, it started from thread [1] where the need for .close()
callback on vm_special_mapping was pointed, this generic code besides
removing duplicated .mremap() callbacks provides a cheaper way to
support munmap() on vdso mappings without introducing .close() callbacks
for every architecture (with would bring even more code duplication).

[1]: https://lore.kernel.org/linux-arch/CAJwJo6ZANqYkSHbQ+3b+Fi_VT80MtrzEV5yreQAWx-L8j8x2zA@mail.gmail.com/
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]
Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 3 ++-
fs/aio.c | 3 ++-
include/linux/mm.h | 3 ++-
include/linux/mm_types.h | 10 ++++++++++
mm/Kconfig | 3 +++
mm/mmap.c | 19 ++++++++++++++++++-
mm/mremap.c | 2 +-
7 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
index e916646adc69..786c97203bf6 100644
--- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
+++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
@@ -1458,7 +1458,8 @@ static int pseudo_lock_dev_release(struct inode *inode, struct file *filp)
return 0;
}

-static int pseudo_lock_dev_mremap(struct vm_area_struct *area, unsigned long flags)
+static int pseudo_lock_dev_mremap(struct vm_area_struct *old_vma,
+ struct vm_area_struct *new_vma, unsigned long flags)
{
/* Not supported */
return -EINVAL;
diff --git a/fs/aio.c b/fs/aio.c
index d1dad4cd860f..2695dc9ed46f 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -324,7 +324,8 @@ static void aio_free_ring(struct kioctx *ctx)
}
}

-static int aio_ring_mremap(struct vm_area_struct *vma, unsigned long flags)
+static int aio_ring_mremap(struct vm_area_struct *old_vma,
+ struct vm_area_struct *vma, unsigned long flags)
{
struct file *file = vma->vm_file;
struct mm_struct *mm = vma->vm_mm;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 427911d2c83e..4b0f97a289b3 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -559,7 +559,8 @@ struct vm_operations_struct {
void (*close)(struct vm_area_struct * area);
/* Called any time before splitting to check if it's allowed */
int (*may_split)(struct vm_area_struct *area, unsigned long addr);
- int (*mremap)(struct vm_area_struct *area, unsigned long flags);
+ int (*mremap)(struct vm_area_struct *old_vma,
+ struct vm_area_struct *new_vma, unsigned long flags);
vm_fault_t (*fault)(struct vm_fault *vmf);
vm_fault_t (*huge_fault)(struct vm_fault *vmf,
enum page_entry_size pe_size);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index b035caff6abe..f888257e973a 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -488,6 +488,16 @@ struct mm_struct {

/* Architecture-specific MM context */
mm_context_t context;
+#ifdef CONFIG_ARCH_HAS_USER_LANDING
+ /*
+ * Address of special mapping VMA to land after processing
+ * a signal. Reads are unprotected: if a thread unmaps or
+ * mremaps the mapping while another thread is processing
+ * a signal, it can segfault while landing.
+ */
+ void __user *user_landing;
+#endif
+#define UNMAPPED_USER_LANDING TASK_SIZE_MAX

unsigned long flags; /* Must use atomic bitops to access */

diff --git a/mm/Kconfig b/mm/Kconfig
index 01b0ae0cd9d3..d43b61a21be8 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -883,4 +883,7 @@ config ARCH_HAS_HUGEPD
config MAPPING_DIRTY_HELPERS
bool

+config ARCH_HAS_USER_LANDING
+ bool
+
endmenu
diff --git a/mm/mmap.c b/mm/mmap.c
index 2376f3972f13..8a17ffdedacb 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3410,11 +3410,25 @@ void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages)

static vm_fault_t special_mapping_fault(struct vm_fault *vmf);

+static void update_user_landing(struct vm_area_struct *old_vma,
+ unsigned long new_addr)
+{
+#ifdef CONFIG_ARCH_HAS_USER_LANDING
+ struct mm_struct *mm = old_vma->vm_mm;
+
+ if (WARN_ON_ONCE(!mm))
+ return;
+ if (old_vma->vm_start == (unsigned long)mm->user_landing)
+ mm->user_landing = (void __user *)new_addr;
+#endif
+}
+
/*
* Having a close hook prevents vma merging regardless of flags.
*/
static void special_mapping_close(struct vm_area_struct *vma)
{
+ update_user_landing(vma, UNMAPPED_USER_LANDING);
}

static const char *special_mapping_name(struct vm_area_struct *vma)
@@ -3422,7 +3436,8 @@ static const char *special_mapping_name(struct vm_area_struct *vma)
return ((struct vm_special_mapping *)vma->vm_private_data)->name;
}

-static int special_mapping_mremap(struct vm_area_struct *new_vma,
+static int special_mapping_mremap(struct vm_area_struct *old_vma,
+ struct vm_area_struct *new_vma,
unsigned long flags)
{
struct vm_special_mapping *sm = new_vma->vm_private_data;
@@ -3436,6 +3451,8 @@ static int special_mapping_mremap(struct vm_area_struct *new_vma,
if (sm->mremap)
sm->mremap(sm, new_vma);

+ update_user_landing(old_vma, new_vma->vm_start);
+
return 0;
}

diff --git a/mm/mremap.c b/mm/mremap.c
index c5590afe7165..9595f6b72101 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -543,7 +543,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
if (moved_len < old_len) {
err = -ENOMEM;
} else if (vma->vm_ops && vma->vm_ops->mremap) {
- err = vma->vm_ops->mremap(new_vma, flags);
+ err = vma->vm_ops->mremap(vma, new_vma, flags);
}

if (unlikely(err)) {
--
2.28.0

2020-11-08 05:20:31

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 16/19] arm/vdso: Migrate to user_landing

Generic way to track the land vma area.
As a bonus, after unmapping sigpage, kernel won't try to land on its
previous position.

Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/arm/Kconfig | 1 +
arch/arm/kernel/process.c | 9 +--------
arch/arm/kernel/signal.c | 6 +++++-
3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bece41f3b3b9..c161d7313911 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -24,6 +24,7 @@ config ARM
select ARCH_HAS_SYNC_DMA_FOR_CPU if SWIOTLB
select ARCH_HAS_TEARDOWN_DMA_OPS if MMU
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+ select ARCH_HAS_USER_LANDING
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_HAS_GCOV_PROFILE_ALL
select ARCH_KEEP_MEMBLOCK
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 5f4eced738f5..ac08241e5cf8 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -376,16 +376,9 @@ static unsigned long sigpage_addr(const struct mm_struct *mm,
static struct page *signal_page;
extern struct page *get_signal_page(void);

-static void sigpage_mremap(const struct vm_special_mapping *sm,
- struct vm_area_struct *new_vma)
-{
- current->mm->context.sigpage = new_vma->vm_start;
-}
-
static const struct vm_special_mapping sigpage_mapping = {
.name = "[sigpage]",
.pages = &signal_page,
- .mremap = sigpage_mremap,
};

int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
@@ -423,7 +416,7 @@ int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
goto up_fail;
}

- mm->context.sigpage = addr;
+ mm->user_landing = (void __user *)addr;

/* Unlike the sigpage, failure to install the vdso is unlikely
* to be fatal to the process, so no error check needed
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 9d2e916121be..270b17a9dc0f 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -451,13 +451,17 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
#ifdef CONFIG_MMU
if (cpsr & MODE32_BIT) {
struct mm_struct *mm = current->mm;
+ unsigned long land = (unsigned long)mm->user_landing;
+
+ if (land == UNMAPPED_USER_LANDING)
+ return 1;

/*
* 32-bit code can use the signal return page
* except when the MPU has protected the vectors
* page from PL0
*/
- retcode = mm->context.sigpage + signal_return_offset +
+ retcode = land + signal_return_offset +
(idx << 2) + thumb;
} else
#endif
--
2.28.0

2020-11-08 05:20:33

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 18/19] arm64/vdso: Migrate native signals to user_landing

Generic way to track the land vma area.
As a bonus, after unmapping vdso, kernel won't try to land on its
previous position.

Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/arm64/kernel/signal.c | 10 +++++++---
arch/arm64/kernel/vdso.c | 13 +++----------
2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index bec6ef69704f..4c1dfbc1aed3 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -723,9 +723,10 @@ static int get_sigframe(struct rt_sigframe_user_layout *user,
return 0;
}

-static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
+static int setup_return(struct pt_regs *regs, struct k_sigaction *ka,
struct rt_sigframe_user_layout *user, int usig)
{
+ unsigned long land = (unsigned long)current->mm->user_landing;
__sigrestore_t sigtramp;

regs->regs[0] = usig;
@@ -754,10 +755,13 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,

if (ka->sa.sa_flags & SA_RESTORER)
sigtramp = ka->sa.sa_restorer;
+ else if (land != UNMAPPED_USER_LANDING)
+ sigtramp = VDSO_SYMBOL(land, sigtramp);
else
- sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp);
+ return 1;

regs->regs[30] = (unsigned long)sigtramp;
+ return 0;
}

static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
@@ -780,7 +784,7 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
err |= setup_sigframe(&user, regs, set);
if (err == 0) {
- setup_return(regs, &ksig->ka, &user, usig);
+ err = setup_return(regs, &ksig->ka, &user, usig);
if (ksig->ka.sa.sa_flags & SA_SIGINFO) {
err |= copy_siginfo_to_user(&frame->info, &ksig->info);
regs->regs[1] = (unsigned long)&frame->info;
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 08e8f1d56d92..d710fcd7141c 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -78,12 +78,6 @@ static union {
} vdso_data_store __page_aligned_data;
struct vdso_data *vdso_data = vdso_data_store.data;

-static void vdso_mremap(const struct vm_special_mapping *sm,
- struct vm_area_struct *new_vma)
-{
- current->mm->context.vdso = (void *)new_vma->vm_start;
-}
-
static int __vdso_init(enum vdso_abi abi)
{
int i;
@@ -239,7 +233,6 @@ static int __setup_additional_pages(enum vdso_abi abi,
gp_flags = VM_ARM64_BTI;

vdso_base += VVAR_NR_PAGES * PAGE_SIZE;
- mm->context.vdso = (void *)vdso_base;
ret = _install_special_mapping(mm, vdso_base, vdso_text_len,
VM_READ|VM_EXEC|gp_flags|
VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
@@ -247,12 +240,14 @@ static int __setup_additional_pages(enum vdso_abi abi,
if (IS_ERR(ret))
goto up_fail;

+ /* 32-bit ABI is to land on sigpage, 64-bit on vdso */
+ if (abi == VDSO_ABI_AA64)
+ mm->user_landing = (void __user *)vdso_base;
*sysinfo_ehdr = vdso_base;

return 0;

up_fail:
- mm->context.vdso = NULL;
return PTR_ERR(ret);
}

@@ -285,7 +280,6 @@ static struct vm_special_mapping aarch32_vdso_maps[] = {
},
[AA32_MAP_VDSO] = {
.name = "[vdso]",
- .mremap = vdso_mremap,
},
};

@@ -431,7 +425,6 @@ static struct vm_special_mapping aarch64_vdso_maps[] __ro_after_init = {
},
[AA64_MAP_VDSO] = {
.name = "[vdso]",
- .mremap = vdso_mremap,
},
};

--
2.28.0

2020-11-08 05:20:47

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 17/19] arm64/vdso: Migrate compat signals to user_landing

Generic way to track the land vma area.
As a bonus, after unmapping sigpage, kernel won't try to land on its
previous position.

Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/arm64/Kconfig | 1 +
arch/arm64/kernel/signal32.c | 17 ++++++++++++-----
arch/arm64/kernel/vdso.c | 2 +-
3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7111cf335ede..56505e396253 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -38,6 +38,7 @@ config ARM64
select ARCH_HAS_SYSCALL_WRAPPER
select ARCH_HAS_TEARDOWN_DMA_OPS if IOMMU_SUPPORT
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+ select ARCH_HAS_USER_LANDING
select ARCH_HAVE_ELF_PROT
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select ARCH_INLINE_READ_LOCK if !PREEMPTION
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index 2f507f565c48..61d583c73be3 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal32.c
@@ -315,7 +315,7 @@ static void __user *compat_get_sigframe(struct ksignal *ksig,
return frame;
}

-static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
+static int compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
compat_ulong_t __user *rc, void __user *frame,
int usig)
{
@@ -342,13 +342,16 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
retcode = ptr_to_compat(ka->sa.sa_restorer);
} else {
/* Set up sigreturn pointer */
+ unsigned long land = (unsigned long)current->mm->user_landing;
unsigned int idx = thumb << 1;

if (ka->sa.sa_flags & SA_SIGINFO)
idx += 3;

- retcode = (unsigned long)current->mm->context.sigpage +
- (idx << 2) + thumb;
+ if (land == UNMAPPED_USER_LANDING)
+ return 1;
+
+ retcode = land + (idx << 2) + thumb;
}

regs->regs[0] = usig;
@@ -356,6 +359,8 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
regs->compat_lr = retcode;
regs->pc = handler;
regs->pstate = spsr;
+
+ return 0;
}

static int compat_setup_sigframe(struct compat_sigframe __user *sf,
@@ -425,7 +430,8 @@ int compat_setup_rt_frame(int usig, struct ksignal *ksig,
err |= compat_setup_sigframe(&frame->sig, regs, set);

if (err == 0) {
- compat_setup_return(regs, &ksig->ka, frame->sig.retcode, frame, usig);
+ err = compat_setup_return(regs, &ksig->ka,
+ frame->sig.retcode, frame, usig);
regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info;
regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc;
}
@@ -448,7 +454,8 @@ int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set,

err |= compat_setup_sigframe(frame, regs, set);
if (err == 0)
- compat_setup_return(regs, &ksig->ka, frame->retcode, frame, usig);
+ err = compat_setup_return(regs, &ksig->ka,
+ frame->retcode, frame, usig);

return err;
}
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 91c1b7c716b7..08e8f1d56d92 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -394,7 +394,7 @@ static int aarch32_sigreturn_setup(struct mm_struct *mm)
if (IS_ERR(ret))
goto out;

- mm->context.sigpage = (void *)addr;
+ mm->user_landing = (void __user *)addr;

out:
return PTR_ERR_OR_ZERO(ret);
--
2.28.0

2020-11-08 05:20:48

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 10/19] sparc/vdso: Remove vdso pointer from mm->context

Not used any more.

Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/sparc/include/asm/mmu_64.h | 1 -
arch/sparc/vdso/vma.c | 5 +----
2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/sparc/include/asm/mmu_64.h b/arch/sparc/include/asm/mmu_64.h
index 7e2704c770e9..8e7892890d14 100644
--- a/arch/sparc/include/asm/mmu_64.h
+++ b/arch/sparc/include/asm/mmu_64.h
@@ -111,7 +111,6 @@ typedef struct {
unsigned long thp_pte_count;
struct tsb_config tsb_block[MM_NUM_TSBS];
struct hv_tsb_descr tsb_descr[MM_NUM_TSBS];
- void *vdso;
bool adi;
tag_storage_desc_t *tag_store;
spinlock_t tag_lock;
diff --git a/arch/sparc/vdso/vma.c b/arch/sparc/vdso/vma.c
index bf9195fe9bcc..255e052223ca 100644
--- a/arch/sparc/vdso/vma.c
+++ b/arch/sparc/vdso/vma.c
@@ -389,7 +389,6 @@ static int map_vdso(const struct vdso_image *image,
}

text_start = addr - image->sym_vvar_start;
- current->mm->context.vdso = (void __user *)text_start;

/*
* MAYWRITE to allow gdb to COW and set breakpoints
@@ -418,9 +417,7 @@ static int map_vdso(const struct vdso_image *image,
}

up_fail:
- if (ret)
- current->mm->context.vdso = NULL;
- else
+ if (!ret)
*sysinfo_ehdr = text_start;

mmap_write_unlock(mm);
--
2.28.0

2020-11-08 05:21:06

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 12/19] x86/signal: Land on &frame->retcode when vdso isn't mapped

Since commit 9fbbd4dd17d0 ("x86: Don't require the vDSO for handling
a.out signals") after processing 32-bit signal if there is no vdso
mapped frame->retcode is used as a landing.
Do the same for rt ia32 signals.

This shouldn't be mistaken for encouragement for running binaries with
executable stack, rather something to do in hopefully very rare
situation with disabled or unmapped vdso and absent SA_RESTORER.
For non-executable stack it'll segfault on attempt to land, rather than
land on a random address where vdso was previously mapped.
For programs with executable stack it'll just do the same for rt signals
as for non-rt.

Discouraging users to run with executable stack is done separately in
commit 47a2ebb7f505 ("execve: warn if process starts with executable
stack").

Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/x86/ia32/ia32_signal.c | 12 +++++++-----
arch/x86/kernel/signal.c | 23 ++++++++++-------------
2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 81cf22398cd1..ea3db15b57bf 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -270,8 +270,8 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
unsafe_put_user(set->sig[1], &frame->extramask[0], Efault);
unsafe_put_user(ptr_to_compat(restorer), &frame->pretcode, Efault);
/*
- * These are actually not used anymore, but left because some
- * gdb versions depend on them as a marker.
+ * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
+ * gdb uses it as a signature to notice signal handler stack frames.
*/
unsafe_put_user(*((u64 *)&code), (u64 __user *)frame->retcode, Efault);
user_access_end();
@@ -336,14 +336,16 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,

if (ksig->ka.sa.sa_flags & SA_RESTORER)
restorer = ksig->ka.sa.sa_restorer;
- else
+ else if (current->mm->context.vdso)
restorer = current->mm->context.vdso +
vdso_image_32.sym___kernel_rt_sigreturn;
+ else
+ restorer = &frame->retcode;
unsafe_put_user(ptr_to_compat(restorer), &frame->pretcode, Efault);

/*
- * Not actually used anymore, but left because some gdb
- * versions need it.
+ * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
+ * gdb uses it as a signature to notice signal handler stack frames.
*/
unsafe_put_user(*((u64 *)&code), (u64 __user *)frame->retcode, Efault);
unsafe_put_sigcontext32(&frame->uc.uc_mcontext, fp, regs, set, Efault);
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index ea794a083c44..372ec09dc4ac 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -317,23 +317,20 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
unsafe_put_user(sig, &frame->sig, Efault);
unsafe_put_sigcontext(&frame->sc, fp, regs, set, Efault);
unsafe_put_user(set->sig[1], &frame->extramask[0], Efault);
- if (current->mm->context.vdso)
+ if (ksig->ka.sa.sa_flags & SA_RESTORER)
+ restorer = ksig->ka.sa.sa_restorer;
+ else if (current->mm->context.vdso)
restorer = current->mm->context.vdso +
vdso_image_32.sym___kernel_sigreturn;
else
restorer = &frame->retcode;
- if (ksig->ka.sa.sa_flags & SA_RESTORER)
- restorer = ksig->ka.sa.sa_restorer;

/* Set up to return from userspace. */
unsafe_put_user(restorer, &frame->pretcode, Efault);

/*
* This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
- *
- * WE DO NOT USE IT ANY MORE! It's only left here for historical
- * reasons and because gdb uses it as a signature to notice
- * signal handler stack frames.
+ * gdb uses it as a signature to notice signal handler stack frames.
*/
unsafe_put_user(*((u64 *)&retcode), (u64 *)frame->retcode, Efault);
user_access_end();
@@ -382,18 +379,18 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
unsafe_save_altstack(&frame->uc.uc_stack, regs->sp, Efault);

/* Set up to return from userspace. */
- restorer = current->mm->context.vdso +
- vdso_image_32.sym___kernel_rt_sigreturn;
if (ksig->ka.sa.sa_flags & SA_RESTORER)
restorer = ksig->ka.sa.sa_restorer;
+ else if (current->mm->context.vdso)
+ restorer = current->mm->context.vdso +
+ vdso_image_32.sym___kernel_rt_sigreturn;
+ else
+ restorer = &frame->retcode;
unsafe_put_user(restorer, &frame->pretcode, Efault);

/*
* This is movl $__NR_rt_sigreturn, %ax ; int $0x80
- *
- * WE DO NOT USE IT ANY MORE! It's only left here for historical
- * reasons and because gdb uses it as a signature to notice
- * signal handler stack frames.
+ * gdb uses it as a signature to notice signal handler stack frames.
*/
unsafe_put_user(*((u64 *)&rt_retcode), (u64 *)frame->retcode, Efault);
unsafe_put_sigcontext(&frame->uc.uc_mcontext, fp, regs, set, Efault);
--
2.28.0

2020-11-08 05:21:28

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 06/19] elf/vdso: Reuse arch_setup_additional_pages() parameters

Both parameters of arch_setup_additional_pages() are currently unused.
commit fc5243d98ac2 ("[S390] arch_setup_additional_pages arguments")
tried to introduce useful arguments, but they still are not used.

Remove old parameters and introduce sysinfo_ehdr argument that will be
used to return vdso address to put as AT_SYSINFO_EHDR tag in auxiliary
vector. The reason to do it is that many architecture have vDSO pointer
saved in their mm->context with the only purpose to use it later
in ARCH_DLINFO. That's the macro for elf loader to setup sysinfo_ehdr
tag.

Return sysinfo_ehdr address that will be later used by ARCH_DLINFO as
an argument. That will allow to drop vDSO pointer from mm.context
and any code responsible to track vDSO position on platforms that
don't use vDSO as a landing in userspace (arm/s390/sparc).

Cc: Albert Ou <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: [email protected]
Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/arm/include/asm/vdso.h | 6 ++++--
arch/arm/kernel/process.c | 4 ++--
arch/arm/kernel/vdso.c | 10 +++++++---
arch/arm64/kernel/vdso.c | 17 ++++++++--------
arch/csky/kernel/vdso.c | 3 ++-
arch/hexagon/kernel/vdso.c | 3 ++-
arch/mips/kernel/vdso.c | 3 ++-
arch/nds32/kernel/vdso.c | 3 ++-
arch/nios2/mm/init.c | 2 +-
arch/powerpc/kernel/vdso.c | 3 ++-
arch/riscv/kernel/vdso.c | 9 +++++----
arch/s390/kernel/vdso.c | 3 ++-
arch/sh/kernel/vsyscall/vsyscall.c | 3 ++-
arch/sparc/vdso/vma.c | 15 +++++++-------
arch/x86/entry/vdso/vma.c | 32 +++++++++++++++++-------------
arch/x86/um/vdso/vma.c | 2 +-
fs/binfmt_elf.c | 3 ++-
fs/binfmt_elf_fdpic.c | 3 ++-
include/linux/elf.h | 17 +++++++++++-----
19 files changed, 84 insertions(+), 57 deletions(-)

diff --git a/arch/arm/include/asm/vdso.h b/arch/arm/include/asm/vdso.h
index 5b85889f82ee..6b2b3b1fe833 100644
--- a/arch/arm/include/asm/vdso.h
+++ b/arch/arm/include/asm/vdso.h
@@ -10,13 +10,15 @@ struct mm_struct;

#ifdef CONFIG_VDSO

-void arm_install_vdso(struct mm_struct *mm, unsigned long addr);
+void arm_install_vdso(struct mm_struct *mm, unsigned long addr,
+ unsigned long *sysinfo_ehdr);

extern unsigned int vdso_total_pages;

#else /* CONFIG_VDSO */

-static inline void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
+static inline void arm_install_vdso(struct mm_struct *mm, unsigned long addr,
+ unsigned long *sysinfo_ehdr)
{
}

diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index d0220da1d1b1..0e90cba8ac7a 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -389,7 +389,7 @@ static const struct vm_special_mapping sigpage_mapping = {
.mremap = sigpage_mremap,
};

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
@@ -430,7 +430,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
* to be fatal to the process, so no error check needed
* here.
*/
- arm_install_vdso(mm, addr + PAGE_SIZE);
+ arm_install_vdso(mm, addr + PAGE_SIZE, sysinfo_ehdr);

up_fail:
mmap_write_unlock(mm);
diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index 3408269d19c7..710e5ca99a53 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -233,7 +233,8 @@ static int install_vvar(struct mm_struct *mm, unsigned long addr)
}

/* assumes mmap_lock is write-locked */
-void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
+void arm_install_vdso(struct mm_struct *mm, unsigned long addr,
+ unsigned long *sysinfo_ehdr)
{
struct vm_area_struct *vma;
unsigned long len;
@@ -254,7 +255,10 @@ void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
&vdso_text_mapping);

- if (!IS_ERR(vma))
- mm->context.vdso = addr;
+ if (IS_ERR(vma))
+ return;
+
+ mm->context.vdso = addr;
+ *sysinfo_ehdr = addr;
}

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 1b710deb84d6..666338724a07 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -213,8 +213,7 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,

static int __setup_additional_pages(enum vdso_abi abi,
struct mm_struct *mm,
- struct linux_binprm *bprm,
- int uses_interp)
+ unsigned long *sysinfo_ehdr)
{
unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
unsigned long gp_flags = 0;
@@ -250,6 +249,8 @@ static int __setup_additional_pages(enum vdso_abi abi,
if (IS_ERR(ret))
goto up_fail;

+ *sysinfo_ehdr = vdso_base;
+
return 0;

up_fail:
@@ -401,8 +402,7 @@ static int aarch32_sigreturn_setup(struct mm_struct *mm)
return PTR_ERR_OR_ZERO(ret);
}

-static int aarch32_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp)
+static int aarch32_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
int ret;
@@ -412,8 +412,7 @@ static int aarch32_setup_additional_pages(struct linux_binprm *bprm,
return ret;

if (IS_ENABLED(CONFIG_COMPAT_VDSO)) {
- ret = __setup_additional_pages(VDSO_ABI_AA32, mm, bprm,
- uses_interp);
+ ret = __setup_additional_pages(VDSO_ABI_AA32, mm, sysinfo_ehdr);
if (ret)
return ret;
}
@@ -447,7 +446,7 @@ static int __init vdso_init(void)
}
arch_initcall(vdso_init);

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
int ret;
@@ -456,9 +455,9 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
return -EINTR;

if (is_compat_task())
- ret = aarch32_setup_additional_pages(bprm, uses_interp);
+ ret = aarch32_setup_additional_pages(sysinfo_ehdr);
else
- ret = __setup_additional_pages(VDSO_ABI_AA64, mm, bprm, uses_interp);
+ ret = __setup_additional_pages(VDSO_ABI_AA64, mm, sysinfo_ehdr);

mmap_write_unlock(mm);

diff --git a/arch/csky/kernel/vdso.c b/arch/csky/kernel/vdso.c
index abc3dbc658d4..f72f76915c59 100644
--- a/arch/csky/kernel/vdso.c
+++ b/arch/csky/kernel/vdso.c
@@ -44,7 +44,7 @@ static int __init init_vdso(void)
}
subsys_initcall(init_vdso);

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
int ret;
unsigned long addr;
@@ -68,6 +68,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
goto up_fail;

mm->context.vdso = (void *)addr;
+ *sysinfo_ehdr = addr;

up_fail:
mmap_write_unlock(mm);
diff --git a/arch/hexagon/kernel/vdso.c b/arch/hexagon/kernel/vdso.c
index b70970ac809f..39e78fe82b99 100644
--- a/arch/hexagon/kernel/vdso.c
+++ b/arch/hexagon/kernel/vdso.c
@@ -46,7 +46,7 @@ arch_initcall(vdso_init);
/*
* Called from binfmt_elf. Create a VMA for the vDSO page.
*/
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
int ret;
unsigned long vdso_base;
@@ -74,6 +74,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
goto up_fail;

mm->context.vdso = (void *)vdso_base;
+ *sysinfo_ehdr = vdso_base;

up_fail:
mmap_write_unlock(mm);
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index 242dc5e83847..a4a321252df6 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -86,7 +86,7 @@ static unsigned long vdso_base(void)
return base;
}

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mips_vdso_image *image = current->thread.abi->vdso;
struct mm_struct *mm = current->mm;
@@ -184,6 +184,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
}

mm->context.vdso = (void *)vdso_addr;
+ *sysinfo_ehdr = vdso_addr;
ret = 0;

out:
diff --git a/arch/nds32/kernel/vdso.c b/arch/nds32/kernel/vdso.c
index e16009a07971..530164221166 100644
--- a/arch/nds32/kernel/vdso.c
+++ b/arch/nds32/kernel/vdso.c
@@ -111,7 +111,7 @@ unsigned long inline vdso_random_addr(unsigned long vdso_mapping_len)
return addr;
}

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
@@ -176,6 +176,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
/*Map vdso to user space */
vdso_base += PAGE_SIZE;
mm->context.vdso = (void *)vdso_base;
+ *sysinfo_ehdr = vdso_base;
vma = _install_special_mapping(mm, vdso_base, vdso_text_len,
VM_READ | VM_EXEC |
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c
index 61862dbb0e32..e09e54198ac6 100644
--- a/arch/nios2/mm/init.c
+++ b/arch/nios2/mm/init.c
@@ -104,7 +104,7 @@ static int alloc_kuser_page(void)
}
arch_initcall(alloc_kuser_page);

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
int ret;
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 8dad44262e75..0ec3bbe7fb36 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -122,7 +122,7 @@ struct lib64_elfinfo
* This is called from binfmt_elf, we create the special vma for the
* vDSO and insert it into the mm struct tree
*/
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
struct page **vdso_pagelist;
@@ -211,6 +211,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
}

mmap_write_unlock(mm);
+ *sysinfo_ehdr = vdso_base;
return 0;

fail_mmapsem:
diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c
index 678204231700..d5c741e3cde6 100644
--- a/arch/riscv/kernel/vdso.c
+++ b/arch/riscv/kernel/vdso.c
@@ -56,11 +56,10 @@ static int __init vdso_init(void)
}
arch_initcall(vdso_init);

-int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
- unsigned long vdso_base, vdso_len;
+ unsigned long vdso_base, vvar_base, vdso_len;
int ret;

vdso_len = (vdso_pages + 1) << PAGE_SHIFT;
@@ -89,12 +88,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
goto end;
}

- vdso_base += (vdso_pages << PAGE_SHIFT);
+ vvar_base = vdso_base + (vdso_pages << PAGE_SHIFT);
ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
(VM_READ | VM_MAYREAD), &vdso_pagelist[vdso_pages]);

if (unlikely(ret))
mm->context.vdso = NULL;
+ else
+ *sysinfo_ehdr = vdso_base;
end:
mmap_write_unlock(mm);
return ret;
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index 6c9ec9521203..810b72f8985c 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -150,7 +150,7 @@ void vdso_free_per_cpu(struct lowcore *lowcore)
* This is called from binfmt_elf, we create the special vma for the
* vDSO and insert it into the mm struct tree
*/
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
@@ -205,6 +205,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
}

current->mm->context.vdso_base = vdso_base;
+ *sysinfo_ehdr = vdso_base;
rc = 0;

out_up:
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c
index 1bd85a6949c4..de8df3261b4f 100644
--- a/arch/sh/kernel/vsyscall/vsyscall.c
+++ b/arch/sh/kernel/vsyscall/vsyscall.c
@@ -55,7 +55,7 @@ int __init vsyscall_init(void)
}

/* Setup a VMA at program startup for the vsyscall page */
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
unsigned long addr;
@@ -78,6 +78,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
goto up_fail;

current->mm->context.vdso = (void *)addr;
+ *sysinfo_ehdr = addr;

up_fail:
mmap_write_unlock(mm);
diff --git a/arch/sparc/vdso/vma.c b/arch/sparc/vdso/vma.c
index cc19e09b0fa1..bf9195fe9bcc 100644
--- a/arch/sparc/vdso/vma.c
+++ b/arch/sparc/vdso/vma.c
@@ -346,8 +346,6 @@ static int __init init_vdso(void)
}
subsys_initcall(init_vdso);

-struct linux_binprm;
-
/* Shuffle the vdso up a bit, randomly. */
static unsigned long vdso_addr(unsigned long start, unsigned int len)
{
@@ -359,7 +357,8 @@ static unsigned long vdso_addr(unsigned long start, unsigned int len)
}

static int map_vdso(const struct vdso_image *image,
- struct vm_special_mapping *vdso_mapping)
+ struct vm_special_mapping *vdso_mapping,
+ unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
@@ -421,12 +420,14 @@ static int map_vdso(const struct vdso_image *image,
up_fail:
if (ret)
current->mm->context.vdso = NULL;
+ else
+ *sysinfo_ehdr = text_start;

mmap_write_unlock(mm);
return ret;
}

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{

if (!vdso_enabled)
@@ -434,11 +435,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)

#if defined CONFIG_COMPAT
if (!(is_32bit_task()))
- return map_vdso(&vdso_image_64_builtin, &vdso_mapping64);
+ return map_vdso(&vdso_image_64_builtin, &vdso_mapping64, sysinfo_ehdr);
else
- return map_vdso(&vdso_image_32_builtin, &vdso_mapping32);
+ return map_vdso(&vdso_image_32_builtin, &vdso_mapping32, sysinfo_ehdr);
#else
- return map_vdso(&vdso_image_64_builtin, &vdso_mapping64);
+ return map_vdso(&vdso_image_64_builtin, &vdso_mapping64, sysinfo_ehdr);
#endif

}
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index aace862ed9a1..5b9020742e66 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -243,7 +243,8 @@ static const struct vm_special_mapping vvar_mapping = {
* @image - blob to map
* @addr - request a specific address (zero to map at free addr)
*/
-static int map_vdso(const struct vdso_image *image, unsigned long addr)
+static int map_vdso(const struct vdso_image *image, unsigned long addr,
+ unsigned long *sysinfo_ehdr)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
@@ -290,6 +291,7 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
} else {
current->mm->context.vdso = (void __user *)text_start;
current->mm->context.vdso_image = image;
+ *sysinfo_ehdr = text_start;
}

up_fail:
@@ -342,11 +344,12 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
return addr;
}

-static int map_vdso_randomized(const struct vdso_image *image)
+static int map_vdso_randomized(const struct vdso_image *image,
+ unsigned long *sysinfo_ehdr)
{
unsigned long addr = vdso_addr(current->mm->start_stack, image->size-image->sym_vvar_start);

- return map_vdso(image, addr);
+ return map_vdso(image, addr, sysinfo_ehdr);
}
#endif

@@ -354,6 +357,7 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
+ unsigned long unused;

mmap_write_lock(mm);
/*
@@ -372,19 +376,19 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)
}
mmap_write_unlock(mm);

- return map_vdso(image, addr);
+ return map_vdso(image, addr, &unused);
}

#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
-static int load_vdso_ia32(void)
+static int load_vdso_ia32(unsigned long *sysinfo_ehdr)
{
if (vdso32_enabled != 1) /* Other values all mean "disabled" */
return 0;

- return map_vdso(&vdso_image_32, 0);
+ return map_vdso(&vdso_image_32, 0, sysinfo_ehdr);
}
#else
-static int load_vdso_ia32(void)
+static int load_vdso_ia32(unsigned long *sysinfo_ehdr)
{
WARN_ON_ONCE(1);
return -ENODATA;
@@ -392,32 +396,32 @@ static int load_vdso_ia32(void)
#endif

#ifdef CONFIG_X86_64
-static int load_vdso_64(void)
+static int load_vdso_64(unsigned long *sysinfo_ehdr)
{
if (!vdso64_enabled)
return 0;

#ifdef CONFIG_X86_X32_ABI
if (in_x32_syscall())
- return map_vdso_randomized(&vdso_image_x32);
+ return map_vdso_randomized(&vdso_image_x32, sysinfo_ehdr);
#endif

- return map_vdso_randomized(&vdso_image_64);
+ return map_vdso_randomized(&vdso_image_64, sysinfo_ehdr);
}
#else
-static int load_vdso_64(void)
+static int load_vdso_64(unsigned long *sysinfo_ehdr)
{
WARN_ON_ONCE(1);
return -ENODATA;
}
#endif

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
if (in_ia32_syscall())
- return load_vdso_ia32();
+ return load_vdso_ia32(sysinfo_ehdr);

- return load_vdso_64();
+ return load_vdso_64(sysinfo_ehdr);
}

#ifdef CONFIG_X86_64
diff --git a/arch/x86/um/vdso/vma.c b/arch/x86/um/vdso/vma.c
index 76d9f6ce7a3d..77488065f7cc 100644
--- a/arch/x86/um/vdso/vma.c
+++ b/arch/x86/um/vdso/vma.c
@@ -50,7 +50,7 @@ static int __init init_vdso(void)
}
subsys_initcall(init_vdso);

-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
{
int err;
struct mm_struct *mm = current->mm;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index b9adbeb59101..049ff514aa19 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -833,6 +833,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
unsigned long interp_load_addr = 0;
unsigned long start_code, end_code, start_data, end_data;
unsigned long reloc_func_desc __maybe_unused = 0;
+ unsigned long sysinfo_ehdr = 0;
int executable_stack = EXSTACK_DEFAULT;
struct elfhdr *elf_ex = (struct elfhdr *)bprm->buf;
struct elfhdr *interp_elf_ex = NULL;
@@ -1249,7 +1250,7 @@ static int load_elf_binary(struct linux_binprm *bprm)

set_binfmt(&elf_format);

- retval = arch_setup_additional_pages(bprm, !!interpreter);
+ retval = arch_setup_additional_pages(&sysinfo_ehdr);
if (retval < 0)
goto out;

diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index b9a6d1b2b5bb..c9ee3c240855 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -183,6 +183,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
{
struct elf_fdpic_params exec_params, interp_params;
struct pt_regs *regs = current_pt_regs();
+ unsigned long sysinfo_ehdr = 0;
struct elf_phdr *phdr;
unsigned long stack_size, entryaddr;
#ifdef ELF_FDPIC_PLAT_INIT
@@ -375,7 +376,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
if (retval < 0)
goto error;

- retval = arch_setup_additional_pages(bprm, !!interpreter_name);
+ retval = arch_setup_additional_pages(&sysinfo_ehdr);
if (retval < 0)
goto error;
#endif
diff --git a/include/linux/elf.h b/include/linux/elf.h
index 95bf7a1abaef..f9b561bb395d 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -104,13 +104,20 @@ static inline int arch_elf_adjust_prot(int prot,
}
#endif

-struct linux_binprm;
#ifdef CONFIG_ARCH_HAS_SETUP_ADDITIONAL_PAGES
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
+/**
+ * arch_setup_additional_pages - Premap VMAs in a new-execed process
+ * @sysinfo_ehdr: Returns vDSO position to be set in the initial
+ * auxiliary vector (tag AT_SYSINFO_EHDR) by binfmt
+ * loader. On failure isn't initialized.
+ * As address == 0 is never used, it allows to check
+ * if the tag should be set.
+ *
+ * Return: Zero if successful, or a negative error code on failure.
+ */
+extern int arch_setup_additional_pages(unsigned long *sysinfo_ehdr);
#else
-static inline int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp)
+static inline int arch_setup_additional_pages(unsigned long *sysinfo_ehdr);
{
return 0;
}
--
2.28.0

2020-11-08 05:21:29

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 05/19] elf: Remove compat_arch_setup_additional_pages()

Now that all users rely on detecting bitness of new-born task checking
personality, remove compat_arch_setup_additional_pages() macro,
simplifying the code.

Signed-off-by: Dmitry Safonov <[email protected]>
---
fs/compat_binfmt_elf.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
index 3606dd3a32f5..da8ee4d6e451 100644
--- a/fs/compat_binfmt_elf.c
+++ b/fs/compat_binfmt_elf.c
@@ -115,11 +115,6 @@
#define START_THREAD COMPAT_START_THREAD
#endif

-#ifdef compat_arch_setup_additional_pages
-#undef arch_setup_additional_pages
-#define arch_setup_additional_pages compat_arch_setup_additional_pages
-#endif
-
#ifdef compat_elf_read_implies_exec
#undef elf_read_implies_exec
#define elf_read_implies_exec compat_elf_read_implies_exec
--
2.28.0

2020-11-08 05:22:28

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 01/19] x86/elf: Check in_x32_syscall() in compat_arch_setup_additional_pages()

Partly revert commit 3316ec8ccd34 ("x86/elf: Use e_machine to check for
x32/ia32 in setup_additional_pages()") and commit 9a29a671902c ("elf:
Expose ELF header on arch_setup_additional_pages()".
Both patches did a good thing: removed usage of TIF_X32, but with
a price of additional macros ARCH_SETUP_ADDITIONAL_PAGES() and ifdeffs.

Instead, use in_x32_syscall() - the first thing load_elf_binary() does
after parsing and checking new ELF binary. It's done that early which
also allows to use it in mmap() code straight away, which needs it
to know which mmap_base to use (see arch_pick_mmap_layout()).
Add comments that describe how it works.

Cc: [email protected]
Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/x86/entry/vdso/vma.c | 4 ++--
arch/x86/include/asm/compat.h | 6 ++++++
arch/x86/include/asm/elf.h | 6 ++----
fs/binfmt_elf.c | 10 +++++++---
fs/compat_binfmt_elf.c | 11 +++--------
include/linux/elf.h | 5 -----
6 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 44de75b21fab..4eea508e9b10 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -396,10 +396,10 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)

#ifdef CONFIG_COMPAT
int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp, bool x32)
+ int uses_interp)
{
#ifdef CONFIG_X86_X32_ABI
- if (x32) {
+ if (in_x32_syscall()) {
if (!vdso64_enabled)
return 0;
return map_vdso_randomized(&vdso_image_x32);
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index f145e3326c6d..4489bd60640b 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -197,6 +197,12 @@ static inline bool in_x32_syscall(void)
return false;
}

+/*
+ * Valid all time on the context of process that performs a syscall.
+ * Just born process has __X32_SYSCALL_BIT or TS_COMPAT set very
+ * early in load_binary() on setting personality and flags.
+ * See also set_personality_ia32().
+ */
static inline bool in_32bit_syscall(void)
{
return in_ia32_syscall() || in_x32_syscall();
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 44a9b9940535..109697a19eb1 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -383,10 +383,8 @@ struct linux_binprm;
extern int arch_setup_additional_pages(struct linux_binprm *bprm,
int uses_interp);
extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp, bool x32);
-#define COMPAT_ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \
- compat_arch_setup_additional_pages(bprm, interpreter, \
- (ex->e_machine == EM_X86_64))
+ int uses_interp);
+#define compat_arch_setup_additional_pages compat_arch_setup_additional_pages

/* Do not change the values. See get_align_mask() */
enum align_flags {
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index ac0b5fc30ea6..3de72c0e0406 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -999,8 +999,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
if (retval)
goto out_free_dentry;

- /* Do this immediately, since STACK_TOP as used in setup_arg_pages
- may depend on the personality. */
+ /*
+ * Do this immediately, since STACK_TOP as used in setup_arg_pages
+ * may depend on the personality. At this moment we start
+ * pretending that we are in a context of compat syscall for
+ * compatible applications on x86, in_compat_syscall() starts working.
+ */
SET_PERSONALITY2(*elf_ex, &arch_state);
if (elf_read_implies_exec(*elf_ex, executable_stack))
current->personality |= READ_IMPLIES_EXEC;
@@ -1246,7 +1250,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
set_binfmt(&elf_format);

#ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES
- retval = ARCH_SETUP_ADDITIONAL_PAGES(bprm, elf_ex, !!interpreter);
+ retval = arch_setup_additional_pages(bprm, !!interpreter);
if (retval < 0)
goto out;
#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */
diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
index 2c557229696a..12b991368f0a 100644
--- a/fs/compat_binfmt_elf.c
+++ b/fs/compat_binfmt_elf.c
@@ -115,16 +115,11 @@
#define START_THREAD COMPAT_START_THREAD
#endif

-#ifdef compat_arch_setup_additional_pages
-#define COMPAT_ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \
- compat_arch_setup_additional_pages(bprm, interpreter)
-#endif
-
-#ifdef COMPAT_ARCH_SETUP_ADDITIONAL_PAGES
+#ifdef compat_arch_setup_additional_pages
#undef ARCH_HAS_SETUP_ADDITIONAL_PAGES
#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-#undef ARCH_SETUP_ADDITIONAL_PAGES
-#define ARCH_SETUP_ADDITIONAL_PAGES COMPAT_ARCH_SETUP_ADDITIONAL_PAGES
+#undef arch_setup_additional_pages
+#define arch_setup_additional_pages compat_arch_setup_additional_pages
#endif

#ifdef compat_elf_read_implies_exec
diff --git a/include/linux/elf.h b/include/linux/elf.h
index c9a46c4e183b..6dbcfe7a3fd7 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -27,11 +27,6 @@
start_thread(regs, elf_entry, start_stack)
#endif

-#if defined(ARCH_HAS_SETUP_ADDITIONAL_PAGES) && !defined(ARCH_SETUP_ADDITIONAL_PAGES)
-#define ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \
- arch_setup_additional_pages(bprm, interpreter)
-#endif
-
#define ELF32_GNU_PROPERTY_ALIGN 4
#define ELF64_GNU_PROPERTY_ALIGN 8

--
2.28.0

2020-11-08 05:22:37

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 19/19] mips/vdso: Migrate to user_landing

Generic way to track the land vma area.
As a bonus, after unmapping sigpage, kernel won't try to land on its
previous position.

Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]
Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/mips/Kconfig | 1 +
arch/mips/kernel/signal.c | 11 +++++++----
arch/mips/kernel/vdso.c | 2 +-
arch/mips/vdso/genvdso.c | 8 --------
4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5e696ab80df4..eedb1683ec8e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -10,6 +10,7 @@ config MIPS
select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAS_UBSAN_SANITIZE_ALL
+ select ARCH_HAS_USER_LANDING
select ARCH_SUPPORTS_UPROBES
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_CMPXCHG_LOCKREF if 64BIT
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index f1e985109da0..eb79272d3cc2 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -806,11 +806,13 @@ struct mips_abi mips_abi = {

static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
{
+ unsigned long land = (unsigned long)current->mm->user_landing;
sigset_t *oldset = sigmask_to_save();
- int ret;
+ int ret = 1;
struct mips_abi *abi = current->thread.abi;
- void *vdso = current->mm->context.vdso;

+ if (land == UNMAPPED_USER_LANDING)
+ goto err;
/*
* If we were emulating a delay slot instruction, exit that frame such
* that addresses in the sigframe are as expected for userland and we
@@ -843,12 +845,13 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
rseq_signal_deliver(ksig, regs);

if (sig_uses_siginfo(&ksig->ka, abi))
- ret = abi->setup_rt_frame(vdso + abi->vdso->off_rt_sigreturn,
+ ret = abi->setup_rt_frame(land + abi->vdso->off_rt_sigreturn,
ksig, regs, oldset);
else
- ret = abi->setup_frame(vdso + abi->vdso->off_sigreturn,
+ ret = abi->setup_frame(land + abi->vdso->off_sigreturn,
ksig, regs, oldset);

+err:
signal_setup_done(ret, ksig, 0);
}

diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index a4a321252df6..5523ba25ab3d 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -183,7 +183,7 @@ int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
goto out;
}

- mm->context.vdso = (void *)vdso_addr;
+ mm->user_landing = (void __user *)vdso_addr;
*sysinfo_ehdr = vdso_addr;
ret = 0;

diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c
index 0303d30cde03..8f581a2c8578 100644
--- a/arch/mips/vdso/genvdso.c
+++ b/arch/mips/vdso/genvdso.c
@@ -259,13 +259,6 @@ int main(int argc, char **argv)
fprintf(out_file, "#include <linux/linkage.h>\n");
fprintf(out_file, "#include <linux/mm.h>\n");
fprintf(out_file, "#include <asm/vdso.h>\n");
- fprintf(out_file, "static void vdso_mremap(\n");
- fprintf(out_file, " const struct vm_special_mapping *sm,\n");
- fprintf(out_file, " struct vm_area_struct *new_vma)\n");
- fprintf(out_file, "{\n");
- fprintf(out_file, " current->mm->context.vdso =\n");
- fprintf(out_file, " (void *)(new_vma->vm_start);\n");
- fprintf(out_file, "}\n");

/* Write out the stripped VDSO data. */
fprintf(out_file,
@@ -290,7 +283,6 @@ int main(int argc, char **argv)
fprintf(out_file, "\t.mapping = {\n");
fprintf(out_file, "\t\t.name = \"[vdso]\",\n");
fprintf(out_file, "\t\t.pages = vdso_pages,\n");
- fprintf(out_file, "\t\t.mremap = vdso_mremap,\n");
fprintf(out_file, "\t},\n");

/* Calculate and write symbol offsets to <output file> */
--
2.28.0

2020-11-08 05:22:44

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 09/19] s390/vdso: Remove vdso_base pointer from mm->context

Not used any more.

Cc: Christian Borntraeger <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: [email protected]
Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/s390/include/asm/mmu.h | 1 -
arch/s390/kernel/vdso.c | 10 ----------
2 files changed, 11 deletions(-)

diff --git a/arch/s390/include/asm/mmu.h b/arch/s390/include/asm/mmu.h
index e12ff0f29d1a..095d0596f700 100644
--- a/arch/s390/include/asm/mmu.h
+++ b/arch/s390/include/asm/mmu.h
@@ -15,7 +15,6 @@ typedef struct {
unsigned long gmap_asce;
unsigned long asce;
unsigned long asce_limit;
- unsigned long vdso_base;
/* The mmu context belongs to a secure guest. */
atomic_t is_protected;
/*
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index 810b72f8985c..3f07711a07c1 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -58,18 +58,9 @@ static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
return 0;
}

-static int vdso_mremap(const struct vm_special_mapping *sm,
- struct vm_area_struct *vma)
-{
- current->mm->context.vdso_base = vma->vm_start;
-
- return 0;
-}
-
static const struct vm_special_mapping vdso_mapping = {
.name = "[vdso]",
.fault = vdso_fault,
- .mremap = vdso_mremap,
};

static int __init vdso_setup(char *str)
@@ -204,7 +195,6 @@ int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
goto out_up;
}

- current->mm->context.vdso_base = vdso_base;
*sysinfo_ehdr = vdso_base;
rc = 0;

--
2.28.0

2020-11-08 05:24:12

by Dmitry Safonov

[permalink] [raw]
Subject: [PATCH 02/19] elf: Move arch_setup_additional_pages() to generic elf.h

Ifdef the function in the header, not in the code.
Following kernel style, move it to Kconfig.
All it makes it easier to follow when the option is enabled/disabled.
Remove re-definition from compat_binfmt_elf, as it's always defined
under compat_arch_setup_additional_pages (to be reworked).

Signed-off-by: Dmitry Safonov <[email protected]>
---
arch/arm/Kconfig | 1 +
arch/arm/include/asm/elf.h | 5 -----
arch/arm64/Kconfig | 1 +
arch/arm64/include/asm/elf.h | 6 +-----
arch/csky/Kconfig | 1 +
arch/csky/include/asm/elf.h | 4 ----
arch/hexagon/Kconfig | 1 +
arch/hexagon/include/asm/elf.h | 6 ------
arch/mips/Kconfig | 1 +
arch/mips/include/asm/elf.h | 5 -----
arch/nds32/Kconfig | 1 +
arch/nds32/include/asm/elf.h | 3 ---
arch/nios2/Kconfig | 1 +
arch/nios2/include/asm/elf.h | 4 ----
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/elf.h | 5 -----
arch/riscv/Kconfig | 1 +
arch/riscv/include/asm/elf.h | 5 -----
arch/s390/Kconfig | 1 +
arch/s390/include/asm/elf.h | 5 -----
arch/sh/Kconfig | 1 +
arch/sh/include/asm/elf.h | 6 ------
arch/sparc/Kconfig | 1 +
arch/sparc/include/asm/elf_64.h | 6 ------
arch/x86/Kconfig | 1 +
arch/x86/include/asm/elf.h | 4 ----
arch/x86/um/asm/elf.h | 5 -----
fs/Kconfig.binfmt | 3 +++
fs/binfmt_elf.c | 2 --
fs/binfmt_elf_fdpic.c | 3 +--
fs/compat_binfmt_elf.c | 2 --
include/linux/elf.h | 12 ++++++++++++
32 files changed, 30 insertions(+), 74 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fb700e471332..bece41f3b3b9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -15,6 +15,7 @@ config ARM
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
select ARCH_HAS_PHYS_TO_DMA
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES if MMU
select ARCH_HAS_SETUP_DMA_OPS
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 61941f369861..1f4b91a17a91 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -132,7 +132,6 @@ extern int arm_elf_read_implies_exec(int);
extern void elf_set_personality(const struct elf32_hdr *);
#define SET_PERSONALITY(ex) elf_set_personality(&(ex))

-#ifdef CONFIG_MMU
#ifdef CONFIG_VDSO
#define ARCH_DLINFO \
do { \
@@ -140,9 +139,5 @@ do { \
(elf_addr_t)current->mm->context.vdso); \
} while (0)
#endif
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-struct linux_binprm;
-int arch_setup_additional_pages(struct linux_binprm *, int);
-#endif

#endif
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index d1b81221c6a9..7111cf335ede 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -26,6 +26,7 @@ config ARM64
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
select ARCH_HAS_PTE_DEVMAP
select ARCH_HAS_PTE_SPECIAL
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_SETUP_DMA_OPS
select ARCH_HAS_SET_DIRECT_MAP
select ARCH_HAS_SET_MEMORY
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 8d1c8dcb87fd..d1073ffa7f24 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -181,11 +181,6 @@ do { \
NEW_AUX_ENT(AT_IGNORE, 0); \
} while (0)

-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-
/* 1GB of VA */
#ifdef CONFIG_COMPAT
#define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \
@@ -242,6 +237,7 @@ do { \
#else
#define COMPAT_ARCH_DLINFO
#endif
+struct linux_binprm;
extern int aarch32_setup_additional_pages(struct linux_binprm *bprm,
int uses_interp);
#define compat_arch_setup_additional_pages \
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 8fec85ab5da6..00e7b063f6ca 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -4,6 +4,7 @@ config CSKY
select ARCH_32BIT_OFF_T
select ARCH_HAS_DMA_PREP_COHERENT
select ARCH_HAS_GCOV_PROFILE_ALL
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_USE_BUILTIN_BSWAP
diff --git a/arch/csky/include/asm/elf.h b/arch/csky/include/asm/elf.h
index eb2cc5a673b5..8ec675f8d0d9 100644
--- a/arch/csky/include/asm/elf.h
+++ b/arch/csky/include/asm/elf.h
@@ -84,8 +84,4 @@ extern int dump_task_regs(struct task_struct *tsk, elf_gregset_t *elf_regs);
#define ELF_PLATFORM (NULL)
#define SET_PERSONALITY(ex) set_personality(PER_LINUX)

-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
#endif /* __ASM_CSKY_ELF_H */
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 6e00c16a36b5..74bc280523e4 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -5,6 +5,7 @@ comment "Linux Kernel Configuration for Hexagon"
config HEXAGON
def_bool y
select ARCH_32BIT_OFF_T
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_NO_PREEMPT
select HAVE_OPROFILE
diff --git a/arch/hexagon/include/asm/elf.h b/arch/hexagon/include/asm/elf.h
index 5bfdd9b147fd..eba4131610aa 100644
--- a/arch/hexagon/include/asm/elf.h
+++ b/arch/hexagon/include/asm/elf.h
@@ -207,10 +207,4 @@ do { \
*/
#define ELF_PLATFORM (NULL)

-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-
-
#endif
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 077c4ae09550..5e696ab80df4 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -7,6 +7,7 @@ config MIPS
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_KCOV
select ARCH_HAS_PTE_SPECIAL if !(32BIT && CPU_HAS_RIXI)
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAS_UBSAN_SANITIZE_ALL
select ARCH_SUPPORTS_UPROBES
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index 71c7622025d1..6665cf7870b3 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -480,11 +480,6 @@ do { \
(unsigned long)current->mm->context.vdso); \
} while (0)

-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-
#ifdef CONFIG_MIPS_FP_SUPPORT

struct arch_elf_state {
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index 62313902d75d..02afe5ebdfff 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -8,6 +8,7 @@ config NDS32
def_bool y
select ARCH_32BIT_OFF_T
select ARCH_HAS_DMA_PREP_COHERENT
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_WANT_FRAME_POINTERS if FTRACE
diff --git a/arch/nds32/include/asm/elf.h b/arch/nds32/include/asm/elf.h
index 1853dc89b8ac..36cec4ae5a84 100644
--- a/arch/nds32/include/asm/elf.h
+++ b/arch/nds32/include/asm/elf.h
@@ -173,8 +173,5 @@ do { \
NEW_AUX_ENT(AT_SYSINFO_EHDR, \
(elf_addr_t)current->mm->context.vdso); \
} while (0)
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-struct linux_binprm;
-int arch_setup_additional_pages(struct linux_binprm *, int);

#endif
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index c24955c81c92..8159123a995e 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -3,6 +3,7 @@ config NIOS2
def_bool y
select ARCH_32BIT_OFF_T
select ARCH_HAS_DMA_PREP_COHERENT
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_HAS_DMA_SET_UNCACHED
diff --git a/arch/nios2/include/asm/elf.h b/arch/nios2/include/asm/elf.h
index 984dd6de17c2..4f8baaef843f 100644
--- a/arch/nios2/include/asm/elf.h
+++ b/arch/nios2/include/asm/elf.h
@@ -28,10 +28,6 @@
/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
now struct_user_regs, they are different) */

-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
#define ELF_CORE_COPY_REGS(pr_reg, regs) \
{ do { \
/* Bleech. */ \
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 0d29c264ba0c..61198a087b6c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -134,6 +134,7 @@ config PPC
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_MEMBARRIER_CALLBACKS
select ARCH_HAS_MEMBARRIER_SYNC_CORE
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC_BOOK3S_64
select ARCH_HAS_STRICT_KERNEL_RWX if (PPC32 && !HIBERNATION)
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index 53ed2ca40151..ba0e1e331088 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -111,11 +111,6 @@ extern int dcache_bsize;
extern int icache_bsize;
extern int ucache_bsize;

-/* vDSO has arch_setup_additional_pages */
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
#define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b)

/* 1GB for 64bit, 8MB for 32bit */
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 880c2b3b65d0..d8489724ddbf 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -26,6 +26,7 @@ config RISCV
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_SET_DIRECT_MAP
select ARCH_HAS_SET_MEMORY
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_STRICT_KERNEL_RWX if MMU
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h
index 5c725e1df58b..628444d3bbab 100644
--- a/arch/riscv/include/asm/elf.h
+++ b/arch/riscv/include/asm/elf.h
@@ -75,10 +75,5 @@ do { \
NEW_AUX_ENT(AT_L2_CACHEGEOMETRY, \
get_cache_geometry(2, CACHE_TYPE_UNIFIED)); \
} while (0)
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-#endif /* CONFIG_MMU */

#endif /* _ASM_RISCV_ELF_H */
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index c3e4cbebcf0b..a02c99016acd 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -67,6 +67,7 @@ config S390
select ARCH_HAS_MEM_ENCRYPT
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_SET_MEMORY
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_HAS_STRICT_MODULE_RWX
select ARCH_HAS_SYSCALL_WRAPPER
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index 5775fc22f410..f6ce9df8a996 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -276,9 +276,4 @@ do { \
(unsigned long)current->mm->context.vdso_base); \
} while (0)

-struct linux_binprm;
-
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-int arch_setup_additional_pages(struct linux_binprm *, int);
-
#endif
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 5fa580219a86..c0bae180d8b8 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -8,6 +8,7 @@ config SUPERH
select ARCH_HAS_GIGANTIC_PAGE
select ARCH_HAS_GCOV_PROFILE_ALL
select ARCH_HAS_PTE_SPECIAL
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES if VSYSCALL
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HIBERNATION_POSSIBLE if MMU
select ARCH_MIGHT_HAVE_PC_PARPORT
diff --git a/arch/sh/include/asm/elf.h b/arch/sh/include/asm/elf.h
index 2862d6d1cb64..9b3e22e771a1 100644
--- a/arch/sh/include/asm/elf.h
+++ b/arch/sh/include/asm/elf.h
@@ -164,12 +164,6 @@ do { \
set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))

#ifdef CONFIG_VSYSCALL
-/* vDSO has arch_setup_additional_pages */
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-
extern unsigned int vdso_enabled;
extern void __kernel_vsyscall;

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index e4aad12b9c47..9d5cc6be8974 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -13,6 +13,7 @@ config 64BIT
config SPARC
bool
default y
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES if SPARC64
select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI
select ARCH_MIGHT_HAVE_PC_SERIO
select DMA_OPS
diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
index 8fb09eec8c3e..63a622c36df3 100644
--- a/arch/sparc/include/asm/elf_64.h
+++ b/arch/sparc/include/asm/elf_64.h
@@ -223,10 +223,4 @@ do { \
NEW_AUX_ENT(AT_ADI_NBITS, adi_state.caps.nbits); \
NEW_AUX_ENT(AT_ADI_UEONADI, adi_state.caps.ue_on_adi); \
} while (0)
-
-struct linux_binprm;
-
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
#endif /* !(__ASM_SPARC64_ELF_H) */
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 34d5fb82f674..b068f949d2e4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -78,6 +78,7 @@ config X86
select ARCH_HAS_COPY_MC if X86_64
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_SET_DIRECT_MAP
+ select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_HAS_STRICT_MODULE_RWX
select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 109697a19eb1..d00b723eea2d 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -378,10 +378,6 @@ else \
vdso_image_32.sym___kernel_vsyscall)

struct linux_binprm;
-
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
int uses_interp);
#define compat_arch_setup_additional_pages compat_arch_setup_additional_pages
diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h
index c907b20d4993..7bc1d9d94d66 100644
--- a/arch/x86/um/asm/elf.h
+++ b/arch/x86/um/asm/elf.h
@@ -181,11 +181,6 @@ do { \
#define FIXADDR_USER_START 0
#define FIXADDR_USER_END 0

-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-
extern unsigned long um_vdso_addr;
#define AT_SYSINFO_EHDR 33
#define ARCH_DLINFO NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr)
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 885da6d983b4..4ed2ab0a1565 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -39,6 +39,9 @@ config ARCH_BINFMT_ELF_STATE
config ARCH_HAVE_ELF_PROT
bool

+config ARCH_HAS_SETUP_ADDITIONAL_PAGES
+ bool
+
config ARCH_USE_GNU_PROPERTY
bool

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 3de72c0e0406..b9adbeb59101 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1249,11 +1249,9 @@ static int load_elf_binary(struct linux_binprm *bprm)

set_binfmt(&elf_format);

-#ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES
retval = arch_setup_additional_pages(bprm, !!interpreter);
if (retval < 0)
goto out;
-#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */

retval = create_elf_tables(bprm, elf_ex,
load_addr, interp_load_addr, e_entry);
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index be4062b8ba75..b9a6d1b2b5bb 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -374,11 +374,10 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
executable_stack);
if (retval < 0)
goto error;
-#ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES
+
retval = arch_setup_additional_pages(bprm, !!interpreter_name);
if (retval < 0)
goto error;
-#endif
#endif

/* load the executable and interpreter into memory */
diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
index 12b991368f0a..3606dd3a32f5 100644
--- a/fs/compat_binfmt_elf.c
+++ b/fs/compat_binfmt_elf.c
@@ -116,8 +116,6 @@
#endif

#ifdef compat_arch_setup_additional_pages
-#undef ARCH_HAS_SETUP_ADDITIONAL_PAGES
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
#undef arch_setup_additional_pages
#define arch_setup_additional_pages compat_arch_setup_additional_pages
#endif
diff --git a/include/linux/elf.h b/include/linux/elf.h
index 6dbcfe7a3fd7..95bf7a1abaef 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -104,4 +104,16 @@ static inline int arch_elf_adjust_prot(int prot,
}
#endif

+struct linux_binprm;
+#ifdef CONFIG_ARCH_HAS_SETUP_ADDITIONAL_PAGES
+extern int arch_setup_additional_pages(struct linux_binprm *bprm,
+ int uses_interp);
+#else
+static inline int arch_setup_additional_pages(struct linux_binprm *bprm,
+ int uses_interp)
+{
+ return 0;
+}
+#endif
+
#endif /* _LINUX_ELF_H */
--
2.28.0

2020-11-08 19:06:48

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH 14/19] mm: Add user_landing in mm_struct

On Sat, Nov 7, 2020 at 9:18 PM Dmitry Safonov <[email protected]> wrote:
>
> Instead of having every architecture to define vdso_base/vdso_addr etc,
> provide a generic mechanism to track landing in userspace.
> It'll minimize per-architecture difference, the number of callbacks to
> provide.
>
> Originally, it started from thread [1] where the need for .close()
> callback on vm_special_mapping was pointed, this generic code besides
> removing duplicated .mremap() callbacks provides a cheaper way to
> support munmap() on vdso mappings without introducing .close() callbacks
> for every architecture (with would bring even more code duplication).

I find the naming odd. It's called "user_landing", which is
presumably a hard-to-understand shorthand for "user mode landing pad
for return from a signal handler if SA_RESTORER is not set". But,
looking at the actual code, it's not this at all -- it's just the vDSO
base address.

So how about just calling it vdso_base? I'm very much in favor of
consolidating and cleaning up, and improving the vdso remap/unmap
code, but I'm not convinced that we should call it anything other than
the vdso base.

--Andy

2020-11-08 19:09:19

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH 12/19] x86/signal: Land on &frame->retcode when vdso isn't mapped

On Sat, Nov 7, 2020 at 9:17 PM Dmitry Safonov <[email protected]> wrote:
>
> Since commit 9fbbd4dd17d0 ("x86: Don't require the vDSO for handling
> a.out signals") after processing 32-bit signal if there is no vdso
> mapped frame->retcode is used as a landing.
> Do the same for rt ia32 signals.

Am I reading correctly that this makes the ia32 compat signals match
the native ia32 case?

--Andy

2020-11-08 19:10:01

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH 00/19] Add generic user_landing tracking

On Sat, Nov 7, 2020 at 9:17 PM Dmitry Safonov <[email protected]> wrote:
>
> Started from discussion [1], where was noted that currently a couple of
> architectures support mremap() for vdso/sigpage, but not munmap().
> If an application maps something on the ex-place of vdso/sigpage,
> later after processing signal it will land there (good luck!)
>
> Patches set is based on linux-next (next-20201106) and it depends on
> changes in x86/cleanups (those reclaim TIF_IA32/TIF_X32) and also
> on my changes in akpm (fixing several mremap() issues).
>
> Logically, the patches set divides on:
> - patch 1: cleanup for patches in x86/cleanups
> - patches 2-11: cleanups for arch_setup_additional_pages()

I like these cleanups, although I think you should stop using terms
like "new-born". A task being exec'd is not newborn at all -- it's in
the middle of a transformation.

--Andy

2020-11-09 01:24:55

by Dmitry Safonov

[permalink] [raw]
Subject: Re: [PATCH 12/19] x86/signal: Land on &frame->retcode when vdso isn't mapped

On 11/8/20 7:06 PM, Andy Lutomirski wrote:
> On Sat, Nov 7, 2020 at 9:17 PM Dmitry Safonov <[email protected]> wrote:
>>
>> Since commit 9fbbd4dd17d0 ("x86: Don't require the vDSO for handling
>> a.out signals") after processing 32-bit signal if there is no vdso
>> mapped frame->retcode is used as a landing.
>> Do the same for rt ia32 signals.
>
> Am I reading correctly that this makes the ia32 compat signals match
> the native ia32 case?

Yes, probably I should have added it to the changelog.

Thanks,
Dmitry

2020-11-09 01:27:00

by Dmitry Safonov

[permalink] [raw]
Subject: Re: [PATCH 14/19] mm: Add user_landing in mm_struct

On 11/8/20 7:04 PM, Andy Lutomirski wrote:
> On Sat, Nov 7, 2020 at 9:18 PM Dmitry Safonov <[email protected]> wrote:
>>
>> Instead of having every architecture to define vdso_base/vdso_addr etc,
>> provide a generic mechanism to track landing in userspace.
>> It'll minimize per-architecture difference, the number of callbacks to
>> provide.
>>
>> Originally, it started from thread [1] where the need for .close()
>> callback on vm_special_mapping was pointed, this generic code besides
>> removing duplicated .mremap() callbacks provides a cheaper way to
>> support munmap() on vdso mappings without introducing .close() callbacks
>> for every architecture (with would bring even more code duplication).
>
> I find the naming odd. It's called "user_landing", which is
> presumably a hard-to-understand shorthand for "user mode landing pad
> for return from a signal handler if SA_RESTORER is not set". But,
> looking at the actual code, it's not this at all -- it's just the vDSO
> base address.

Agree. Originally, I tried to track the actual landing address on the
vdso, but .mremap() seemed simpler when tracking the vma base.

> So how about just calling it vdso_base? I'm very much in favor of
> consolidating and cleaning up, and improving the vdso remap/unmap
> code, but I'm not convinced that we should call it anything other than
> the vdso base.

Sure.

Thanks,
Dmitry

2020-11-09 01:29:10

by Dmitry Safonov

[permalink] [raw]
Subject: Re: [PATCH 00/19] Add generic user_landing tracking

On 11/8/20 7:07 PM, Andy Lutomirski wrote:
> On Sat, Nov 7, 2020 at 9:17 PM Dmitry Safonov <[email protected]> wrote:
>>
>> Started from discussion [1], where was noted that currently a couple of
>> architectures support mremap() for vdso/sigpage, but not munmap().
>> If an application maps something on the ex-place of vdso/sigpage,
>> later after processing signal it will land there (good luck!)
>>
>> Patches set is based on linux-next (next-20201106) and it depends on
>> changes in x86/cleanups (those reclaim TIF_IA32/TIF_X32) and also
>> on my changes in akpm (fixing several mremap() issues).
>>
>> Logically, the patches set divides on:
>> - patch 1: cleanup for patches in x86/cleanups
>> - patches 2-11: cleanups for arch_setup_additional_pages()
>
> I like these cleanups, although I think you should stop using terms
> like "new-born". A task being exec'd is not newborn at all -- it's in
> the middle of a transformation.

Thank you for looking at them, Andy :-)

Yeah, somehow I thought about new-execed process as a new-born binary.
I'll try to improve changelogs in v2.

Thanks,
Dmitry

2020-11-13 06:59:49

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 06/19] elf/vdso: Reuse arch_setup_additional_pages() parameters

Hi Dmitry,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on c34f157421f6905e6b4a79a312e9175dce2bc607]

url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
base: c34f157421f6905e6b4a79a312e9175dce2bc607
config: ia64-randconfig-r035-20201109 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/04586680978b048abe74dd892c5b1fcde7c486a3
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
git checkout 04586680978b048abe74dd892c5b1fcde7c486a3
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

WARNING: unmet direct dependencies detected for FRAME_POINTER
Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
Selected by
- FAULT_INJECTION_STACKTRACE_FILTER && FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT && !X86_64 && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM && !ARC && !X86
In file included from arch/ia64/include/asm/pgtable.h:154,
from include/linux/pgtable.h:6,
from arch/ia64/include/asm/uaccess.h:40,
from include/linux/uaccess.h:11,
from include/linux/sched/task.h:11,
from include/linux/sched/signal.h:9,
from arch/ia64/kernel/asm-offsets.c:10:
arch/ia64/include/asm/mmu_context.h: In function 'reload_context':
arch/ia64/include/asm/mmu_context.h:127:41: warning: variable 'old_rr4' set but not used
127 | unsigned long rr0, rr1, rr2, rr3, rr4, old_rr4;
| ^~~~~~~
In file included from arch/ia64/include/asm/sections.h:10,
from include/linux/interrupt.h:20,
from arch/ia64/include/asm/mca.h:17,
from arch/ia64/kernel/asm-offsets.c:18:
include/linux/elf.h: At top level:
include/linux/elf.h:121:1: error: expected identifier or '(' before '{' token
121 | {
| ^
arch/ia64/kernel/asm-offsets.c:23:6: warning: no previous prototype for 'foo'
23 | void foo(void)
| ^~~
In file included from arch/ia64/include/asm/sections.h:10,
from include/linux/interrupt.h:20,
from arch/ia64/include/asm/mca.h:17,
from arch/ia64/kernel/asm-offsets.c:18:
>> include/linux/elf.h:120:19: warning: 'arch_setup_additional_pages' declared 'static' but never defined
120 | static inline int arch_setup_additional_pages(unsigned long
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Makefile arch include kernel scripts source usr [scripts/Makefile.build:117: arch/ia64/kernel/asm-offsets.s] Error 1
Target '__build' not remade because of errors.
Makefile arch include kernel scripts source usr [Makefile:1198: prepare0] Error 2
Target 'prepare' not remade because of errors.
make: Makefile arch include kernel scripts source usr [Makefile:185: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

vim +120 include/linux/elf.h

106
107 #ifdef CONFIG_ARCH_HAS_SETUP_ADDITIONAL_PAGES
108 /**
109 * arch_setup_additional_pages - Premap VMAs in a new-execed process
110 * @sysinfo_ehdr: Returns vDSO position to be set in the initial
111 * auxiliary vector (tag AT_SYSINFO_EHDR) by binfmt
112 * loader. On failure isn't initialized.
113 * As address == 0 is never used, it allows to check
114 * if the tag should be set.
115 *
116 * Return: Zero if successful, or a negative error code on failure.
117 */
118 extern int arch_setup_additional_pages(unsigned long *sysinfo_ehdr);
119 #else
> 120 static inline int arch_setup_additional_pages(unsigned long *sysinfo_ehdr);
121 {
122 return 0;
123 }
124 #endif
125

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (4.22 kB)
.config.gz (30.20 kB)
Download all attachments

2020-11-13 07:02:55

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 02/19] elf: Move arch_setup_additional_pages() to generic elf.h

Hi Dmitry,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on c34f157421f6905e6b4a79a312e9175dce2bc607]

url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
base: c34f157421f6905e6b4a79a312e9175dce2bc607
config: riscv-randconfig-r026-20201109 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 09ec07827b1128504457a93dee80b2ceee1af600)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/c46ac7ddea192a97f9b0b3aa3536566a37389bec
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
git checkout c46ac7ddea192a97f9b0b3aa3536566a37389bec
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

#ifndef _ASM_RISCV_ELF_H
^
In file included from arch/riscv/kernel/traps_misaligned.c:9:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:556:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inb(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:55:76: note: expanded from macro 'inb'
#define inb(c) ({ u8 __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:87:48: note: expanded from macro 'readb_cpu'
#define readb_cpu(c) ({ u8 __r = __raw_readb(c); __r; })
^
In file included from arch/riscv/kernel/traps_misaligned.c:9:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:564:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inw(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:56:76: note: expanded from macro 'inw'
#define inw(c) ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:88:76: note: expanded from macro 'readw_cpu'
#define readw_cpu(c) ({ u16 __r = le16_to_cpu((__force __le16)__raw_readw(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from arch/riscv/kernel/traps_misaligned.c:9:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:572:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inl(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
#define inl(c) ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
#define readl_cpu(c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from arch/riscv/kernel/traps_misaligned.c:9:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:580:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outb(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
#define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
#define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
^
In file included from arch/riscv/kernel/traps_misaligned.c:9:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:588:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outw(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
#define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
#define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
^
In file included from arch/riscv/kernel/traps_misaligned.c:9:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:596:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outl(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
#define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
#define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
^
In file included from arch/riscv/kernel/traps_misaligned.c:9:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:1005:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
~~~~~~~~~~ ^
arch/riscv/kernel/traps_misaligned.c:240:5: warning: no previous prototype for function 'handle_misaligned_load' [-Wmissing-prototypes]
int handle_misaligned_load(struct pt_regs *regs)
^
arch/riscv/kernel/traps_misaligned.c:240:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int handle_misaligned_load(struct pt_regs *regs)
^
static
>> arch/riscv/kernel/traps_misaligned.c:316:2: warning: shift count is negative [-Wshift-count-negative]
SET_RD(insn, regs, val.data_ulong << shift >> shift);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:142:36: note: expanded from macro 'SET_RD'
#define SET_RD(insn, regs, val) (*REG_PTR(insn, SH_RD, regs) = (val))
^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:132:28: note: expanded from macro 'REG_PTR'
(ulong *)((ulong)(regs) + REG_OFFSET(insn, pos))
^~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:129:3: note: expanded from macro 'REG_OFFSET'
(SHIFT_RIGHT((insn), (pos) - LOG_REGBYTES) & REG_MASK)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:123:18: note: expanded from macro 'SHIFT_RIGHT'
((y) < 0 ? ((x) << -(y)) : ((x) >> (y)))
^ ~~~~
arch/riscv/kernel/traps_misaligned.c:323:5: warning: no previous prototype for function 'handle_misaligned_store' [-Wmissing-prototypes]
int handle_misaligned_store(struct pt_regs *regs)
^
arch/riscv/kernel/traps_misaligned.c:323:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int handle_misaligned_store(struct pt_regs *regs)
^
static
arch/riscv/kernel/traps_misaligned.c:333:19: warning: shift count is negative [-Wshift-count-negative]
val.data_ulong = GET_RS2(insn, regs);
^~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:137:32: note: expanded from macro 'GET_RS2'
#define GET_RS2(insn, regs) (*REG_PTR(insn, SH_RS2, regs))
^~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:132:28: note: expanded from macro 'REG_PTR'
(ulong *)((ulong)(regs) + REG_OFFSET(insn, pos))
^~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:129:3: note: expanded from macro 'REG_OFFSET'
(SHIFT_RIGHT((insn), (pos) - LOG_REGBYTES) & REG_MASK)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:123:18: note: expanded from macro 'SHIFT_RIGHT'
((y) < 0 ? ((x) << -(y)) : ((x) >> (y)))
^ ~~~~
arch/riscv/kernel/traps_misaligned.c:346:20: warning: shift count is negative [-Wshift-count-negative]
val.data_ulong = GET_RS2S(insn, regs);
^~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:139:33: note: expanded from macro 'GET_RS2S'
#define GET_RS2S(insn, regs) (*REG_PTR(RVC_RS2S(insn), 0, regs))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:132:28: note: expanded from macro 'REG_PTR'
(ulong *)((ulong)(regs) + REG_OFFSET(insn, pos))
^~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:129:3: note: expanded from macro 'REG_OFFSET'
(SHIFT_RIGHT((insn), (pos) - LOG_REGBYTES) & REG_MASK)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:123:34: note: expanded from macro 'SHIFT_RIGHT'
((y) < 0 ? ((x) << -(y)) : ((x) >> (y)))
^ ~~~
arch/riscv/kernel/traps_misaligned.c:350:20: warning: shift count is negative [-Wshift-count-negative]
val.data_ulong = GET_RS2C(insn, regs);
^~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:140:33: note: expanded from macro 'GET_RS2C'
#define GET_RS2C(insn, regs) (*REG_PTR(insn, SH_RS2C, regs))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:132:28: note: expanded from macro 'REG_PTR'
(ulong *)((ulong)(regs) + REG_OFFSET(insn, pos))
^~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:129:3: note: expanded from macro 'REG_OFFSET'
(SHIFT_RIGHT((insn), (pos) - LOG_REGBYTES) & REG_MASK)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:123:34: note: expanded from macro 'SHIFT_RIGHT'
((y) < 0 ? ((x) << -(y)) : ((x) >> (y)))
^ ~~~
arch/riscv/kernel/traps_misaligned.c:354:20: warning: shift count is negative [-Wshift-count-negative]
val.data_ulong = GET_RS2S(insn, regs);
^~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:139:33: note: expanded from macro 'GET_RS2S'
#define GET_RS2S(insn, regs) (*REG_PTR(RVC_RS2S(insn), 0, regs))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:132:28: note: expanded from macro 'REG_PTR'
(ulong *)((ulong)(regs) + REG_OFFSET(insn, pos))
^~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:129:3: note: expanded from macro 'REG_OFFSET'
(SHIFT_RIGHT((insn), (pos) - LOG_REGBYTES) & REG_MASK)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:123:34: note: expanded from macro 'SHIFT_RIGHT'
((y) < 0 ? ((x) << -(y)) : ((x) >> (y)))
^ ~~~
arch/riscv/kernel/traps_misaligned.c:358:20: warning: shift count is negative [-Wshift-count-negative]
val.data_ulong = GET_RS2C(insn, regs);
^~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:140:33: note: expanded from macro 'GET_RS2C'
#define GET_RS2C(insn, regs) (*REG_PTR(insn, SH_RS2C, regs))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:132:28: note: expanded from macro 'REG_PTR'
(ulong *)((ulong)(regs) + REG_OFFSET(insn, pos))
^~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:129:3: note: expanded from macro 'REG_OFFSET'
(SHIFT_RIGHT((insn), (pos) - LOG_REGBYTES) & REG_MASK)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps_misaligned.c:123:34: note: expanded from macro 'SHIFT_RIGHT'
((y) < 0 ? ((x) << -(y)) : ((x) >> (y)))
^ ~~~
15 warnings and 1 error generated.
--
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:556:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inb(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:55:76: note: expanded from macro 'inb'
#define inb(c) ({ u8 __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:87:48: note: expanded from macro 'readb_cpu'
#define readb_cpu(c) ({ u8 __r = __raw_readb(c); __r; })
^
In file included from drivers/gpu/drm/vkms/vkms_drv.c:14:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:564:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inw(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:56:76: note: expanded from macro 'inw'
#define inw(c) ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:88:76: note: expanded from macro 'readw_cpu'
#define readw_cpu(c) ({ u16 __r = le16_to_cpu((__force __le16)__raw_readw(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from drivers/gpu/drm/vkms/vkms_drv.c:14:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:572:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inl(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
#define inl(c) ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
#define readl_cpu(c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from drivers/gpu/drm/vkms/vkms_drv.c:14:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:580:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outb(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
#define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
#define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
^
In file included from drivers/gpu/drm/vkms/vkms_drv.c:14:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:588:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outw(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
#define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
#define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
^
In file included from drivers/gpu/drm/vkms/vkms_drv.c:14:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:596:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outl(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
#define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
#define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
^
In file included from drivers/gpu/drm/vkms/vkms_drv.c:14:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:1005:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
~~~~~~~~~~ ^
In file included from drivers/gpu/drm/vkms/vkms_drv.c:20:
In file included from include/drm/drm_fb_helper.h:39:
In file included from include/linux/vgaarb.h:34:
include/video/vga.h:215:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outw(VGA_OUT16VAL (val, reg), port);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
#define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
#define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
^
>> drivers/gpu/drm/vkms/vkms_drv.c:146:9: warning: shift count >= width of type [-Wshift-count-overflow]
DMA_BIT_MASK(64));
^~~~~~~~~~~~~~~~
include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
^ ~~~
9 warnings and 1 error generated.

vim +316 arch/riscv/kernel/traps_misaligned.c

956d705dd279f7 Damien Le Moal 2020-03-16 239
956d705dd279f7 Damien Le Moal 2020-03-16 240 int handle_misaligned_load(struct pt_regs *regs)
956d705dd279f7 Damien Le Moal 2020-03-16 241 {
956d705dd279f7 Damien Le Moal 2020-03-16 242 union reg_data val;
956d705dd279f7 Damien Le Moal 2020-03-16 243 unsigned long epc = regs->epc;
956d705dd279f7 Damien Le Moal 2020-03-16 244 unsigned long insn = get_insn(epc);
956d705dd279f7 Damien Le Moal 2020-03-16 245 unsigned long addr = csr_read(mtval);
956d705dd279f7 Damien Le Moal 2020-03-16 246 int i, fp = 0, shift = 0, len = 0;
956d705dd279f7 Damien Le Moal 2020-03-16 247
956d705dd279f7 Damien Le Moal 2020-03-16 248 regs->epc = 0;
956d705dd279f7 Damien Le Moal 2020-03-16 249
956d705dd279f7 Damien Le Moal 2020-03-16 250 if ((insn & INSN_MASK_LW) == INSN_MATCH_LW) {
956d705dd279f7 Damien Le Moal 2020-03-16 251 len = 4;
956d705dd279f7 Damien Le Moal 2020-03-16 252 shift = 8 * (sizeof(unsigned long) - len);
956d705dd279f7 Damien Le Moal 2020-03-16 253 #if defined(CONFIG_64BIT)
956d705dd279f7 Damien Le Moal 2020-03-16 254 } else if ((insn & INSN_MASK_LD) == INSN_MATCH_LD) {
956d705dd279f7 Damien Le Moal 2020-03-16 255 len = 8;
956d705dd279f7 Damien Le Moal 2020-03-16 256 shift = 8 * (sizeof(unsigned long) - len);
956d705dd279f7 Damien Le Moal 2020-03-16 257 } else if ((insn & INSN_MASK_LWU) == INSN_MATCH_LWU) {
956d705dd279f7 Damien Le Moal 2020-03-16 258 len = 4;
956d705dd279f7 Damien Le Moal 2020-03-16 259 #endif
956d705dd279f7 Damien Le Moal 2020-03-16 260 } else if ((insn & INSN_MASK_FLD) == INSN_MATCH_FLD) {
956d705dd279f7 Damien Le Moal 2020-03-16 261 fp = 1;
956d705dd279f7 Damien Le Moal 2020-03-16 262 len = 8;
956d705dd279f7 Damien Le Moal 2020-03-16 263 } else if ((insn & INSN_MASK_FLW) == INSN_MATCH_FLW) {
956d705dd279f7 Damien Le Moal 2020-03-16 264 fp = 1;
956d705dd279f7 Damien Le Moal 2020-03-16 265 len = 4;
956d705dd279f7 Damien Le Moal 2020-03-16 266 } else if ((insn & INSN_MASK_LH) == INSN_MATCH_LH) {
956d705dd279f7 Damien Le Moal 2020-03-16 267 len = 2;
956d705dd279f7 Damien Le Moal 2020-03-16 268 shift = 8 * (sizeof(unsigned long) - len);
956d705dd279f7 Damien Le Moal 2020-03-16 269 } else if ((insn & INSN_MASK_LHU) == INSN_MATCH_LHU) {
956d705dd279f7 Damien Le Moal 2020-03-16 270 len = 2;
956d705dd279f7 Damien Le Moal 2020-03-16 271 #if defined(CONFIG_64BIT)
956d705dd279f7 Damien Le Moal 2020-03-16 272 } else if ((insn & INSN_MASK_C_LD) == INSN_MATCH_C_LD) {
956d705dd279f7 Damien Le Moal 2020-03-16 273 len = 8;
956d705dd279f7 Damien Le Moal 2020-03-16 274 shift = 8 * (sizeof(unsigned long) - len);
956d705dd279f7 Damien Le Moal 2020-03-16 275 insn = RVC_RS2S(insn) << SH_RD;
956d705dd279f7 Damien Le Moal 2020-03-16 276 } else if ((insn & INSN_MASK_C_LDSP) == INSN_MATCH_C_LDSP &&
956d705dd279f7 Damien Le Moal 2020-03-16 277 ((insn >> SH_RD) & 0x1f)) {
956d705dd279f7 Damien Le Moal 2020-03-16 278 len = 8;
956d705dd279f7 Damien Le Moal 2020-03-16 279 shift = 8 * (sizeof(unsigned long) - len);
956d705dd279f7 Damien Le Moal 2020-03-16 280 #endif
956d705dd279f7 Damien Le Moal 2020-03-16 281 } else if ((insn & INSN_MASK_C_LW) == INSN_MATCH_C_LW) {
956d705dd279f7 Damien Le Moal 2020-03-16 282 len = 4;
956d705dd279f7 Damien Le Moal 2020-03-16 283 shift = 8 * (sizeof(unsigned long) - len);
956d705dd279f7 Damien Le Moal 2020-03-16 284 insn = RVC_RS2S(insn) << SH_RD;
956d705dd279f7 Damien Le Moal 2020-03-16 285 } else if ((insn & INSN_MASK_C_LWSP) == INSN_MATCH_C_LWSP &&
956d705dd279f7 Damien Le Moal 2020-03-16 286 ((insn >> SH_RD) & 0x1f)) {
956d705dd279f7 Damien Le Moal 2020-03-16 287 len = 4;
956d705dd279f7 Damien Le Moal 2020-03-16 288 shift = 8 * (sizeof(unsigned long) - len);
956d705dd279f7 Damien Le Moal 2020-03-16 289 } else if ((insn & INSN_MASK_C_FLD) == INSN_MATCH_C_FLD) {
956d705dd279f7 Damien Le Moal 2020-03-16 290 fp = 1;
956d705dd279f7 Damien Le Moal 2020-03-16 291 len = 8;
956d705dd279f7 Damien Le Moal 2020-03-16 292 insn = RVC_RS2S(insn) << SH_RD;
956d705dd279f7 Damien Le Moal 2020-03-16 293 } else if ((insn & INSN_MASK_C_FLDSP) == INSN_MATCH_C_FLDSP) {
956d705dd279f7 Damien Le Moal 2020-03-16 294 fp = 1;
956d705dd279f7 Damien Le Moal 2020-03-16 295 len = 8;
956d705dd279f7 Damien Le Moal 2020-03-16 296 #if defined(CONFIG_32BIT)
956d705dd279f7 Damien Le Moal 2020-03-16 297 } else if ((insn & INSN_MASK_C_FLW) == INSN_MATCH_C_FLW) {
956d705dd279f7 Damien Le Moal 2020-03-16 298 fp = 1;
956d705dd279f7 Damien Le Moal 2020-03-16 299 len = 4;
956d705dd279f7 Damien Le Moal 2020-03-16 300 insn = RVC_RS2S(insn) << SH_RD;
956d705dd279f7 Damien Le Moal 2020-03-16 301 } else if ((insn & INSN_MASK_C_FLWSP) == INSN_MATCH_C_FLWSP) {
956d705dd279f7 Damien Le Moal 2020-03-16 302 fp = 1;
956d705dd279f7 Damien Le Moal 2020-03-16 303 len = 4;
956d705dd279f7 Damien Le Moal 2020-03-16 304 #endif
956d705dd279f7 Damien Le Moal 2020-03-16 305 } else {
956d705dd279f7 Damien Le Moal 2020-03-16 306 regs->epc = epc;
956d705dd279f7 Damien Le Moal 2020-03-16 307 return -1;
956d705dd279f7 Damien Le Moal 2020-03-16 308 }
956d705dd279f7 Damien Le Moal 2020-03-16 309
956d705dd279f7 Damien Le Moal 2020-03-16 310 val.data_u64 = 0;
956d705dd279f7 Damien Le Moal 2020-03-16 311 for (i = 0; i < len; i++)
956d705dd279f7 Damien Le Moal 2020-03-16 312 val.data_bytes[i] = load_u8((void *)(addr + i));
956d705dd279f7 Damien Le Moal 2020-03-16 313
956d705dd279f7 Damien Le Moal 2020-03-16 314 if (fp)
956d705dd279f7 Damien Le Moal 2020-03-16 315 return -1;
956d705dd279f7 Damien Le Moal 2020-03-16 @316 SET_RD(insn, regs, val.data_ulong << shift >> shift);
956d705dd279f7 Damien Le Moal 2020-03-16 317
956d705dd279f7 Damien Le Moal 2020-03-16 318 regs->epc = epc + INSN_LEN(insn);
956d705dd279f7 Damien Le Moal 2020-03-16 319
956d705dd279f7 Damien Le Moal 2020-03-16 320 return 0;
956d705dd279f7 Damien Le Moal 2020-03-16 321 }
956d705dd279f7 Damien Le Moal 2020-03-16 322

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (28.92 kB)
.config.gz (31.92 kB)
Download all attachments

2020-11-13 07:04:22

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 02/19] elf: Move arch_setup_additional_pages() to generic elf.h

Hi Dmitry,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on c34f157421f6905e6b4a79a312e9175dce2bc607]

url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
base: c34f157421f6905e6b4a79a312e9175dce2bc607
config: riscv-allmodconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c46ac7ddea192a97f9b0b3aa3536566a37389bec
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
git checkout c46ac7ddea192a97f9b0b3aa3536566a37389bec
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/irqchip.h:15,
from arch/riscv/kernel/irq.c:9:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/irq.c:19:13: warning: no previous prototype for 'init_IRQ' [-Wmissing-prototypes]
19 | void __init init_IRQ(void)
| ^~~~~~~~
--
In file included from include/linux/elf.h:6,
from arch/riscv/kernel/ptrace.c:15:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/ptrace.c:140:15: warning: no previous prototype for 'do_syscall_trace_enter' [-Wmissing-prototypes]
140 | __visible int do_syscall_trace_enter(struct pt_regs *regs)
| ^~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/ptrace.c:163:16: warning: no previous prototype for 'do_syscall_trace_exit' [-Wmissing-prototypes]
163 | __visible void do_syscall_trace_exit(struct pt_regs *regs)
| ^~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/kallsyms.h:13,
from include/linux/ftrace.h:11,
from include/linux/perf_event.h:49,
from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:84,
from arch/riscv/kernel/signal.c:11:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/signal.c:309:27: warning: no previous prototype for 'do_notify_resume' [-Wmissing-prototypes]
309 | asmlinkage __visible void do_notify_resume(struct pt_regs *regs,
| ^~~~~~~~~~~~~~~~
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/kallsyms.h:13,
from include/linux/ftrace.h:11,
from include/linux/perf_event.h:49,
from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:84,
from arch/riscv/kernel/syscall_table.c:8:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL'
29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
| ^~~~~~~~~
include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro '__SC_COMP'
34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for 'sys_call_table[0]')
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL'
29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
| ^~~~~~~~~
include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro '__SC_COMP'
34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:36:1: note: in expansion of macro '__SYSCALL'
36 | __SYSCALL(__NR_io_destroy, sys_io_destroy)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for 'sys_call_table[1]')
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:36:1: note: in expansion of macro '__SYSCALL'
36 | __SYSCALL(__NR_io_destroy, sys_io_destroy)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL'
29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
| ^~~~~~~~~
include/uapi/asm-generic/unistd.h:38:1: note: in expansion of macro '__SC_COMP'
38 | __SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for 'sys_call_table[2]')
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL'
29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
| ^~~~~~~~~
include/uapi/asm-generic/unistd.h:38:1: note: in expansion of macro '__SC_COMP'
38 | __SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:40:1: note: in expansion of macro '__SYSCALL'
40 | __SYSCALL(__NR_io_cancel, sys_io_cancel)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for 'sys_call_table[3]')
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:40:1: note: in expansion of macro '__SYSCALL'
40 | __SYSCALL(__NR_io_cancel, sys_io_cancel)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:22:34: note: in expansion of macro '__SYSCALL'
22 | #define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64)
| ^~~~~~~~~
include/uapi/asm-generic/unistd.h:43:1: note: in expansion of macro '__SC_3264'
43 | __SC_3264(__NR_io_getevents, sys_io_getevents_time32, sys_io_getevents)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for 'sys_call_table[4]')
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:22:34: note: in expansion of macro '__SYSCALL'
22 | #define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64)
| ^~~~~~~~~
include/uapi/asm-generic/unistd.h:43:1: note: in expansion of macro '__SC_3264'
43 | __SC_3264(__NR_io_getevents, sys_io_getevents_time32, sys_io_getevents)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:48:1: note: in expansion of macro '__SYSCALL'
48 | __SYSCALL(__NR_setxattr, sys_setxattr)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for 'sys_call_table[5]')
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:48:1: note: in expansion of macro '__SYSCALL'
48 | __SYSCALL(__NR_setxattr, sys_setxattr)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
include/uapi/asm-generic/unistd.h:50:1: note: in expansion of macro '__SYSCALL'
50 | __SYSCALL(__NR_lsetxattr, sys_lsetxattr)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for 'sys_call_table[6]')
14 | #define __SYSCALL(nr, call) [nr] = (call),
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/kallsyms.h:13,
from include/linux/ftrace.h:11,
from include/linux/perf_event.h:49,
from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:84,
from arch/riscv/kernel/sys_riscv.c:8:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from arch/riscv/kernel/traps.c:16:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/traps.c:92:15: warning: no previous prototype for 'do_trap_unknown' [-Wmissing-prototypes]
92 | DO_ERROR_INFO(do_trap_unknown,
| ^~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:94:15: warning: no previous prototype for 'do_trap_insn_misaligned' [-Wmissing-prototypes]
94 | DO_ERROR_INFO(do_trap_insn_misaligned,
| ^~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:96:15: warning: no previous prototype for 'do_trap_insn_fault' [-Wmissing-prototypes]
96 | DO_ERROR_INFO(do_trap_insn_fault,
| ^~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:98:15: warning: no previous prototype for 'do_trap_insn_illegal' [-Wmissing-prototypes]
98 | DO_ERROR_INFO(do_trap_insn_illegal,
| ^~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:100:15: warning: no previous prototype for 'do_trap_load_fault' [-Wmissing-prototypes]
100 | DO_ERROR_INFO(do_trap_load_fault,
| ^~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:103:15: warning: no previous prototype for 'do_trap_load_misaligned' [-Wmissing-prototypes]
103 | DO_ERROR_INFO(do_trap_load_misaligned,
| ^~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:105:15: warning: no previous prototype for 'do_trap_store_misaligned' [-Wmissing-prototypes]
105 | DO_ERROR_INFO(do_trap_store_misaligned,
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:127:15: warning: no previous prototype for 'do_trap_store_fault' [-Wmissing-prototypes]
127 | DO_ERROR_INFO(do_trap_store_fault,
| ^~~~~~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:129:15: warning: no previous prototype for 'do_trap_ecall_u' [-Wmissing-prototypes]
129 | DO_ERROR_INFO(do_trap_ecall_u,
| ^~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:131:15: warning: no previous prototype for 'do_trap_ecall_s' [-Wmissing-prototypes]
131 | DO_ERROR_INFO(do_trap_ecall_s,
| ^~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:133:15: warning: no previous prototype for 'do_trap_ecall_m' [-Wmissing-prototypes]
133 | DO_ERROR_INFO(do_trap_ecall_m,
| ^~~~~~~~~~~~~~~
arch/riscv/kernel/traps.c:87:27: note: in definition of macro 'DO_ERROR_INFO'
87 | asmlinkage __visible void name(struct pt_regs *regs) \
| ^~~~
arch/riscv/kernel/traps.c:146:27: warning: no previous prototype for 'do_trap_break' [-Wmissing-prototypes]
146 | asmlinkage __visible void do_trap_break(struct pt_regs *regs)
| ^~~~~~~~~~~~~
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/kallsyms.h:13,
from arch/riscv/kernel/stacktrace.c:8:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/stacktrace.c:24:14: warning: no previous prototype for 'walk_stackframe' [-Wmissing-prototypes]
24 | void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
| ^~~~~~~~~~~~~~~
arch/riscv/kernel/stacktrace.c: In function 'walk_stackframe':
arch/riscv/kernel/stacktrace.c:34:3: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
34 | const register unsigned long current_sp = sp_in_global;
| ^~~~~
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/kallsyms.h:13,
from include/linux/ftrace.h:11,
from arch/riscv/kernel/ftrace.c:8:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/ftrace.c:158:6: warning: no previous prototype for 'prepare_ftrace_return' [-Wmissing-prototypes]
158 | void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
| ^~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/kallsyms.h:13,
from include/linux/ftrace.h:11,
from include/linux/perf_event.h:49,
from arch/riscv/kernel/perf_callchain.c:4:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/perf_callchain.c:77:6: warning: no previous prototype for 'fill_callchain' [-Wmissing-prototypes]
77 | bool fill_callchain(unsigned long pc, void *entry)
| ^~~~~~~~~~~~~~
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/bpf.h:20,
from include/linux/bpf-cgroup.h:5,
from include/linux/cgroup-defs.h:22,
from include/linux/cgroup.h:28,
from include/linux/blk-cgroup.h:17,
from include/linux/writeback.h:14,
from include/linux/backing-dev.h:17,
from fs/btrfs/ctree.h:16,
from fs/btrfs/ctree.c:10:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
fs/btrfs/ctree.c: In function 'btrfs_realloc_node':
fs/btrfs/ctree.c:1581:6: warning: variable 'parent_level' set but not used [-Wunused-but-set-variable]
1581 | int parent_level;
| ^~~~~~~~~~~~
--
In file included from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/bpf.h:20,
from include/linux/bpf-cgroup.h:5,
from include/linux/cgroup-defs.h:22,
from include/linux/cgroup.h:28,
from include/linux/blk-cgroup.h:17,
from include/linux/writeback.h:14,
from include/linux/backing-dev.h:17,
from fs/btrfs/ctree.h:16,
from fs/btrfs/zstd.c:22:
>> arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
In file included from fs/btrfs/zstd.c:19:
include/linux/zstd.h:798:21: warning: 'ZSTD_skippableHeaderSize' defined but not used [-Wunused-const-variable=]
798 | static const size_t ZSTD_skippableHeaderSize = 8;
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/zstd.h:796:21: warning: 'ZSTD_frameHeaderSize_max' defined but not used [-Wunused-const-variable=]
796 | static const size_t ZSTD_frameHeaderSize_max = ZSTD_FRAMEHEADERSIZE_MAX;
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/zstd.h:795:21: warning: 'ZSTD_frameHeaderSize_min' defined but not used [-Wunused-const-variable=]
795 | static const size_t ZSTD_frameHeaderSize_min = ZSTD_FRAMEHEADERSIZE_MIN;
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/zstd.h:794:21: warning: 'ZSTD_frameHeaderSize_prefix' defined but not used [-Wunused-const-variable=]
794 | static const size_t ZSTD_frameHeaderSize_prefix = 5;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +8 arch/riscv/include/asm/elf.h

2129a235c098960 Palmer Dabbelt 2017-07-10 @8 #ifndef _ASM_RISCV_ELF_H
2129a235c098960 Palmer Dabbelt 2017-07-10 9 #define _ASM_RISCV_ELF_H
2129a235c098960 Palmer Dabbelt 2017-07-10 10

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (20.40 kB)
.config.gz (65.98 kB)
Download all attachments

2020-11-13 08:08:13

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 06/19] elf/vdso: Reuse arch_setup_additional_pages() parameters

Hi Dmitry,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on c34f157421f6905e6b4a79a312e9175dce2bc607]

url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
base: c34f157421f6905e6b4a79a312e9175dce2bc607
config: riscv-allmodconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/04586680978b048abe74dd892c5b1fcde7c486a3
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
git checkout 04586680978b048abe74dd892c5b1fcde7c486a3
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from include/linux/elf.h:6,
from arch/riscv/kernel/vdso.c:9:
arch/riscv/include/asm/elf.h:8: error: unterminated #ifndef
8 | #ifndef _ASM_RISCV_ELF_H
|
arch/riscv/kernel/vdso.c: In function 'arch_setup_additional_pages':
>> arch/riscv/kernel/vdso.c:62:27: warning: variable 'vvar_base' set but not used [-Wunused-but-set-variable]
62 | unsigned long vdso_base, vvar_base, vdso_len;
| ^~~~~~~~~

vim +/vvar_base +62 arch/riscv/kernel/vdso.c

> 9 #include <linux/elf.h>
10 #include <linux/mm.h>
11 #include <linux/slab.h>
12 #include <linux/binfmts.h>
13 #include <linux/err.h>
14 #include <asm/page.h>
15 #ifdef GENERIC_TIME_VSYSCALL
16 #include <vdso/datapage.h>
17 #else
18 #include <asm/vdso.h>
19 #endif
20
21 extern char vdso_start[], vdso_end[];
22
23 static unsigned int vdso_pages;
24 static struct page **vdso_pagelist;
25
26 /*
27 * The vDSO data page.
28 */
29 static union {
30 struct vdso_data data;
31 u8 page[PAGE_SIZE];
32 } vdso_data_store __page_aligned_data;
33 struct vdso_data *vdso_data = &vdso_data_store.data;
34
35 static int __init vdso_init(void)
36 {
37 unsigned int i;
38
39 vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
40 vdso_pagelist =
41 kcalloc(vdso_pages + 1, sizeof(struct page *), GFP_KERNEL);
42 if (unlikely(vdso_pagelist == NULL)) {
43 pr_err("vdso: pagelist allocation failed\n");
44 return -ENOMEM;
45 }
46
47 for (i = 0; i < vdso_pages; i++) {
48 struct page *pg;
49
50 pg = virt_to_page(vdso_start + (i << PAGE_SHIFT));
51 vdso_pagelist[i] = pg;
52 }
53 vdso_pagelist[i] = virt_to_page(vdso_data);
54
55 return 0;
56 }
57 arch_initcall(vdso_init);
58
59 int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
60 {
61 struct mm_struct *mm = current->mm;
> 62 unsigned long vdso_base, vvar_base, vdso_len;
63 int ret;
64
65 vdso_len = (vdso_pages + 1) << PAGE_SHIFT;
66
67 mmap_write_lock(mm);
68 vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0);
69 if (IS_ERR_VALUE(vdso_base)) {
70 ret = vdso_base;
71 goto end;
72 }
73
74 /*
75 * Put vDSO base into mm struct. We need to do this before calling
76 * install_special_mapping or the perf counter mmap tracking code
77 * will fail to recognise it as a vDSO (since arch_vma_name fails).
78 */
79 mm->context.vdso = (void *)vdso_base;
80
81 ret =
82 install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
83 (VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC),
84 vdso_pagelist);
85
86 if (unlikely(ret)) {
87 mm->context.vdso = NULL;
88 goto end;
89 }
90
91 vvar_base = vdso_base + (vdso_pages << PAGE_SHIFT);
92 ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
93 (VM_READ | VM_MAYREAD), &vdso_pagelist[vdso_pages]);
94
95 if (unlikely(ret))
96 mm->context.vdso = NULL;
97 else
98 *sysinfo_ehdr = vdso_base;
99 end:
100 mmap_write_unlock(mm);
101 return ret;
102 }
103

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (4.70 kB)
.config.gz (65.98 kB)
Download all attachments

2020-11-13 10:01:24

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 19/19] mips/vdso: Migrate to user_landing

Hi Dmitry,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on c34f157421f6905e6b4a79a312e9175dce2bc607]

url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
base: c34f157421f6905e6b4a79a312e9175dce2bc607
config: mips-randconfig-p002-20201109 (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/cf47146993b3d1866163ee1815829d9e76b48807
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dmitry-Safonov/Add-generic-user_landing-tracking/20201109-090354
git checkout cf47146993b3d1866163ee1815829d9e76b48807
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

arch/mips/kernel/signal.c:439:5: warning: no previous prototype for 'setup_sigcontext' [-Wmissing-prototypes]
439 | int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
| ^~~~~~~~~~~~~~~~
arch/mips/kernel/signal.c:516:5: warning: no previous prototype for 'restore_sigcontext' [-Wmissing-prototypes]
516 | int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
| ^~~~~~~~~~~~~~~~~~
arch/mips/kernel/signal.c:630:17: warning: no previous prototype for 'sys_sigreturn' [-Wmissing-prototypes]
630 | asmlinkage void sys_sigreturn(void)
| ^~~~~~~~~~~~~
arch/mips/kernel/signal.c:667:17: warning: no previous prototype for 'sys_rt_sigreturn' [-Wmissing-prototypes]
667 | asmlinkage void sys_rt_sigreturn(void)
| ^~~~~~~~~~~~~~~~
In file included from include/linux/mmzone.h:21,
from include/linux/gfp.h:6,
from include/linux/mm.h:10,
from arch/mips/kernel/signal.c:15:
arch/mips/kernel/signal.c: In function 'handle_signal':
include/linux/mm_types.h:500:31: error: 'TASK_SIZE_MAX' undeclared (first use in this function); did you mean 'TASK_SIZE_OF'?
500 | #define UNMAPPED_USER_LANDING TASK_SIZE_MAX
| ^~~~~~~~~~~~~
arch/mips/kernel/signal.c:814:14: note: in expansion of macro 'UNMAPPED_USER_LANDING'
814 | if (land == UNMAPPED_USER_LANDING)
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/mm_types.h:500:31: note: each undeclared identifier is reported only once for each function it appears in
500 | #define UNMAPPED_USER_LANDING TASK_SIZE_MAX
| ^~~~~~~~~~~~~
arch/mips/kernel/signal.c:814:14: note: in expansion of macro 'UNMAPPED_USER_LANDING'
814 | if (land == UNMAPPED_USER_LANDING)
| ^~~~~~~~~~~~~~~~~~~~~
>> arch/mips/kernel/signal.c:848:34: warning: passing argument 1 of 'abi->setup_rt_frame' makes pointer from integer without a cast [-Wint-conversion]
848 | ret = abi->setup_rt_frame(land + abi->vdso->off_rt_sigreturn,
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned int
arch/mips/kernel/signal.c:848:34: note: expected 'void *' but argument is of type 'long unsigned int'
>> arch/mips/kernel/signal.c:851:31: warning: passing argument 1 of 'abi->setup_frame' makes pointer from integer without a cast [-Wint-conversion]
851 | ret = abi->setup_frame(land + abi->vdso->off_sigreturn,
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned int
arch/mips/kernel/signal.c:851:31: note: expected 'void *' but argument is of type 'long unsigned int'
arch/mips/kernel/signal.c: At top level:
arch/mips/kernel/signal.c:898:17: warning: no previous prototype for 'do_notify_resume' [-Wmissing-prototypes]
898 | asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
| ^~~~~~~~~~~~~~~~

vim +848 arch/mips/kernel/signal.c

806
807 static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
808 {
809 unsigned long land = (unsigned long)current->mm->user_landing;
810 sigset_t *oldset = sigmask_to_save();
811 int ret = 1;
812 struct mips_abi *abi = current->thread.abi;
813
814 if (land == UNMAPPED_USER_LANDING)
815 goto err;
816 /*
817 * If we were emulating a delay slot instruction, exit that frame such
818 * that addresses in the sigframe are as expected for userland and we
819 * don't have a problem if we reuse the thread's frame for an
820 * instruction within the signal handler.
821 */
822 dsemul_thread_rollback(regs);
823
824 if (regs->regs[0]) {
825 switch(regs->regs[2]) {
826 case ERESTART_RESTARTBLOCK:
827 case ERESTARTNOHAND:
828 regs->regs[2] = EINTR;
829 break;
830 case ERESTARTSYS:
831 if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
832 regs->regs[2] = EINTR;
833 break;
834 }
835 fallthrough;
836 case ERESTARTNOINTR:
837 regs->regs[7] = regs->regs[26];
838 regs->regs[2] = regs->regs[0];
839 regs->cp0_epc -= 4;
840 }
841
842 regs->regs[0] = 0; /* Don't deal with this again. */
843 }
844
845 rseq_signal_deliver(ksig, regs);
846
847 if (sig_uses_siginfo(&ksig->ka, abi))
> 848 ret = abi->setup_rt_frame(land + abi->vdso->off_rt_sigreturn,
849 ksig, regs, oldset);
850 else
> 851 ret = abi->setup_frame(land + abi->vdso->off_sigreturn,
852 ksig, regs, oldset);
853
854 err:
855 signal_setup_done(ret, ksig, 0);
856 }
857

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (6.26 kB)
.config.gz (26.97 kB)
Download all attachments