From: Prakash Sangappa <prakash.sangappa@oracle.com>
To: linux-kernel@vger.kernel.org
Cc: ebiederm@xmission.com, tglx@linutronix.de, peterz@infradead.org,
serge@hallyn.com, prakash.sangappa@oracle.com
Subject: [RFC PATCH 1/1] Selectively allow CAP_SYS_NICE capability inside user namespaces
Date: Fri, 1 Nov 2019 11:18:28 -0700 [thread overview]
Message-ID: <1572632308-7071-2-git-send-email-prakash.sangappa@oracle.com> (raw)
In-Reply-To: <1572632308-7071-1-git-send-email-prakash.sangappa@oracle.com>
Allow CAP_SYS_NICE to take effect for processes having effective uid of a
root user from init namespace.
Signed-off-by: Prakash Sangappa <prakash.sangappa@oracle.com>
---
kernel/sched/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7880f4f..628bd46 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4548,6 +4548,8 @@ int can_nice(const struct task_struct *p, const int nice)
int nice_rlim = nice_to_rlimit(nice);
return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
+ (ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE) &&
+ uid_eq(current_euid(), GLOBAL_ROOT_UID)) ||
capable(CAP_SYS_NICE));
}
@@ -4784,7 +4786,9 @@ static int __sched_setscheduler(struct task_struct *p,
/*
* Allow unprivileged RT tasks to decrease priority:
*/
- if (user && !capable(CAP_SYS_NICE)) {
+ if (user && !(ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE) &&
+ uid_eq(current_euid(), GLOBAL_ROOT_UID)) &&
+ !capable(CAP_SYS_NICE)) {
if (fair_policy(policy)) {
if (attr->sched_nice < task_nice(p) &&
!can_nice(p, attr->sched_nice))
--
2.7.4
prev parent reply other threads:[~2019-11-01 18:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-01 18:18 [RFC PATCH 0/1] CAP_SYS_NICE inside user namespace Prakash Sangappa
2019-11-01 18:18 ` Prakash Sangappa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1572632308-7071-2-git-send-email-prakash.sangappa@oracle.com \
--to=prakash.sangappa@oracle.com \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=serge@hallyn.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®