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 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 EC77DC10F11 for ; Wed, 10 Apr 2019 15:16:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B499C20854 for ; Wed, 10 Apr 2019 15:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733075AbfDJPQ6 (ORCPT ); Wed, 10 Apr 2019 11:16:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44562 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732928AbfDJPQ6 (ORCPT ); Wed, 10 Apr 2019 11:16:58 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB5FCC04FFFA; Wed, 10 Apr 2019 15:16:56 +0000 (UTC) Received: from [10.43.12.151] (unknown [10.43.12.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F3A05D719; Wed, 10 Apr 2019 15:16:55 +0000 (UTC) Subject: Re: [PATCH] Label /sys/kernel/ns_last_pid as sysctl_kernel_ns_last_pid_t To: Chris PeBenito , selinux-refpolicy@vger.kernel.org References: <20190408161907.10322-1-lvrabec@redhat.com> <42a81b2d-115e-4202-832d-190ae1da46e6@ieee.org> From: Lukas Vrabec Openpgp: preference=signencrypt Autocrypt: addr=lvrabec@redhat.com; keydata= mQINBFqX9fs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wqX5RbfoOl8+2I5q+C06r56VvgT/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: <718a3c7b-680f-0fa6-2bf2-7139148d880f@redhat.com> Date: Wed, 10 Apr 2019 17:16:55 +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: <42a81b2d-115e-4202-832d-190ae1da46e6@ieee.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0ZEAZSzllifgbK0vljDcZ9vNvqXfGb6B3" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 10 Apr 2019 15:16:56 +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) --0ZEAZSzllifgbK0vljDcZ9vNvqXfGb6B3 Content-Type: multipart/mixed; boundary="eMafgvv1Bothdn8YMpykwmlQK2ohQIlfi"; protected-headers="v1" From: Lukas Vrabec To: Chris PeBenito , selinux-refpolicy@vger.kernel.org Message-ID: <718a3c7b-680f-0fa6-2bf2-7139148d880f@redhat.com> Subject: Re: [PATCH] Label /sys/kernel/ns_last_pid as sysctl_kernel_ns_last_pid_t References: <20190408161907.10322-1-lvrabec@redhat.com> <42a81b2d-115e-4202-832d-190ae1da46e6@ieee.org> In-Reply-To: <42a81b2d-115e-4202-832d-190ae1da46e6@ieee.org> --eMafgvv1Bothdn8YMpykwmlQK2ohQIlfi Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 4/9/19 1:54 PM, Chris PeBenito wrote: > On 4/8/19 12:19 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. >> >> Using new label container_t will just write to >> sysctl_kernel_ns_last_pid_t instad writing to more generic >> sysctl_kernel_t files. >> --- >> =C2=A0 policy/modules/kernel/kernel.if | 60 ++++++++++++++++++++++++++= +++++++ >> =C2=A0 policy/modules/kernel/kernel.te |=C2=A0 7 ++++ >> =C2=A0 2 files changed, 67 insertions(+) >> >> diff --git a/policy/modules/kernel/kernel.if >> b/policy/modules/kernel/kernel.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',= ` >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 allow $1 sysctl_kernel_t:file { getattr= mounton }; >> =C2=A0 ') >> =C2=A0 +######################################## >> +## >> +##=C2=A0=C2=A0=C2=A0 Read kernel ns lastpid sysctls. >> +## >> +## >> +##=C2=A0=C2=A0=C2=A0 >> +##=C2=A0=C2=A0=C2=A0 Domain allowed access. >> +##=C2=A0=C2=A0=C2=A0 >> +## >> +## >> +# >> +interface(`kernel_read_kernel_ns_lastpid_sysctls',` >> +=C2=A0=C2=A0=C2=A0 gen_require(` >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 type proc_t, sysctl_t, sys= ctl_kernel_ns_last_pid_t; >> +=C2=A0=C2=A0=C2=A0 ') >> + >> +=C2=A0=C2=A0=C2=A0 read_files_pattern($1, { proc_t sysctl_t >> sysctl_kernel_ns_last_pid_t }, sysctl_kernel_ns_last_pid_t) >> + >> +=C2=A0=C2=A0=C2=A0 list_dirs_pattern($1, { proc_t sysctl_t }, >> sysctl_kernel_ns_last_pid_t) >> +') >> + >> +######################################## >> +## >> +##=C2=A0=C2=A0=C2=A0 Do not audit attempts to write kernel ns lastpid= sysctls. >> +## >> +## >> +##=C2=A0=C2=A0=C2=A0 >> +##=C2=A0=C2=A0=C2=A0 Domain to not audit. >> +##=C2=A0=C2=A0=C2=A0 >> +## >> +# >> +interface(`kernel_dontaudit_write_kernel_ns_lastpid_sysctl',` >> +=C2=A0=C2=A0=C2=A0 gen_require(` >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 type sysctl_kernel_ns_last= _pid_t; >> +=C2=A0=C2=A0=C2=A0 ') >> + >> +=C2=A0=C2=A0=C2=A0 dontaudit $1 sysctl_kernel_ns_last_pid_t:file writ= e; >> +') >> + >> +######################################## >> +## >> +##=C2=A0=C2=A0=C2=A0 Read and write kernel ns lastpid sysctls. >> +## >> +## >> +##=C2=A0=C2=A0=C2=A0 >> +##=C2=A0=C2=A0=C2=A0 Domain allowed access. >> +##=C2=A0=C2=A0=C2=A0 >> +## >> +## >> +# >> +interface(`kernel_rw_kernel_ns_lastpid_sysctl',` >> +=C2=A0=C2=A0=C2=A0 gen_require(` >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 type proc_t, sysctl_t, sys= ctl_kernel_ns_last_pid_t; >> +=C2=A0=C2=A0=C2=A0 ') >> + >> +=C2=A0=C2=A0=C2=A0 rw_files_pattern($1, { proc_t sysctl_t >> sysctl_kernel_ns_last_pid_t }, sysctl_kernel_ns_last_pid_t) >> + >> +=C2=A0=C2=A0=C2=A0 list_dirs_pattern($1, { proc_t sysctl_t }, >> sysctl_kernel_ns_last_pid_t) >> +') >> + >> =C2=A0 ######################################## >> =C2=A0 ## >> =C2=A0 ##=C2=A0=C2=A0=C2=A0 Search filesystem sysctl directories. >> diff --git a/policy/modules/kernel/kernel.te >> b/policy/modules/kernel/kernel.te >> index 8e958074..f5ec1c22 100644 >> --- a/policy/modules/kernel/kernel.te >> +++ b/policy/modules/kernel/kernel.te >> @@ -132,6 +132,11 @@ genfscon proc /sys/fs >> gen_context(system_u:object_r:sysctl_fs_t,s0) >> =C2=A0 type sysctl_kernel_t, sysctl_type; >> =C2=A0 genfscon proc /sys/kernel >> gen_context(system_u:object_r:sysctl_kernel_t,s0) >> =C2=A0 +# /sys/kernel/ns_last_pid file >> +type sysctl_kernel_ns_last_pid_t, sysctl_type; >> +fs_associate(sysctl_kernel_ns_last_pid_t) >=20 > Is this associate really necessary?=C2=A0 It's not used for any other s= ysctls. >=20 You're right, it's not really needed. >> +genfscon proc /sys/kernel/ns_last_pid >> gen_context(system_u:object_r:sysctl_kernel_ns_last_pid_t,s0) >> + >> =C2=A0 # /proc/sys/kernel/modprobe file >> =C2=A0 type sysctl_modprobe_t, sysctl_type; >> =C2=A0 genfscon proc /sys/kernel/modprobe >> gen_context(system_u:object_r:sysctl_modprobe_t,s0) >> @@ -232,6 +237,8 @@ allow kernel_t sysctl_kernel_t:dir list_dir_perms;= >> =C2=A0 allow kernel_t sysctl_kernel_t:file read_file_perms; >> =C2=A0 allow kernel_t sysctl_t:dir list_dir_perms; >> =C2=A0 +allow kernel_t sysctl_kernel_ns_last_pid_t:file read_file_perm= s; >> + >> =C2=A0 # Other possible mount points for the root fs are in files >> =C2=A0 allow kernel_t unlabeled_t:dir mounton; >> =C2=A0 # Kernel-generated traffic e.g., TCP resets on >> >=20 >=20 --=20 Lukas Vrabec Senior Software Engineer, Security Technologies Red Hat, Inc. --eMafgvv1Bothdn8YMpykwmlQK2ohQIlfi-- --0ZEAZSzllifgbK0vljDcZ9vNvqXfGb6B3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE3wrP3ArXoyYgAS7LRyAaxC8pzgYFAlyuCOcACgkQRyAaxC8p zgbffQf7BmR3SYffhJNECAJYJhbpZac5YfHS0BFDi+/4GmHTrQ0t3bdN6EIASXxY FORX9JyFOntgpTGzvDp7aeDYFbjb1NZFKt7bCRXza0xLavChfbEBKgMMuke+RFEf MSmQXh2FiDD6CfxgDWVMfV71JrUNZ9WmmH/3WmszdU14u33ZC6ZuDwkvWDTLUgbk WLwZCyIjp3+wzyJyccoYNFAbvJ5dqdBqcjFhy59lfMM2gOn+miYFktmi3VJFf2Le cIHH83fJCccJgdnEqbYn6OSGo8TEAZHtWJonwN7nx07+P+NPWNSJwnaDI4N5xmle ruC782W5Ic75G9LCiO47itSHcrIm7A== =53BJ -----END PGP SIGNATURE----- --0ZEAZSzllifgbK0vljDcZ9vNvqXfGb6B3--