From nobody Sun Dec 19 02:44:35 2021 X-Original-To: dev-commits-src-branches@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 84D2E18E4D49; Sun, 19 Dec 2021 02:44:38 +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 4JGn9w2pqBz4qjb; Sun, 19 Dec 2021 02:44:36 +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 17BFF1A6F8; Sun, 19 Dec 2021 02:44:36 +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 1BJ2iZWG012764; Sun, 19 Dec 2021 02:44:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BJ2iZC0012763; Sun, 19 Dec 2021 02:44:35 GMT (envelope-from git) Date: Sun, 19 Dec 2021 02:44:35 GMT Message-Id: <202112190244.1BJ2iZC0012763@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 5719dba7652d - stable/13 - Add PRIV_SCHED_IDPRIO List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 5719dba7652daa1a6d529f38b7569037e9480128 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639881876; 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=YG1czytm5mzI8gpkKVin+NKdIuzkb9IQ6zcHuDVMKTY=; b=cqlJqO/94K4AWn2lHR4m2u05z3uCuFsLYsLeU3uM+OGSWFpQb161arezrl8hFUDuR6Aa2y P9IX3q2lNe0eEezIM+yVS4AqvvC08NI5dBsIew5fdinMMBYnaonCqQHYImDHFvI8nNgRQ5 UmMZ0gWaqElaoUqJaEvgHjYMXpzz3NThd0ML1G43V3caoKimo9q8nT+u8jraCB0UYHyoOi hnA0S9nqu33NxnvSE+5BndHmzuSfAUTgvzooD4A53nJc2P/TkgDz+F2FgtlMH3JtkMc01S 96bmeOGGWk23l1TR4mMp81toaV+LbFzXYr4TymV90+EyrEa8jTvI95XuYxT2uw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639881876; a=rsa-sha256; cv=none; b=Uo49PbyeCRkGjtAkwvEqlwxxbOfohAvx0ehDGNA66DQ1FGCPqVRQpk/Cwa/seMExZHp+9T ksGI1FOj5EMNnoxo7Q1ySd+vlFLz+Z3RiAgh0SKzjUYy7qPIymPNhedNVxBkt+ALl9pWR9 DqzzmJR6XaTjR8wdUBrZmGN0dNTn4bqD3tt8vM07nYaLMNdYFFb0t3M5aVnLgBrf6+J2P0 xxiZ/ACpvojtQIZupcl3NW9o+M5Bd6oyGULCjp7cSkrsALV35zqASZtYfUpkp0aV4JMVEl HeFv98QhRrltITQJnVYweTox0nUGKOapy49HvHVz0znc94gtHulJnw9ia2Z21w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5719dba7652daa1a6d529f38b7569037e9480128 commit 5719dba7652daa1a6d529f38b7569037e9480128 Author: Florian Walpen AuthorDate: 2021-12-10 01:43:12 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-19 02:42:51 +0000 Add PRIV_SCHED_IDPRIO (cherry picked from commit a20a2450cd5f38fb28d5fa5540177edfb60d2473) --- 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 e14be34aa6e0..1cb6cc2a36fd 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.