Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp718553pxb; Tue, 2 Feb 2021 16:35:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUnprfCu2ST0gTZBfhiWDecGW+1TPnsMtWtf7bXexAIY6B4L5T56hoEIV3/Zk+nA4CWKld X-Received: by 2002:a17:906:24ca:: with SMTP id f10mr577555ejb.96.1612312518777; Tue, 02 Feb 2021 16:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612312518; cv=none; d=google.com; s=arc-20160816; b=MKZ8uAHHzt12gb6M5UhdqylK88MyYzZ2hqprpOT5txlg3wrjWkvvvw17847h1DbARo 9GMg0NmcuALmGnNc3jL3CEHR+1mPgN73NggdaSMcRmSAA/ghLGY6foMx16w9hJNKD2z5 SLjK1SwH6US+KZ+Exu57A30MBKqRnmGis4T6js653iXsnZIwG/GmKX33d5wthsceFtq8 UmPHQn3sDwwP7xEx30hKTASnaTg5IUXoma/s8ob/VPOcit4VFPVpDPlmjPAG2pi/B21a 1f7wYdUvxgrB9PVK+RN/wftMzIjQ0dFZdzKQvpXYWnN9O2fJkDpc0bNOqxrVAb86wBnG sfWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=j8x44LpoTFfUH4HOzyDNCNzfG3hSJ0gj9lo3px1hSNo=; b=FpIUtCoclMbxTWCGaLORGXVusMKTH9aYbM5J2jBYyBtSTON1CqrhgkfXSKcq+14Cs/ nDsPcN39fKKq3CnRGN8PlZqRulcyaD5CJ6qyakmKhKCOT8pqzjWxksBP9uiXhwL9Wxv6 USgl6Iyhx/gjoa2qlAX0tEVlVEOIFuv7+L+D5FMytdUkfQCYvLt9zo6g9qB1T1EflLJU b6+fzVDggJVmuyFAydwPclnfPSPVdR6XMPIi2XDveE2mGXAho51VTqVWftaRMw4ovUET PdYZ27/J/hY/DxfkYUtMIZjBt4/oO6jGqsOVvqjuKJV9aSWyh+sl7QcKGMwH8nAi2b0m QNww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=SOG3MkzI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si211074edr.526.2021.02.02.16.34.54; Tue, 02 Feb 2021 16:35:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=SOG3MkzI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238213AbhBBSLQ (ORCPT + 99 others); Tue, 2 Feb 2021 13:11:16 -0500 Received: from sonic307-15.consmr.mail.ne1.yahoo.com ([66.163.190.38]:36164 "EHLO sonic307-15.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238164AbhBBSHY (ORCPT ); Tue, 2 Feb 2021 13:07:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1612289198; bh=j8x44LpoTFfUH4HOzyDNCNzfG3hSJ0gj9lo3px1hSNo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject:Reply-To; b=SOG3MkzI/xo4NHO773dKiJqmfifbW10ppO5VX0RDiEtsVo2tYzrW3vQKUAVMkNA5lIvQREOwdvy1OoVIqnmQ0shXGFSE4BsxQgpHUkyVipBSy4igv7D8oUF4p3OO1/Etx7BlLAOPJ+A3624Hh2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xu9.9V9EenNj.tivumCMgqfMUPJ636f3gkjgAPmk98n5M.ua jfzXHF0iqp.t4ofq5pZmC_KeX7sbyyT35T9TjbY8NATMATTDU6cd5_.S4zjnPMo43eHkzgqdWzoa ZTkosvZBlpSkphV85dNzTWWFgEknX4LxwkIX1z.J_bCuGCR1JQDdPlA4D7.txzjPXbpYKBzD.JDA DwiVDKBbn2yTKSceYA9G8MK8ZxWbuNVaUHvIz8ifMC9KXdp6xwIwJzRWdibAIT2UlV3wTB112dvu LNJ_5ujqKyV2XXt6BtQIxnYOC2tBUphLOtjQByV.YuerFhDMzaXVEx.gjSZzu8xcQxVV44mIhsaS llYDdFU23ZsOTW.jMScmIq785tWfY3mmzkpLJHX4F5mwghNMYajtBMjrd6j0Ur_g5BiSkiLZopS8 g7sdRxILm26sj84ClbjAZyPqZ.ieVOC0WGTDLuG9CjHmThjrTngkoCRzv.0_i9GrrVliKxCdEG66 mwoSUFWYMVMIqe.3ByGHgIFns6NPSQq_znXT8f32_uLhVZQnrQ_KzySATQjWQ6JdKW5BZ7addHb2 1IAsvzcrts2hpujDumdU1DYPzfkE6JTeJwsMXEe3D2bxClHKK7XjGAA2oMcuzZJQ- Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ne1.yahoo.com with HTTP; Tue, 2 Feb 2021 18:06:38 +0000 Received: by smtp415.mail.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 2e19b6b38051dbf5ab33afec7d37668e; Tue, 02 Feb 2021 18:06:31 +0000 (UTC) Subject: Re: [PATCH v24 00/25] LSM: Module stacking for AppArmor To: Topi Miettinen , casey.schaufler@intel.com, jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Cc: linux-audit@redhat.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com, sds@tycho.nsa.gov, linux-kernel@vger.kernel.org, Casey Schaufler References: <20210126164108.1958-1-casey.ref@schaufler-ca.com> <20210126164108.1958-1-casey@schaufler-ca.com> <31ba0fe7-afdf-8f7d-e7a7-8f15d8c690a4@gmail.com> From: Casey Schaufler Message-ID: <3ac446c9-1af7-04dd-561d-6ec1dbb146b9@schaufler-ca.com> Date: Tue, 2 Feb 2021 10:06:29 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Mailer: WebService/1.1.17648 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.8) Content-Length: 7178 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/2/2021 9:12 AM, Topi Miettinen wrote: > On 2.2.2021 17.30, Casey Schaufler wrote: >> On 2/2/2021 4:05 AM, Topi Miettinen wrote: >>> On 26.1.2021 18.40, Casey Schaufler wrote: >>>> This patchset provides the changes required for >>>> the AppArmor security module to stack safely with any other. >>> >>> In my test, when kernel command line has apparmor before selinux in l= sm=3D entry, the boot is not successful with enforcing=3D1: >>> systemd[1]: Failed to compute init label, ignoring. >>> systemd[1]: Failed to set SELinux security context system_u:object_r:= cgroup_t:s0 for /sys/fs/cgroup: Invalid argument >>> systemd[1]: Failed to set SELinux security context system_u:object_r:= pstore_t:s0 for /sys/fs/pstore: Invalid argument >>> systemd[1]: Failed to set SELinux security context system_u:object_r:= sysfs_t:s0 for /sys/firmware/efi/efivars: Invalid argument >>> ... >>> Failed to drop capability bounding set of usermode helpers: Operation= not permitted >>> Failed to drop capability bounding set of usermode helpers. >>> systemd[1]: Freezing execution. >> >> Systemd has extensive support for SELinux. That's good. >> It doesn't have an understanding of what needs to be done >> if SELinux is active but not the default security module >> for interfaces including SO_PEERSEC and /proc/*/attr/*. >> That's going to take some work. > > Ok. What will be the replacement for SO_PEERSEC? Systemd calls getsocko= pt(fd, SOL_SOCKET, SO_PEERSEC, s, &n). Dealing with SO_PEERSEC has been discussed at length, and I wouldn't say that anyone is really happy with the conclusions. The patch set presented uses the interface_lsm to determine which module's data is presented in SO_PEERSEC. The interface_lsm is controlled by writing the desired security module name to /proc/self/attr/interface_lsm. The addition of SO_PEERCONTEXT, which would contain all active security module data, has been proposed as a follow-on but is not included in this patch set. > > Is the /proc part something that should be fixed on systemd side, or ca= n perhaps the SELinux libraries hide this from applications? It's unfortunate that the early days of the LSM where dominated by the mindset that security had to be a complete solution. I was in that camp myself for a good long time, but came to recognize that attempting to solve all security problems for everyone using one mechanism was destined to excess. Because user-space development has assumed a single LSM for so long it's hard to imagine that there won't need to be changes in both the libraries and the programs. Because SELinux has the longest history and most complete distribution integration it will also have the most trouble with sharing the LSM stack.=20 > >> >>> >>> Probably SELinux libraries can't find or set the labels for the PID1 = or any file systems. Before the init label message, systemd calls getcon_= raw(), getfilecon_raw(), string_to_security_class() and security_compute_= create_raw(), so one of these don't understand the LSM stacking. >> >> That is correct. >> >>> >>> Also the policy needs updating to handle process2:setdisplay: >>> SELinux:=C2=A0 Permission setdisplay in class process2 not defined in= policy. >>> SELinux: the above unknown classes and permissions will be denied >>> >>> With enforcing=3D0, many services start, but for example systemd-jour= nald doesn't. This is probably related to the earlier problem with labels= (maybe libraries try to use SELinux labels where kernel wants AppArmor p= rofiles): >>> systemd[1]: Failed to set SELinux security context system_u:object_r:= init_runtime_t:s0 for /run/systemd/units/invocation:systemd-user-sessions= =2Eservice: Invalid argument >> >> This is also an artifact of systemd seeing AppArmor information >> instead of SELinux contexts. > > Will SELinux libraries choose automatically the correct way to set labe= ls in the future? I expect so eventually. The SELinux developers have not been especially enthusiastic about the prospect of module stacking. Once it is available I expect to see some accommodation, but not necessarily to the level you might like. The patch set here is strongly influenced by the assumption that putting the most highly integrated module first (SELinux on Fedora, AppArmor on Ubuntu, Smack on Tizen, ...) is going to get you most of what you need. Whoever wants to add Smack to Ubuntu is going to have some work to do. Stacking AppArmor with SELinux is a real use case in the container world, but that's not the real focus of this effort. I have seen several cases where security features have not been implemented because they couldn't be added to a system that also required SELinux, AppArmor or Smack. I have seen many proposals for changes to existing security modules that where outside their scope just because there was no other way. > >>> >>> Switching the order so that apparmor is after selinux, boot is succes= sful. Loading AppArmor profiles needs a permission from SELinux: >>> >>> Feb 02 08:53:15 audit[963]: AVC avc:=C2=A0 denied=C2=A0 { mac_admin }= for=C2=A0 pid=3D963 comm=3D"apparmor_parser" capability=3D33 scontext=3D= system_u:system_r:initrc_t:s0 tcontext=3Dsystem_u:system_r:initrc_t:s0 tc= lass=3Dcapability2 permissive=3D0 >>> Feb 02 08:53:15 audit[963]: AVC apparmor=3D"STATUS" operation=3D"prof= ile_replace" info=3D"not policy admin" error=3D-13 profile=3D"unconfined"= pid=3D963 comm=3D"apparmor_parser" >>> Feb 02 08:53:15 audit: AUDIT1420 subj_selinux=3Dsystem_u:system_r:ini= trc_t:s0 subj_apparmor=3D=3Dunconfined >>> Feb 02 08:53:15 audit[963]: SYSCALL arch=3Dc000003e syscall=3D1 succe= ss=3Dno exit=3D-13 a0=3D7 a1=3D7a8f2ff04f80 a2=3D1e09 a3=3D0 items=3D0 pp= id=3D961 pid=3D963 auid=3D4294967295 uid=3D0 gid=3D0 euid=3D0 suid=3D0 fs= uid=3D0 egid=3D0 sgid=3D0 fsgid=3D0 tty=3D(none) ses=3D4294967295 comm=3D= "apparmor_parser" exe=3D"/usr/sbin/apparmor_parser" subj=3D? key=3D(null)= >>> Feb 02 08:53:15 audit: PROCTITLE proctitle=3D2F7362696E2F61707061726D= 6F725F706172736572002D2D77726974652D6361636865002D2D7265706C616365002D2D0= 02F6574632F61707061726D6F722E64 >>> Feb 02 08:53:15 apparmor.systemd[963]: /sbin/apparmor_parser: Unable = to replace "/lib/systemd/systemd-resolved".=C2=A0 Permission denied; atte= mpted to load a profile while confined? >>> >>> This just seems to need TE rules for the apparmor_parser. >>> >>> Double equal sign in subj_apparmor=3D=3Dunconfined looks odd, should = that be just one like subj_selinux? >> >> The audit code is reporting what AppArmor provides. >> I agree that this looks odd. >> >>> >>> >>> Tools like ps, and KDE and Gnome System Monitors only show SELinux co= ntext, but it would be nice if MAC contexts for all enabled LSMs were sho= wn. >> >> I agree. How this should be done has been a topic of >> lively debate for some time. >> >>> >>> -Topi >> >> Thank you for this report. Which distribution are you using? >> I have been testing with Fedora (SELinux + AppArmor) and Ubuntu >> (AppArmor + Smack). I would be very interested to see how a >> distribution that doesn't use systemd behaves. > > This is Debian with systemd, I'm using SELinux + TOMOYO + AppArmor. Great to hear. Thanks again.