From nobody Tue Dec 14 22:02:17 2021 X-Original-To: dev-commits-src-all@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 E171618ED848; Tue, 14 Dec 2021 22:02:17 +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 4JDC614Y2cz4RTc; Tue, 14 Dec 2021 22:02:17 +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 732D410854; Tue, 14 Dec 2021 22:02:17 +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 1BEM2HPa023787; Tue, 14 Dec 2021 22:02:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BEM2Hkk023786; Tue, 14 Dec 2021 22:02:17 GMT (envelope-from git) Date: Tue, 14 Dec 2021 22:02:17 GMT Message-Id: <202112142202.1BEM2Hkk023786@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: e28767f0e175 - main - Thread creation privilege for realtime group List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: e28767f0e17550d8ed030cff0918202e5de101ab Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639519337; 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=u0bywE+QoYWiqjLDMA7ivQVC4hN7R5Ke/PhOYDSoa1M=; b=vLp3aCTpSYVo68lFSYudwZczUTheWPwq20DpaYUnII+ZlYSYMW3T/L0xmm8uipuKgzvT9B uD+WWDeRwy4ylV0npXqXlPIOEnCJENpdA4Z8iStWWsxutJRCytOFpNcI8M8DpQyqsi7F2b 8xxemLGNbfKAWQryMT/e2vLDnAAuHK3wwmbjXe38i2iLnMZ6u/WrLkDjcTR/QCrJGp7CQM C2BNA1WUTbipPLBJzFwFO7s3Lyxch499OEqX5Uq0W2x4O9Wq4VO6Pgpkfokl3rudET43+N r37G86njOrzcCdXJS4if9Jw4jl9U2tI4xME6QyAN7k1wF9sEBtGnCunXrD9gag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639519337; a=rsa-sha256; cv=none; b=aM7gEwKMf0/3EeYYmuJxeujvRg5jrckTCVfWM26I95ptu6XlxYJNN7KlnKor6uSCQj1vhj wmLBnYWzK3CNtkQsvtxgqfqmoPwxUkPxCUSxlgf55Y53/C7udSqiMRVFZHpADPitQhzKRq pAqhwzPOPAVelbVdoMyZ8RSZb3OBfTUivOd+SwdZbfncDy4RkoO0OVJow/ru6aUGuvj188 H3a8MnsbA2GXqEE168KGfQkY23JdZcB+qXOFb3HvYzh0KgNF7vJNDXVPY6dBw/mw1fUto+ Ie1HisvivrI1MozTCglQlnQPEkO2DZeHTGR6NjKHz0MhLtEdWkwua5bRFmprBA== 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=e28767f0e17550d8ed030cff0918202e5de101ab commit e28767f0e17550d8ed030cff0918202e5de101ab Author: Florian Walpen AuthorDate: 2021-12-14 21:55:51 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-14 22:01:58 +0000 Thread creation privilege for realtime group With the mac_priority(4) realtime policy active, users and processes in the realtime group may promote existing threads and processes to realtime scheduling priority. Extend the privileges granted to PRIV_SCHED_SETPOLICY which allows explicit creation of new realtime threads. One use case of this is when the pthread scheduling policy is set to SCHED_RR or SCHED_FIFO via pthread_attr_setschedpolicy(...) before calling pthread_create(...). I ran into this when testing audio software with realtime threads, particularly audio/ardour6. MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33393 --- share/man/man4/mac_priority.4 | 15 +++++++++------ sys/security/mac_priority/mac_priority.c | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/share/man/man4/mac_priority.4 b/share/man/man4/mac_priority.4 index 6dfb937d1596..868d027d5233 100644 --- a/share/man/man4/mac_priority.4 +++ b/share/man/man4/mac_priority.4 @@ -21,7 +21,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 7, 2021 +.Dd December 14, 2021 .Dt MAC_PRIORITY 4 .Os .Sh NAME @@ -79,13 +79,16 @@ priority through the .Xr rtprio 2 system calls. .Ss Privileges Granted -The kernel privileges granted to any process running -with the corresponding group gid is: -.Bl -tag -width ".Dv PRIV_SCHED_RTPRIO" -offset indent +The realtime policy grants the following kernel privileges to any process +running with the realtime group id: +.Bl -inset -offset indent -compact .It Dv PRIV_SCHED_RTPRIO -If it is a member of the realtime group. +.It Dv PRIV_SCHED_SETPOLICY +.El +.Pp +The kernel privilege granted by the idletime policy is: +.Bl -inset -offset indent -compact .It Dv PRIV_SCHED_IDPRIO -If it is a member of the idletime group. .El .Ss Runtime Configuration The following diff --git a/sys/security/mac_priority/mac_priority.c b/sys/security/mac_priority/mac_priority.c index 5c4db72ca657..f460e5195cb9 100644 --- a/sys/security/mac_priority/mac_priority.c +++ b/sys/security/mac_priority/mac_priority.c @@ -64,8 +64,8 @@ SYSCTL_INT(_security_mac_priority, OID_AUTO, idletime_gid, CTLFLAG_RWTUN, static int priority_priv_grant(struct ucred *cred, int priv) { - if (priv == PRIV_SCHED_RTPRIO && realtime_enabled && - groupmember(realtime_gid, cred)) + if ((priv == PRIV_SCHED_RTPRIO || priv == PRIV_SCHED_SETPOLICY) && + realtime_enabled && groupmember(realtime_gid, cred)) return (0); if (priv == PRIV_SCHED_IDPRIO && idletime_enabled &&