History

sched/coredump: introduce enum task_dumpable

Replace the SUID_DUMP_DISABLE/USER/ROOT preprocessor constants with enum task_dumpable. Numeric values are preserved (kernel.suid_dumpable sysctl and prctl(PR_SET_DUMPABLE) ABI), so this is a pure rename with no behavioral change. Subsequent commits relocate dumpability onto a per-task structure where the enum type will allow stronger type-checking on the new API.

Christian Brauner (Amutable) committed 5 months ago

Commit 4f365e71 parent 5200f5f10 files · +27 −20Browse files

Showing the changes to kernel (3 of 10 files). Show all

Unified · Split

3 files
  1. kernel/exit.c +1 −1
  2. kernel/ptrace.c +2 −2
  3. kernel/sys.c +1 −1
kernel/exit.c+1−1
@@ -571,7 +571,7 @@ static void exit_mm(void) · 570 unmodified lines
571571 */
572572 smp_mb__after_spinlock();
573573 local_irq_disable();
574− current->user_dumpable = (get_dumpable(mm) == SUID_DUMP_USER);
574+ current->user_dumpable = (get_dumpable(mm) == TASK_DUMPABLE_OWNER);
575575 current->mm = NULL;
576576 membarrier_update_current_mm(NULL);
577577 enter_lazy_tlb(mm, current);
kernel/ptrace.c+2−2
@@ -53,7 +53,7 @@ int ptrace_access_vm(struct task_struct *tsk, unsigned long addr, · 52 unmodified lines
5353
5454 if (!tsk->ptrace ||
5555 (current != tsk->parent) ||
56− ((get_dumpable(mm) != SUID_DUMP_USER) &&
56+ ((get_dumpable(mm) != TASK_DUMPABLE_OWNER) &&
5757 !ptracer_capable(tsk, mm->user_ns))) {
5858 mmput(mm);
5959 return 0;
@@ -276,7 +276,7 @@ static bool task_still_dumpable(struct task_struct *task, unsigned int mode) · 216 unmodified lines
276276 {
277277 struct mm_struct *mm = task->mm;
278278 if (mm) {
279− if (get_dumpable(mm) == SUID_DUMP_USER)
279+ if (get_dumpable(mm) == TASK_DUMPABLE_OWNER)
280280 return true;
281281 return ptrace_has_cap(mm->user_ns, mode);
282282 }
kernel/sys.c+1−1
@@ -2568,7 +2568,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, · 2567 unmodified lines
25682568 error = get_dumpable(me->mm);
25692569 break;
25702570 case PR_SET_DUMPABLE:
2571− if (arg2 != SUID_DUMP_DISABLE && arg2 != SUID_DUMP_USER) {
2571+ if (arg2 != TASK_DUMPABLE_OFF && arg2 != TASK_DUMPABLE_OWNER) {
25722572 error = -EINVAL;
25732573 break;
25742574 }