lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231117132148.17844-1-CruzZhao@linux.alibaba.com>
Date:   Fri, 17 Nov 2023 21:21:48 +0800
From:   Cruz Zhao <CruzZhao@...ux.alibaba.com>
To:     mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com, vschneid@...hat.com, joel@...lfernandes.org
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH] sched/core: put the cookie to uaddr when create cookie

For the control process, it's necessary to get the cookie of the
task when create a cookie with command PR_SCHED_CORE_CREATE. In
current design, we have to use command PR_SCHED_CORE_GET after we
create a cookie, with one more syscall.

To optimize this process, we allow user to pass a userspace address,
and we put the cookie to the uaddr when we create the cookie
successfully. If the uaddr is NULL, the logic is the same as before.

Note that put_user() will return -EFAULT if error, which is different
from any error return value of sched_core_share_pid().

Signed-off-by: Cruz Zhao <CruzZhao@...ux.alibaba.com>
---
 kernel/sched/core_sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c
index a57fd8f27498..96bd159844b7 100644
--- a/kernel/sched/core_sched.c
+++ b/kernel/sched/core_sched.c
@@ -142,7 +142,7 @@ int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
 	BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_PROCESS_GROUP != PIDTYPE_PGID);
 
 	if (type > PIDTYPE_PGID || cmd >= PR_SCHED_CORE_MAX || pid < 0 ||
-	    (cmd != PR_SCHED_CORE_GET && uaddr))
+	    (cmd != PR_SCHED_CORE_GET && cmd != PR_SCHED_CORE_CREATE && uaddr))
 		return -EINVAL;
 
 	rcu_read_lock();
@@ -229,6 +229,10 @@ int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
 	read_unlock(&tasklist_lock);
 
 out:
+	if (cmd == PR_SCHED_CORE_CREATE && !err && uaddr) {
+		ptr_to_hashval((void *)cookie, &id);
+		err = put_user(id, (u64 __user *)uaddr);
+	}
 	sched_core_put_cookie(cookie);
 	put_task_struct(task);
 	return err;
-- 
2.39.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ