Skip to content

Commit 5147da9

Browse files
committed
Merge branch 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull exit cleanups from Eric Biederman: "While looking at some issues related to the exit path in the kernel I found several instances where the code is not using the existing abstractions properly. This set of changes introduces force_fatal_sig a way of sending a signal and not allowing it to be caught, and corrects the misuse of the existing abstractions that I found. A lot of the misuse of the existing abstractions are silly things such as doing something after calling a no return function, rolling BUG by hand, doing more work than necessary to terminate a kernel thread, or calling do_exit(SIGKILL) instead of calling force_sig(SIGKILL). In the review a deficiency in force_fatal_sig and force_sig_seccomp where ptrace or sigaction could prevent the delivery of the signal was found. I have added a change that adds SA_IMMUTABLE to change that makes it impossible to interrupt the delivery of those signals, and allows backporting to fix force_sig_seccomp And Arnd found an issue where a function passed to kthread_run had the wrong prototype, and after my cleanup was failing to build." * 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (23 commits) soc: ti: fix wkup_m3_rproc_boot_thread return type signal: Add SA_IMMUTABLE to ensure forced siganls do not get changed signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV) exit/r8188eu: Replace the macro thread_exit with a simple return 0 exit/rtl8712: Replace the macro thread_exit with a simple return 0 exit/rtl8723bs: Replace the macro thread_exit with a simple return 0 signal/x86: In emulate_vsyscall force a signal instead of calling do_exit signal/sparc32: In setup_rt_frame and setup_fram use force_fatal_sig signal/sparc32: Exit with a fatal signal when try_to_clear_window_buffer fails exit/syscall_user_dispatch: Send ordinary signals on failure signal: Implement force_fatal_sig exit/kthread: Have kernel threads return instead of calling do_exit signal/s390: Use force_sigsegv in default_trap_handler signal/vm86_32: Properly send SIGSEGV when the vm86 state cannot be saved. signal/vm86_32: Replace open coded BUG_ON with an actual BUG_ON signal/sparc: In setup_tsb_params convert open coded BUG into BUG signal/powerpc: On swapcontext failure force SIGSEGV signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL) signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT signal/sparc32: Remove unreachable do_exit in do_sparc_fault ...
2 parents a41b744 + f91140e commit 5147da9

File tree

47 files changed

+97
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+97
-96
lines changed

arch/arc/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ int elf_check_arch(const struct elf32_hdr *x)
294294
eflags = x->e_flags;
295295
if ((eflags & EF_ARC_OSABI_MSK) != EF_ARC_OSABI_CURRENT) {
296296
pr_err("ABI mismatch - you need newer toolchain\n");
297-
force_sigsegv(SIGSEGV);
297+
force_fatal_sig(SIGSEGV);
298298
return 0;
299299
}
300300

arch/m68k/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ asmlinkage void set_esp0(unsigned long ssp)
11451145
*/
11461146
asmlinkage void fpsp040_die(void)
11471147
{
1148-
force_sigsegv(SIGSEGV);
1148+
force_fatal_sig(SIGSEGV);
11491149
}
11501150

11511151
#ifdef CONFIG_M68KFPU_EMU

arch/mips/kernel/r2300_fpu.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#define EX2(a,b) \
3030
9: a,##b; \
3131
.section __ex_table,"a"; \
32-
PTR 9b,bad_stack; \
33-
PTR 9b+4,bad_stack; \
32+
PTR 9b,fault; \
33+
PTR 9b+4,fault; \
3434
.previous
3535

3636
.set mips1

arch/mips/kernel/syscall.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,3 @@ SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op)
240240
{
241241
return -ENOSYS;
242242
}
243-
244-
/*
245-
* If we ever come here the user sp is bad. Zap the process right away.
246-
* Due to the bad stack signaling wouldn't work.
247-
*/
248-
asmlinkage void bad_stack(void)
249-
{
250-
do_exit(SIGSEGV);
251-
}

arch/nds32/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ DEFINE_SPINLOCK(die_lock);
118118
/*
119119
* This function is protected against re-entrancy.
120120
*/
121-
void die(const char *str, struct pt_regs *regs, int err)
121+
void __noreturn die(const char *str, struct pt_regs *regs, int err)
122122
{
123123
struct task_struct *tsk = current;
124124
static int die_counter;

arch/nds32/mm/fault.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <asm/tlbflush.h>
1515

16-
extern void die(const char *str, struct pt_regs *regs, long err);
16+
extern void __noreturn die(const char *str, struct pt_regs *regs, long err);
1717

1818
/*
1919
* This is useful to dump out the page tables associated with
@@ -299,10 +299,6 @@ void do_page_fault(unsigned long entry, unsigned long addr,
299299

300300
show_pte(mm, addr);
301301
die("Oops", regs, error_code);
302-
bust_spinlocks(0);
303-
do_exit(SIGKILL);
304-
305-
return;
306302

307303
/*
308304
* We ran out of memory, or some other thing happened to us that made

arch/openrisc/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void nommu_dump_state(struct pt_regs *regs,
197197
}
198198

199199
/* This is normally the 'Oops' routine */
200-
void die(const char *str, struct pt_regs *regs, long err)
200+
void __noreturn die(const char *str, struct pt_regs *regs, long err)
201201
{
202202

203203
console_verbose();

arch/openrisc/mm/fault.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ unsigned long pte_errors; /* updated by do_page_fault() */
3232
*/
3333
volatile pgd_t *current_pgd[NR_CPUS];
3434

35-
extern void die(char *, struct pt_regs *, long);
35+
extern void __noreturn die(char *, struct pt_regs *, long);
3636

3737
/*
3838
* This routine handles page faults. It determines the address,
@@ -248,8 +248,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
248248

249249
die("Oops", regs, write_acc);
250250

251-
do_exit(SIGKILL);
252-
253251
/*
254252
* We ran out of memory, or some other thing happened to us that made
255253
* us unable to handle the page fault gracefully.

arch/powerpc/kernel/signal_32.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,10 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
10621062
* or if another thread unmaps the region containing the context.
10631063
* We kill the task with a SIGSEGV in this situation.
10641064
*/
1065-
if (do_setcontext(new_ctx, regs, 0))
1066-
do_exit(SIGSEGV);
1065+
if (do_setcontext(new_ctx, regs, 0)) {
1066+
force_fatal_sig(SIGSEGV);
1067+
return -EFAULT;
1068+
}
10671069

10681070
set_thread_flag(TIF_RESTOREALL);
10691071
return 0;

arch/powerpc/kernel/signal_64.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,15 +703,18 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
703703
* We kill the task with a SIGSEGV in this situation.
704704
*/
705705

706-
if (__get_user_sigset(&set, &new_ctx->uc_sigmask))
707-
do_exit(SIGSEGV);
706+
if (__get_user_sigset(&set, &new_ctx->uc_sigmask)) {
707+
force_fatal_sig(SIGSEGV);
708+
return -EFAULT;
709+
}
708710
set_current_blocked(&set);
709711

710712
if (!user_read_access_begin(new_ctx, ctx_size))
711713
return -EFAULT;
712714
if (__unsafe_restore_sigcontext(current, NULL, 0, &new_ctx->uc_mcontext)) {
713715
user_read_access_end();
714-
do_exit(SIGSEGV);
716+
force_fatal_sig(SIGSEGV);
717+
return -EFAULT;
715718
}
716719
user_read_access_end();
717720

0 commit comments

Comments
 (0)