Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6884174ybi; Wed, 5 Jun 2019 07:52:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqysj4j/70lwiM7JJ74vtgZ5yh6rXOvXSEVSmErJct5B/uRVNcZz2zy/SebNF+uC8AqwtAZd X-Received: by 2002:a17:902:21:: with SMTP id 30mr43800321pla.302.1559746365713; Wed, 05 Jun 2019 07:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559746365; cv=none; d=google.com; s=arc-20160816; b=tgdeRq38/T0VkoCTa6yuBhwoDN4TvZ+p5YC+YgFZgtzkMfbX1Jw7S8Q2lZ4/av4Spo cNj3GFRNvxBndEEBKWEH47Ji3eMIZCGXo+2v0K8O716OWto38jjpWQPrFw2KIbTqMqfD xbgRtep7MOUDD6fOv3u6V/VJ2SRrgpSacO4KeRV41F3Q1INruw6vKN39EnlUIpEMqadi +xiqfG4xRA7hT9fQ7ySGB49VEULqIloYrNJ4vA+luDhG4DhKO7KPIDO7gX1I3Hp39Crf oTOF/ZUW6664rBi7ibTwd+4YBs/I5fI4UFD8ZHu6VWUOlJ75+vmzYjOoHf00qrHt+hgh +SYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=vQ863yDV2wmdCZygtxSI5wsL7fPddox6Fd+/Zoc7GU0=; b=jUefk7iEongfzD+43UmJocuw1In1/mu9USLMgvKUlewNMe02/DT3HuLXhAJONyvgIV Awzc+2AGCm8KBNTJ2h48yMK8I2B+xS2m5GEuBPkfzVKEP4GO2gazXbeboLNGJVV09IPs tmj1j9/xBhHB3kvjH63t/3WgcEseX+PX5YvC9MJN4Ky2QHRdj3PQDNJgUF8EjIX4Wmhw XPRFTlMxPDC+fG6DT7Yi5YdGS/bJyF1UHabVN46Sh6DyWMe+PaYtHaRb1wQzK6cjXr5l wjf91T9deaDHIU36dBPx4Qxt5GUolhP9oFtZumxPfvPFgzmTQggoskaWuma7XrzyCIlj UOcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b="d2f2F7/m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b16si30004510pgk.387.2019.06.05.07.52.26; Wed, 05 Jun 2019 07:52:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b="d2f2F7/m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728483AbfFEOvM (ORCPT + 99 others); Wed, 5 Jun 2019 10:51:12 -0400 Received: from sonic317-38.consmr.mail.ne1.yahoo.com ([66.163.184.49]:44125 "EHLO sonic317-38.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728306AbfFEOvL (ORCPT ); Wed, 5 Jun 2019 10:51:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1559746268; bh=vQ863yDV2wmdCZygtxSI5wsL7fPddox6Fd+/Zoc7GU0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=d2f2F7/mifDiveMDb2TFbH3W+TzBqbAkUxvolGn0V1MCLxwp8he1PGODogV/6qMgT1pBF29GeGoJxXGaFd+jxj4U+tAPcjUJjFgS3t3CUnXSMQOPXe8AdBgspQnWWJrs0b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5kRHe1yxduK2NeoOq37YDeVTus PTIu57S94wwAkEq1ShUXPRMkmc_MiKdPvkR6LzVP_0BNOcJdd1_hDFYw3s56TQ7JYPuLo1BePapF 4oEKK27.94jIqszojw3iStyWNh0V5qT8vxbcSQshccI3uZYc2yCqJUBmWMk3VCMKrpE8Hct7p2bi aVBvvKPEjQmHfXRKmld9Zv1fXAfXer2SZr12efGlo.RqXG2OpHBepOuXMh24KtmalD6JIpYCBy73 Ytyxw.Pie47HXe8gJS4RsymY3Pd48_DJJ2gTSPfZprt60XmmrUs2ON_2bQIq1fbOLC9sWxX3sO9m Bmac24ZB3rZ9v.FUfqAALla0R6jUWWDavdzizQ6ecBFu7CYeVA3ZNv3hCjMm2WmHskg62ZqxU0Cp _xtucNwdkxuTzt9AlYZ.I2zk5bDnbMcVE Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Wed, 5 Jun 2019 14:51:08 +0000 Received: from c-73-223-4-185.hsd1.ca.comcast.net (EHLO [192.168.0.103]) ([73.223.4.185]) by smtp429.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 610f9da3c63d75c55bf190f4c4eb0731; Wed, 05 Jun 2019 14:51:05 +0000 (UTC) Subject: Re: [RFC][PATCH 0/8] Mount, FS, Block and Keyrings notifications [ver #2] To: David Howells Cc: Andy Lutomirski , Al Viro , raven@themaw.net, Linux FS Devel , Linux API , linux-block@vger.kernel.org, keyrings@vger.kernel.org, LSM List , LKML , casey@schaufler-ca.com References: <50c2ea19-6ae8-1f42-97ef-ba5c95e40475@schaufler-ca.com> <155966609977.17449.5624614375035334363.stgit@warthog.procyon.org.uk> <20192.1559724094@warthog.procyon.org.uk> From: Casey Schaufler Openpgp: preference=signencrypt Autocrypt: addr=casey@schaufler-ca.com; keydata= mQINBFzV9HABEAC/mmv3jeJyF7lR7QhILYg1+PeBLIMZv7KCzBSc/4ZZipoWdmr77Lel/RxQ 1PrNx0UaM5r6Hj9lJm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/ij Dxf9HG2o5hOlMIAkJq/uLNMvABEBAAGJAjwEGAEIACYWIQQL720fVjJTAhDNQh44pRV8jEPI EQUCXNX0cAIbDAUJEswDAAAKCRA4pRV8jEPIEWkzEACKFUnpp+wIVHpckMfBqN8BE5dUbWJc GyQ7wXWajLtlPdw1nNw0Wrv+ob2RCT7qQlUo6GRLcvj9Fn5tR4hBvR6D3m8aR0AGHbcC62cq I7LjaSDP5j/em4oVL2SMgNTrXgE2w33JMGjAx9oBzkxmKUqprhJomPwmfDHMJ0t7y39Da724 oLPTkQDpJL1kuraM9TC5NyLe1+MyIxqM/8NujoJbWeQUgGjn9uxQAil7o/xSCjrWCP3kZDID vd5ZaHpdl8e1mTExQoKr4EWgaMjmD/a3hZ/j3KfTVNpM2cLfD/QwTMaC2fkK8ExMsz+rUl1H icmcmpptCwOSgwSpPY1Zfio6HvEJp7gmDwMgozMfwQuT9oxyFTxn1X3rn1IoYQF3P8gsziY5 qtTxy2RrgqQFm/hr8gM78RhP54UPltIE96VywviFzDZehMvuwzW//fxysIoK97Y/KBZZOQs+ /T+Bw80Pwk/dqQ8UmIt2ffHEgwCTbkSm711BejapWCfklxkMZDp16mkxSt2qZovboVjXnfuq wQ1QL4o4t1hviM7LyoflsCLnQFJh6RSBhBpKQinMJl/z0A6NYDkQi6vEGMDBWX/M2vk9Jvwa v0cEBfY3Z5oFgkh7BUORsu1V+Hn0fR/Lqq/Pyq+nTR26WzGDkolLsDr3IH0TiAVH5ZuPxyz6 abzjfg== Message-ID: Date: Wed, 5 Jun 2019 07:50:57 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20192.1559724094@warthog.procyon.org.uk> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nAYbsaLPWvSYgBq1ZgUViHpZIInmpNbp5" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --nAYbsaLPWvSYgBq1ZgUViHpZIInmpNbp5 Content-Type: multipart/mixed; boundary="txkkq0wOFA671eV9SlTrRrBSRAcaZSaKJ"; protected-headers="v1" From: Casey Schaufler To: David Howells Cc: Andy Lutomirski , Al Viro , raven@themaw.net, Linux FS Devel , Linux API , linux-block@vger.kernel.org, keyrings@vger.kernel.org, LSM List , LKML , casey@schaufler-ca.com Message-ID: Subject: Re: [RFC][PATCH 0/8] Mount, FS, Block and Keyrings notifications [ver #2] References: <50c2ea19-6ae8-1f42-97ef-ba5c95e40475@schaufler-ca.com> <155966609977.17449.5624614375035334363.stgit@warthog.procyon.org.uk> <20192.1559724094@warthog.procyon.org.uk> In-Reply-To: <20192.1559724094@warthog.procyon.org.uk> --txkkq0wOFA671eV9SlTrRrBSRAcaZSaKJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US On 6/5/2019 1:41 AM, David Howells wrote: > Casey Schaufler wrote: > >> I will try to explain the problem once again. If process A >> sends a signal (writes information) to process B the kernel >> checks that either process A has the same UID as process B >> or that process A has privilege to override that policy. >> Process B is passive in this access control decision, while >> process A is active. In the event delivery case, process A >> does something (e.g. modifies a keyring) that generates an >> event, which is then sent to process B's event buffer. > I think this might be the core sticking point here. It looks like two > different situations: > > (1) A explicitly sends event to B (eg. signalling, sendmsg, etc.) > > (2) A implicitly and unknowingly sends event to B as a side effect of = some > other action (eg. B has a watch for the event A did). > > The LSM treats them as the same: that is B must have MAC authorisation = to send > a message to A. YES! Threat is about what you can do, not what you intend to do. And it would be really great if you put some thought into what a rational model would be for UID based controls, too. > But there are problems with not sending the event: > > (1) B's internal state is then corrupt (or, at least, unknowingly inva= lid). Then B is a badly written program. > (2) B can potentially figure out that the event happened by other mean= s. Then why does it need the event mechanism in the first place? > I've implemented four event sources so far: > > (1) Keys/keyrings. You can only get events on a key you have View per= mission > on and the other process has to have write access to it, so I thin= k this > is good enough. Sounds fine. > (2) Block layer. Currently this will only get you hardware error even= ts, > which is probably safe. I'm not sure you can manipulate those wit= hout > permission to directly access the device files. There's an argument to be made that this should require CAP_SYS_ADMIN, or that an LSM like SELinux might include hardware error events in policy, but generally I agree that system generated events like this are both harmless and pointless for the general public to watch. > (3) Superblock. This is trickier since it can see events that can be > manufactured (R/W <-> R/O remounting, EDQUOT) as well as events th= at > can't without hardware control (EIO, network link loss, RF kill). The events generated by processes (the 1st set) need controls like keys. The events generated by the system (the 2nd set) may need controls like the block layer. > (4) Mount topology. This is the trickiest since it allows you to see = events > beyond the point at which you placed your watch (in essence, you p= lace a > subtree watch). Like keys. > The question is what permission checking should I do? Ideally, I'= d > emulate a pathwalk between the watchpoint and the eventing object = to see > if the owner of the watchpoint could reach it. That will depend, as I've been saying, on what causes the event to be generated. If it's from a process, the question is "can the active process, the one that generated the event, write to the passive, watching process?" If it's the system on a hardware event, you may want the watcher to have CAP_SYS_ADMIN. > I'd need to do a reverse walk, calling inode_permission(MAY_NOT_BL= OCK) > for each directory between the eventing object and the watchpoint = to see > if one rejects it - but some filesystems have a permission check t= hat > can't be called in this state. This is for setting the watch, right? > It would also be necessary to do this separately for each watchpoi= nt in > the parental chain. > > Further, each permissions check would generate an audit event and = could > generate FAN_ACCESS and/or FAN_ACCESS_PERM fanotify events - which= could > be a problem if fanotify is also trying to post those events to th= e same > watch queue. If you required that the watching process open(dir) what you want to watch you'd get this for free. Or did I miss something obvious? > David --txkkq0wOFA671eV9SlTrRrBSRAcaZSaKJ-- --nAYbsaLPWvSYgBq1ZgUViHpZIInmpNbp5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEC+9tH1YyUwIQzUIeOKUVfIxDyBEFAlz31tgACgkQOKUVfIxD yBEU8hAAj4xd0kV0Ucnk5ru/+nPSqV1JaihLZ77GVirKuvVGICRr78mNeNmZk6n2 u9YVwbFCdB/O/cLE9RtjQzB3PGbGuCNn9JOvKFPfSIARHmBpg93wj8KPamYmMzdJ xltRCnoLwHwHJdZEKgAEIUEQajqIj36opyx7bshsYP8j36Pzn48F1f3Fg8Kg2X2d MeDbje3oXdqf9tVQ8lVLv2EOfF4ZVBH8IqHfO1a7o8UpfZ2ZKilDF5ari5i0+L20 vvom1Xasat1j9BxFsNwwtDXU94LHK0XP5nMAHgHBjNlRQGpZ5Y7ET7RqbRxcuRNA JznODlWUqba6wsY7tnQD1cV6WLRoVzzKi66qhRONJoM8l38916mqzwoneK141fv6 JNdlwq/xkniImrKIVKBszu3LmZsorLWRdlsnxy0XLBZvbbxegLRukiUnSu62m1DV hrfGbTDKh6U1UPwaBrteSn0RNNdvl2cF5+GAc/BOMYTae4zSMJacpfX+R4GcPfpj cTpLYExK2bfYvkIcmrrbt7H38Zhdk4cxEz1Z4UykohjkLdNmuv3kwAUih78JcUbh bZe4OAGR9VYDyBqPxWlDHjrTlTZ3bIcjNAuArVZ4woBTtRaBdsAOhgomRR5S9fYF HTbMjASC6nhlc+Rthv1pXPk4nr/PrAXiRvrqLQyNYOjXxWV8ix8= =G8mX -----END PGP SIGNATURE----- --nAYbsaLPWvSYgBq1ZgUViHpZIInmpNbp5--