Re: [resend RFC 2/3] sched/prctl: add PR_SCHED_CORE_SHARE command

From: Josh Don
Date: Mon Jan 24 2022 - 22:10:54 EST


Hey Christian,

This seems like a reasonable extension of the interface to me.

> @@ -200,6 +212,20 @@ int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
> __sched_core_set(current, cookie);
> goto out;
>
> + case PR_SCHED_CORE_SHARE:
> + rcu_read_lock();
> + p = task_by_pid(pid_share);
> + if (!p)
> + err = -ESRCH;
> + else if (!ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS))
> + err = -EPERM;
> + if (!err)
> + cookie = sched_core_clone_cookie(p);
> + rcu_read_unlock();
> + if (err)
> + goto out;
> + break;
> +

Did you consider folding this into SCHED_CORE_SHARE_TO? SHARE_TO isn't
using the last arg right now; it could use it as an override for the
task we copy the cookie from instead of always choosing 'current'.
Since the code currently rejects any SCHED_CORE prctl calls with a
non-zero last arg for commands other than SCHED_CORE_GET, this would
be a safe change for userspace.