From mboxrd@z Thu Jan 1 00:00:00 1970 From: Casey Schaufler Subject: Re: [RFC][PATCH 00/13] Mount, FS, Block and Keyrings notifications [ver #4] Date: Mon, 10 Jun 2019 12:33:59 -0700 Message-ID: <4b7d02b2-2434-8a7c-66cc-7dbebc37efbc@schaufler-ca.com> References: <155991702981.15579.6007568669839441045.stgit@warthog.procyon.org.uk> <0cf7a49d-85f6-fba9-62ec-a378e0b76adf@schaufler-ca.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Andy Lutomirski Cc: Andy Lutomirski , Stephen Smalley , David Howells , Al Viro , USB list , LSM List , Greg Kroah-Hartman , raven@themaw.net, Linux FS Devel , Linux API , linux-block@vger.kernel.org, keyrings@vger.kernel.org, LKML , Paul Moore , casey@schaufler-ca.com List-Id: linux-api@vger.kernel.org On 6/10/2019 11:22 AM, Andy Lutomirski wrote: >> On Jun 10, 2019, at 11:01 AM, Casey Schaufler = wrote: >> >>> On 6/10/2019 9:42 AM, Andy Lutomirski wrote: >>>> On Mon, Jun 10, 2019 at 9:34 AM Casey Schaufler wrote: >>>>> On 6/10/2019 8:21 AM, Stephen Smalley wrote: >>>>>> On 6/7/19 10:17 AM, David Howells wrote: >>>>>> Hi Al, >>>>>> >>>>>> Here's a set of patches to add a general variable-length notificat= ion queue >>>>>> concept and to add sources of events for: >>>>>> >>>>>> (1) Mount topology events, such as mounting, unmounting, mount ex= piry, >>>>>> mount reconfiguration. >>>>>> >>>>>> (2) Superblock events, such as R/W<->R/O changes, quota overrun a= nd I/O >>>>>> errors (not complete yet). >>>>>> >>>>>> (3) Key/keyring events, such as creating, linking and removal of = keys. >>>>>> >>>>>> (4) General device events (single common queue) including: >>>>>> >>>>>> - Block layer events, such as device errors >>>>>> >>>>>> - USB subsystem events, such as device/bus attach/remove, dev= ice >>>>>> reset, device errors. >>>>>> >>>>>> One of the reasons for this is so that we can remove the issue of = processes >>>>>> having to repeatedly and regularly scan /proc/mounts, which has pr= oven to >>>>>> be a system performance problem. To further aid this, the fsinfo(= ) syscall >>>>>> on which this patch series depends, provides a way to access super= block and >>>>>> mount information in binary form without the need to parse /proc/m= ounts. >>>>>> >>>>>> >>>>>> LSM support is included, but controversial: >>>>>> >>>>>> (1) The creds of the process that did the fput() that reduced the= refcount >>>>>> to zero are cached in the file struct. >>>>>> >>>>>> (2) __fput() overrides the current creds with the creds from (1) = whilst >>>>>> doing the cleanup, thereby making sure that the creds seen by= the >>>>>> destruction notification generated by mntput() appears to com= e from >>>>>> the last fputter. >>>>>> >>>>>> (3) security_post_notification() is called for each queue that we= might >>>>>> want to post a notification into, thereby allowing the LSM to= prevent >>>>>> covert communications. >>>>>> >>>>>> (?) Do I need to add security_set_watch(), say, to rule on whethe= r a watch >>>>>> may be set in the first place? I might need to add a variant= per >>>>>> watch-type. >>>>>> >>>>>> (?) Do I really need to keep track of the process creds in which = an >>>>>> implicit object destruction happened? For example, imagine y= ou create >>>>>> an fd with fsopen()/fsmount(). It is marked to dissolve the = mount it >>>>>> refers to on close unless move_mount() clears that flag. Now= , imagine >>>>>> someone looking at that fd through procfs at the same time as= you exit >>>>>> due to an error. The LSM sees the destruction notification c= ome from >>>>>> the looker if they happen to do their fput() after yours. >>>>> I remain unconvinced that (1), (2), (3), and the final (?) above ar= e a good idea. >>>>> >>>>> For SELinux, I would expect that one would implement a collection o= f per watch-type WATCH permission checks on the target object (or to some= well-defined object label like the kernel SID if there is no object) tha= t allow receipt of all notifications of that watch-type for objects relat= ed to the target object, where "related to" is defined per watch-type. >>>>> >>>>> I wouldn't expect SELinux to implement security_post_notification()= at all. I can't see how one can construct a meaningful, stable policy f= or it. I'd argue that the triggering process is not posting the notifica= tion; the kernel is posting the notification and the watcher has been aut= horized to receive it. >>>> I cannot agree. There is an explicit action by a subject that result= s >>>> in information being delivered to an object. Just like a signal or a= >>>> UDP packet delivery. Smack handles this kind of thing just fine. The= >>>> internal mechanism that results in the access is irrelevant from >>>> this viewpoint. I can understand how a mechanism like SELinux that >>>> works on finer granularity might view it differently. >>> I think you really need to give an example of a coherent policy that >>> needs this. >> I keep telling you, and you keep ignoring what I say. >> >>> As it stands, your analogy seems confusing. >> It's pretty simple. I have given both the abstract >> and examples. > You gave the /dev/null example, which is inapplicable to this patchset.= That addressed an explicit objection, and pointed out an exception to a generality you had asserted, which was not true. It's also a red herring regarding the current discussion. >>> If someone >>> changes the system clock, we don't restrict who is allowed to be >>> notified (via, for example, TFD_TIMER_CANCEL_ON_SET) that the clock >>> was changed based on who changed the clock. >> That's right. The system clock is not an object that >> unprivileged processes can modify. In fact, it is not >> an object at all. If you care to look, you will see that >> Smack does nothing with the clock. > And this is different from the mount tree how? The mount tree can be modified by unprivileged users. If nothing that unprivileged users can do to the mount tree can trigger a notification you are correct, the mount tree is very like the system clock. Is that the case?=20 >>> Similarly, if someone >>> tries to receive a packet on a socket, we check whether they have the= >>> right to receive on that socket (from the endpoint in question) and, >>> if the sender is local, whether the sender can send to that socket. >>> We do not check whether the sender can send to the receiver. >> Bzzzt! Smack sure does. > This seems dubious. I=E2=80=99m still trying to get you to explain to a= non-Smack person why this makes sense. Process A sends a packet to process B. If A has access to TopSecret data and B is not allowed to see TopSecret data, the delivery should be prevented. Is that nonsensical? >>> The signal example is inapplicable. >> From a modeling viewpoint the actions are identical. > This seems incorrect to me What would be correct then? Some convoluted combination of system entities that aren't owned or controlled by any mechanism?=20 > and, I think, to most everyone else reading this. That's quite the assertion. You may even be correct. > Can you explain? > > In SELinux-ese, when you write to a file, the subject is the writer and= the object is the file. When you send a signal to a process, the object= is the target process. YES!!!!!!!!!!!! And when a process triggers a notification it is the subject and the watching process is the object! Subject =3D=3D active entity Object =3D=3D passive entity Triggering an event is, like calling kill(), an action!