From nobody Fri Dec 10 02:55:05 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C9D3218CA697; Fri, 10 Dec 2021 02:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J9Fr93w81z3ByM; Fri, 10 Dec 2021 02:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6611412E5C; Fri, 10 Dec 2021 02:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BA2t5Ht088088; Fri, 10 Dec 2021 02:55:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BA2t5Ki088087; Fri, 10 Dec 2021 02:55:05 GMT (envelope-from git) Date: Fri, 10 Dec 2021 02:55:05 GMT Message-Id: <202112100255.1BA2t5Ki088087@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a20a2450cd5f - main - Add PRIV_SCHED_IDPRIO List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a20a2450cd5f38fb28d5fa5540177edfb60d2473 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639104905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ehj/vIyiSOt44ifc75xtztu9DyhicD3WekZW6FOq8CQ=; b=HhjOHYj25VI5Y46s8xcWjkArZfB4OZhL1rrH1T10v7RqQ6p9M5Gj/l8BFdAklvrv902aoo AJ26+6qY7ZMMByvMkXYNV+/vNLiTvP3RhNNQsQyKbZ/6AI2oBVNaANQeu9ITEvb2Frk6QC +h8vgGt4XfQXRALYEyPVzsYIWMnb/QFAeU5TinESyeFg3wtX0Pj6ByhF6CwT/KSqTgxL4d sOWxYlOuj6lQzi3ibVFGeTEaRGfsqFRoiRqQpxkH31GgRYHhy14oC+589lWGiPKsKNykLD eLRch11lBQOCP7hk/b2wCL8uP3ln2Uv7HFGqnM5+Jc0d1MnDXHZ+rCpwLAaNQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639104905; a=rsa-sha256; cv=none; b=HDn3zE/JhANlWoBKgnbDyFC4zkA+FuV6j/PoMu5aFaFvmo0ApBLEgGNR16voNDKwKvy60z OMxczbZoMNn88T/h/tp5+SjJ2awHxC/+VXtcVYG+kU14jbBXccU3XpWzdfYChxWQFX1Yby gMCCwQch+sRhx8s4T1XYcDLEWiwurZXATIEUqo5OIKzlHf2I1TS/lUeVjY5/pFhRIQ4l0O g6hHk4SfQCBvzgCfZrNnH5tYLfMbuayLzW0l918TlqEPxOEAMthWrKzVvnVDMlU5L426mC lkP8O0NzZUfkoQonHTWIOyEkppSrlChjp8zUwAVo0UuzV4mqWavDAWUp8cmncA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a20a2450cd5f38fb28d5fa5540177edfb60d2473 commit a20a2450cd5f38fb28d5fa5540177edfb60d2473 Author: Florian Walpen AuthorDate: 2021-12-10 01:43:12 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-10 02:54:48 +0000 Add PRIV_SCHED_IDPRIO The privilege allows the holder to assign idle priority type to thread or process. MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D33338 --- sys/kern/kern_resource.c | 28 ++++++++++++++-------------- sys/security/mac_biba/mac_biba.c | 1 + sys/security/mac_lomac/mac_lomac.c | 1 + sys/sys/priv.h | 1 + 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 5b90148ccf99..a2005962e411 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -350,13 +350,13 @@ sys_rtprio_thread(struct thread *td, struct rtprio_thread_args *uap) * easier to lock a resource indefinitely, but it is not the * only thing that makes it possible. */ - if (RTP_PRIO_BASE(rtp.type) == RTP_PRIO_REALTIME || - (RTP_PRIO_BASE(rtp.type) == RTP_PRIO_IDLE && - unprivileged_idprio == 0)) { - error = priv_check(td, PRIV_SCHED_RTPRIO); - if (error) - break; - } + if (RTP_PRIO_BASE(rtp.type) == RTP_PRIO_REALTIME && + (error = priv_check(td, PRIV_SCHED_RTPRIO)) != 0) + break; + if (RTP_PRIO_BASE(rtp.type) == RTP_PRIO_IDLE && + unprivileged_idprio == 0 && + (error = priv_check(td, PRIV_SCHED_IDPRIO)) != 0) + break; error = rtp_to_pri(&rtp, td1); break; default: @@ -440,13 +440,13 @@ sys_rtprio(struct thread *td, struct rtprio_args *uap) * See the comment in sys_rtprio_thread about idprio * threads holding a lock. */ - if (RTP_PRIO_BASE(rtp.type) == RTP_PRIO_REALTIME || - (RTP_PRIO_BASE(rtp.type) == RTP_PRIO_IDLE && - !unprivileged_idprio)) { - error = priv_check(td, PRIV_SCHED_RTPRIO); - if (error) - break; - } + if (RTP_PRIO_BASE(rtp.type) == RTP_PRIO_REALTIME && + (error = priv_check(td, PRIV_SCHED_RTPRIO)) != 0) + break; + if (RTP_PRIO_BASE(rtp.type) == RTP_PRIO_IDLE && + unprivileged_idprio == 0 && + (error = priv_check(td, PRIV_SCHED_IDPRIO)) != 0) + break; /* * If we are setting our own priority, set just our diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c index 296d4a4e25b8..08df65cc289d 100644 --- a/sys/security/mac_biba/mac_biba.c +++ b/sys/security/mac_biba/mac_biba.c @@ -1975,6 +1975,7 @@ biba_priv_check(struct ucred *cred, int priv) case PRIV_SCHED_SETPOLICY: case PRIV_SCHED_SET: case PRIV_SCHED_SETPARAM: + case PRIV_SCHED_IDPRIO: /* * More IPC privileges. diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c index 821b0faf68d0..c017b481c7fa 100644 --- a/sys/security/mac_lomac/mac_lomac.c +++ b/sys/security/mac_lomac/mac_lomac.c @@ -1743,6 +1743,7 @@ lomac_priv_check(struct ucred *cred, int priv) case PRIV_SCHED_SETPOLICY: case PRIV_SCHED_SET: case PRIV_SCHED_SETPARAM: + case PRIV_SCHED_IDPRIO: /* * More IPC privileges. diff --git a/sys/sys/priv.h b/sys/sys/priv.h index 7ef54782a60d..8757db879a5c 100644 --- a/sys/sys/priv.h +++ b/sys/sys/priv.h @@ -192,6 +192,7 @@ #define PRIV_SCHED_SETPARAM 205 /* Can set thread scheduler params. */ #define PRIV_SCHED_CPUSET 206 /* Can manipulate cpusets. */ #define PRIV_SCHED_CPUSET_INTR 207 /* Can adjust IRQ to CPU binding. */ +#define PRIV_SCHED_IDPRIO 208 /* Can set idle time scheduling. */ /* * POSIX semaphore privileges.