Skip to content

Commit be92709

Browse files
committed
Merge tag 'v6.18.31' into rpi-6.18.y
This is the 6.18.31 stable release
2 parents edf0433 + 6c1de6e commit be92709

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 6
33
PATCHLEVEL = 18
4-
SUBLEVEL = 30
4+
SUBLEVEL = 31
55
EXTRAVERSION =
66
NAME = Baby Opossum Posse
77

include/linux/sched.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,9 @@ struct task_struct {
10031003
unsigned sched_rt_mutex:1;
10041004
#endif
10051005

1006+
/* Save user-dumpable when mm goes away */
1007+
unsigned user_dumpable:1;
1008+
10061009
/* Bit to tell TOMOYO we're in execve(): */
10071010
unsigned in_execve:1;
10081011
unsigned in_iowait:1;

kernel/exit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ static void exit_mm(void)
572572
*/
573573
smp_mb__after_spinlock();
574574
local_irq_disable();
575+
current->user_dumpable = (get_dumpable(mm) == SUID_DUMP_USER);
575576
current->mm = NULL;
576577
membarrier_update_current_mm(NULL);
577578
enter_lazy_tlb(mm, current);

kernel/ptrace.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,24 @@ static bool ptrace_has_cap(struct user_namespace *ns, unsigned int mode)
272272
return ns_capable(ns, CAP_SYS_PTRACE);
273273
}
274274

275+
static bool task_still_dumpable(struct task_struct *task, unsigned int mode)
276+
{
277+
struct mm_struct *mm = task->mm;
278+
if (mm) {
279+
if (get_dumpable(mm) == SUID_DUMP_USER)
280+
return true;
281+
return ptrace_has_cap(mm->user_ns, mode);
282+
}
283+
284+
if (task->user_dumpable)
285+
return true;
286+
return ptrace_has_cap(&init_user_ns, mode);
287+
}
288+
275289
/* Returns 0 on success, -errno on denial. */
276290
static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
277291
{
278292
const struct cred *cred = current_cred(), *tcred;
279-
struct mm_struct *mm;
280293
kuid_t caller_uid;
281294
kgid_t caller_gid;
282295

@@ -337,11 +350,8 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
337350
* Pairs with a write barrier in commit_creds().
338351
*/
339352
smp_rmb();
340-
mm = task->mm;
341-
if (mm &&
342-
((get_dumpable(mm) != SUID_DUMP_USER) &&
343-
!ptrace_has_cap(mm->user_ns, mode)))
344-
return -EPERM;
353+
if (!task_still_dumpable(task, mode))
354+
return -EPERM;
345355

346356
return security_ptrace_access_check(task, mode);
347357
}

0 commit comments

Comments
 (0)