diff options
Diffstat (limited to 'arch/riscv/kernel')
| -rw-r--r-- | arch/riscv/kernel/entry.S | 11 | ||||
| -rw-r--r-- | arch/riscv/kernel/module.c | 16 | ||||
| -rw-r--r-- | arch/riscv/kernel/ptrace.c | 11 | 
3 files changed, 24 insertions, 14 deletions
| diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index bad4d85b5e91..208702d8c18e 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S @@ -229,19 +229,12 @@ check_syscall_nr:  	li t0, __NR_syscalls  	la s0, sys_ni_syscall  	/* -	 * The tracer can change syscall number to valid/invalid value. -	 * We use syscall_set_nr helper in syscall_trace_enter thus we -	 * cannot trust the current value in a7 and have to reload from -	 * the current task pt_regs. -	 */ -	REG_L a7, PT_A7(sp) -	/*  	 * Syscall number held in a7.  	 * If syscall number is above allowed value, redirect to ni_syscall.  	 */  	bge a7, t0, 1f  	/* -	 * Check if syscall is rejected by tracer or seccomp, i.e., a7 == -1. +	 * Check if syscall is rejected by tracer, i.e., a7 == -1.  	 * If yes, we pretend it was executed.  	 */  	li t1, -1 @@ -334,6 +327,7 @@ work_resched:  handle_syscall_trace_enter:  	move a0, sp  	call do_syscall_trace_enter +	move t0, a0  	REG_L a0, PT_A0(sp)  	REG_L a1, PT_A1(sp)  	REG_L a2, PT_A2(sp) @@ -342,6 +336,7 @@ handle_syscall_trace_enter:  	REG_L a5, PT_A5(sp)  	REG_L a6, PT_A6(sp)  	REG_L a7, PT_A7(sp) +	bnez t0, ret_from_syscall_rejected  	j check_syscall_nr  handle_syscall_trace_exit:  	move a0, sp diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c index b7401858d872..8bbe5dbe1341 100644 --- a/arch/riscv/kernel/module.c +++ b/arch/riscv/kernel/module.c @@ -8,6 +8,10 @@  #include <linux/err.h>  #include <linux/errno.h>  #include <linux/moduleloader.h> +#include <linux/vmalloc.h> +#include <linux/sizes.h> +#include <asm/pgtable.h> +#include <asm/sections.h>  static int apply_r_riscv_32_rela(struct module *me, u32 *location, Elf_Addr v)  { @@ -386,3 +390,15 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,  	return 0;  } + +#if defined(CONFIG_MMU) && defined(CONFIG_64BIT) +#define VMALLOC_MODULE_START \ +	 max(PFN_ALIGN((unsigned long)&_end - SZ_2G), VMALLOC_START) +void *module_alloc(unsigned long size) +{ +	return __vmalloc_node_range(size, 1, VMALLOC_MODULE_START, +				    VMALLOC_END, GFP_KERNEL, +				    PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, +				    __builtin_return_address(0)); +} +#endif diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c index 407464201b91..444dc7b0fd78 100644 --- a/arch/riscv/kernel/ptrace.c +++ b/arch/riscv/kernel/ptrace.c @@ -148,21 +148,19 @@ long arch_ptrace(struct task_struct *child, long request,   * Allows PTRACE_SYSCALL to work.  These are called from entry.S in   * {handle,ret_from}_syscall.   */ -__visible void do_syscall_trace_enter(struct pt_regs *regs) +__visible int do_syscall_trace_enter(struct pt_regs *regs)  {  	if (test_thread_flag(TIF_SYSCALL_TRACE))  		if (tracehook_report_syscall_entry(regs)) -			syscall_set_nr(current, regs, -1); +			return -1;  	/*  	 * Do the secure computing after ptrace; failures should be fast.  	 * If this fails we might have return value in a0 from seccomp  	 * (via SECCOMP_RET_ERRNO/TRACE).  	 */ -	if (secure_computing() == -1) { -		syscall_set_nr(current, regs, -1); -		return; -	} +	if (secure_computing() == -1) +		return -1;  #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS  	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) @@ -170,6 +168,7 @@ __visible void do_syscall_trace_enter(struct pt_regs *regs)  #endif  	audit_syscall_entry(regs->a7, regs->a0, regs->a1, regs->a2, regs->a3); +	return 0;  }  __visible void do_syscall_trace_exit(struct pt_regs *regs) |