1
0
linux/debian/patches/patchset-pf/ksm/0002-mm-process_ksm-use-pidfd_get_task-instead-of-pidfd_g.patch

51 lines
1.3 KiB
Diff
Raw Normal View History

From 9308d03bfeb941469da17e2903ca06254b110b25 Mon Sep 17 00:00:00 2001
From: Oleksandr Natalenko <oleksandr@natalenko.name>
Date: Tue, 24 Sep 2024 11:58:41 +0200
Subject: mm/process_ksm: use pidfd_get_task() instead of
pidfd_get_pid()+get_pid_task()
Link: https://git.kernel.org/linus/ee9955d61a0a
Signed-off-by: Oleksandr Natalenko <oleksandr@natalenko.name>
---
kernel/sys.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2799,23 +2799,16 @@ enum pkc_action {
static long do_process_ksm_control(int pidfd, enum pkc_action action)
{
long ret;
- struct pid *pid;
struct task_struct *task;
struct mm_struct *mm;
unsigned int f_flags;
- pid = pidfd_get_pid(pidfd, &f_flags);
- if (IS_ERR(pid)) {
- ret = PTR_ERR(pid);
+ task = pidfd_get_task(pidfd, &f_flags);
+ if (IS_ERR(task)) {
+ ret = PTR_ERR(task);
goto out;
}
- task = get_pid_task(pid, PIDTYPE_PID);
- if (!task) {
- ret = -ESRCH;
- goto put_pid;
- }
-
/* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */
mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
if (IS_ERR_OR_NULL(mm)) {
@@ -2852,8 +2845,6 @@ release_mm:
mmput(mm);
release_task:
put_task_struct(task);
-put_pid:
- put_pid(pid);
out:
return ret;
}