Skip to content

Commit 7612bfe

Browse files
keesJames Morris
authored andcommitted
Yama: access task_struct->comm directly
The core ptrace access checking routine holds a task lock, and when reporting a failure, Yama takes a separate task lock. To avoid a potential deadlock with two ptracers taking the opposite locks, do not use get_task_comm() and just use ->comm directly since accuracy is not important for the report. Reported-by: Fengguang Wu <fengguang.wu@intel.com> Suggested-by: Oleg Nesterov <oleg@redhat.com> CC: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: John Johansen <john.johansen@canonical.com> Signed-off-by: James Morris <james.l.morris@oracle.com>
1 parent d987569 commit 7612bfe

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

‎security/yama/yama_lsm.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,9 @@ static int yama_ptrace_access_check(struct task_struct *child,
279279
}
280280

281281
if (rc) {
282-
char name[sizeof(current->comm)];
283282
printk_ratelimited(KERN_NOTICE
284283
"ptrace of pid %d was attempted by: %s (pid %d)\n",
285-
child->pid,
286-
get_task_comm(name, current),
287-
current->pid);
284+
child->pid, current->comm, current->pid);
288285
}
289286

290287
return rc;
@@ -319,12 +316,9 @@ static int yama_ptrace_traceme(struct task_struct *parent)
319316
}
320317

321318
if (rc) {
322-
char name[sizeof(current->comm)];
323319
printk_ratelimited(KERN_NOTICE
324320
"ptraceme of pid %d was attempted by: %s (pid %d)\n",
325-
current->pid,
326-
get_task_comm(name, parent),
327-
parent->pid);
321+
current->pid, parent->comm, parent->pid);
328322
}
329323

330324
return rc;

0 commit comments

Comments
 (0)