Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CB09C10F13 for ; Thu, 11 Apr 2019 11:24:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C53442084D for ; Thu, 11 Apr 2019 11:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726588AbfDKLY3 (ORCPT ); Thu, 11 Apr 2019 07:24:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50930 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726517AbfDKLY3 (ORCPT ); Thu, 11 Apr 2019 07:24:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6197E30832CD for ; Thu, 11 Apr 2019 11:24:28 +0000 (UTC) Received: from [10.43.12.151] (unknown [10.43.12.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id B19C8605AF; Thu, 11 Apr 2019 11:24:27 +0000 (UTC) Subject: Re: [PATCH] Label /sys/kernel/ns_last_pid as sysctl_kernel_ns_last_pid_t References: <20190410151832.8189-1-lvrabec@redhat.com> Cc: Lukas Vrabec To: selinux-refpolicy@vger.kernel.org From: Lukas Vrabec Openpgp: preference=signencrypt Autocrypt: addr=lvrabec@redhat.com; keydata= mQINBFqX9fsBEACvMZuLfMn8Fj1XFIir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56VvgT/fzC3tNtl/fB4+8Cc0iKXi9 pRGKTEQOfbhxTSogbm4GD4rPs9q4v3CQT3czjSyhrL4uboYGUf82UjQ2ae+XLclDnaUnYfjp VrregsW12c5KPN0uuc3Fepvn0G4eQfNhwqqGA9zZqCVJMkDjABEBAAGJAjYEGAEIACAWIQTH h3QCUBS0Ag7mUIaM2mOtYz9pVQUCWpf3CwIbDAAKCRCM2mOtYz9pVYeoD/sH++dZ8QLMb3JN QiW6mEIKoEmZH5FrOP7t7UWuUmpAlTcUJ87n1221pLcdr/56uFBRIdvpp0YC5rB9ACaqD6gx oiNQmR0MkLzN25GWSeD8+bs2thO2SZecO0r+/dAvwgnU3rs+LdVqLcUGPfFwebRH94ZQiPjg Y/Ci6LkV6CNDP/rg9odtfYQnL5EHs9yWZdi5f/kLewdrYOAen+i5Sw0oZOiM6tSNOTt59yd3 LPi6NKDb3rVnul7UU9KkvV7NxZykvs+hyYmUbwnS5UAvFyC40B/dgK9uYongPlzVb4MQmaB0 rimSlHMMsHRBMnPxNr/F9kpFkYnbIqQwAYIf3FoQ0QuwCn3YljTEJYdbMM3ivl5woclVI6M1 JytwpFGq6VX3sRhctk+Xe3JOk8Rxt6cvjKeoSmaaxg+kVt4a50LYysh0n3VoETg8d1Gq9NnW fhEFtJ0rNy01aZLO28gyDy4sSJiudkSFo17UtabrhcP/hv5ocvaGSzTfXEyYaw4Su23A0RC8 ska1wAtlZpTYmZ6Mumw2vAkc6bOeh7npcrAfduWSaXtHrUxjuxy6sVCl58IOo2+2AMJaFdMq ktne5U1i8Lrrt8r507w4sBasTReQXL5i/AhqOnHt+FkhpVT5J1sE79VM5gwszP3AvBqOREcS fhCmGay+X9lHV3XhGE8GWA== Organization: Red Hat, Inc. Message-ID: Date: Thu, 11 Apr 2019 13:24:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190410151832.8189-1-lvrabec@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Lirv8hMJKklLdnoqmylKUrb4yLsPZflGB" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 11 Apr 2019 11:24:28 +0000 (UTC) Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Lirv8hMJKklLdnoqmylKUrb4yLsPZflGB Content-Type: multipart/mixed; boundary="WgaxlImsPUx4iAvRtCrjxY16dOOAk275c"; protected-headers="v1" From: Lukas Vrabec To: selinux-refpolicy@vger.kernel.org Cc: Lukas Vrabec Message-ID: Subject: Re: [PATCH] Label /sys/kernel/ns_last_pid as sysctl_kernel_ns_last_pid_t References: <20190410151832.8189-1-lvrabec@redhat.com> In-Reply-To: <20190410151832.8189-1-lvrabec@redhat.com> --WgaxlImsPUx4iAvRtCrjxY16dOOAk275c Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 4/10/19 5:18 PM, Lukas Vrabec wrote: > CRIU can influence the PID of the threads it wants to create. > CRIU uses /proc/sys/kernel/ns_last_pidto tell the kernel which > PID it wants for the next clone(). > So it has to write to that file. This feels like a problematic as > it opens up the container writing to all sysctl_kernel_t. >=20 > Using new label container_t will just write to > sysctl_kernel_ns_last_pid_t instad writing to more generic > sysctl_kernel_t files. > --- > policy/modules/kernel/kernel.if | 60 +++++++++++++++++++++++++++++++++= > policy/modules/kernel/kernel.te | 6 ++++ > 2 files changed, 66 insertions(+) >=20 > diff --git a/policy/modules/kernel/kernel.if b/policy/modules/kernel/ke= rnel.if > index 1ad282aa..3f0a2dbe 100644 > --- a/policy/modules/kernel/kernel.if > +++ b/policy/modules/kernel/kernel.if > @@ -2150,6 +2150,66 @@ interface(`kernel_mounton_kernel_sysctl_files',`= > allow $1 sysctl_kernel_t:file { getattr mounton }; > ') > =20 > +######################################## > +## > +## Read kernel ns lastpid sysctls. > +## > +## > +## > +## Domain allowed access. > +## > +## > +## > +# > +interface(`kernel_read_kernel_ns_lastpid_sysctls',` > + gen_require(` > + type proc_t, sysctl_t, sysctl_kernel_ns_last_pid_t; > + ') > + > + read_files_pattern($1, { proc_t sysctl_t sysctl_kernel_ns_last_pid_t = }, sysctl_kernel_ns_last_pid_t) > + > + list_dirs_pattern($1, { proc_t sysctl_t }, sysctl_kernel_ns_last_pid_= t) > +') > + > +######################################## > +## > +## Do not audit attempts to write kernel ns lastpid sysctls. > +## > +## > +## > +## Domain to not audit. > +## > +## > +# > +interface(`kernel_dontaudit_write_kernel_ns_lastpid_sysctl',` > + gen_require(` > + type sysctl_kernel_ns_last_pid_t; > + ') > + > + dontaudit $1 sysctl_kernel_ns_last_pid_t:file write; > +') > + > +######################################## > +## > +## Read and write kernel ns lastpid sysctls. > +## > +## > +## > +## Domain allowed access. > +## > +## > +## > +# > +interface(`kernel_rw_kernel_ns_lastpid_sysctl',` > + gen_require(` > + type proc_t, sysctl_t, sysctl_kernel_ns_last_pid_t; > + ') > + > + rw_files_pattern($1, { proc_t sysctl_t sysctl_kernel_ns_last_pid_t },= sysctl_kernel_ns_last_pid_t) > + > + list_dirs_pattern($1, { proc_t sysctl_t }, sysctl_kernel_ns_last_pid_= t) > +') > + > ######################################## > ## > ## Search filesystem sysctl directories. > diff --git a/policy/modules/kernel/kernel.te b/policy/modules/kernel/ke= rnel.te > index 8e958074..f9486216 100644 > --- a/policy/modules/kernel/kernel.te > +++ b/policy/modules/kernel/kernel.te > @@ -132,6 +132,10 @@ genfscon proc /sys/fs gen_context(system_u:object_= r:sysctl_fs_t,s0) > type sysctl_kernel_t, sysctl_type; > genfscon proc /sys/kernel gen_context(system_u:object_r:sysctl_kernel_= t,s0) > =20 > +# /sys/kernel/ns_last_pid file > +type sysctl_kernel_ns_last_pid_t, sysctl_type; > +genfscon proc /sys/kernel/ns_last_pid gen_context(system_u:object_r:sy= sctl_kernel_ns_last_pid_t,s0) > + > # /proc/sys/kernel/modprobe file > type sysctl_modprobe_t, sysctl_type; > genfscon proc /sys/kernel/modprobe gen_context(system_u:object_r:sysct= l_modprobe_t,s0) > @@ -232,6 +236,8 @@ allow kernel_t sysctl_kernel_t:dir list_dir_perms; > allow kernel_t sysctl_kernel_t:file read_file_perms; > allow kernel_t sysctl_t:dir list_dir_perms; > =20 > +allow kernel_t sysctl_kernel_ns_last_pid_t:file read_file_perms; > + > # Other possible mount points for the root fs are in files > allow kernel_t unlabeled_t:dir mounton; > # Kernel-generated traffic e.g., TCP resets on >=20 Patch is related to this story: https://lisas.de/~adrian/posts/2019-Apr-10-criu-and-selinux.html Thanks, Lukas. --=20 Lukas Vrabec Senior Software Engineer, Security Technologies Red Hat, Inc. --WgaxlImsPUx4iAvRtCrjxY16dOOAk275c-- --Lirv8hMJKklLdnoqmylKUrb4yLsPZflGB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE3wrP3ArXoyYgAS7LRyAaxC8pzgYFAlyvI+oACgkQRyAaxC8p zgb96Af/VB2gNzP2UncE6SulmSFusf56ADWsAnsoEvL4eIFEC/UXv3v9uISRu845 P3R2s4kyygamqGORm4WUuEIjRHIR00vvquBbERvCOfONB/S5tzEpIH3f6vYxC+Dq xLgiwpXreJKDwgaKJ8uzHbkWufXf26pseZePAPfDgJWax3p6u5yICeQejp4G9VGP dQZJT1Bs4HMR+7NImYwsUxXZyzg48L0CCZ3eOR+MB/2aWdEtadQ5MErCkIhM2oia bXGvbNfIb8/2NXKrVyr9L+UxmQ/8pcc6uuw6UqXt/4jKDBIJEXVJTkKvoR7vR03/ MYYb7U6dNHxqC2tgIGnu8BLsfGuy7A== =ukea -----END PGP SIGNATURE----- --Lirv8hMJKklLdnoqmylKUrb4yLsPZflGB--