linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: dhowells@redhat.com, Casey Schaufler <casey@schaufler-ca.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	USB list <linux-usb@vger.kernel.org>,
	raven@themaw.net, Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	Linux API <linux-api@vger.kernel.org>,
	linux-block@vger.kernel.org, keyrings@vger.kernel.org,
	LSM List <linux-security-module@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Paul Moore <paul@paul-moore.com>
Subject: Re: [RFC][PATCH 00/10] Mount, FS, Block and Keyrings notifications [ver #3]
Date: Thu, 06 Jun 2019 22:17:07 +0100	[thread overview]
Message-ID: <23611.1559855827@warthog.procyon.org.uk> (raw)
In-Reply-To: <CALCETrVuNRPgEzv-XY4M9m6sEsCiRHxPenN_MpcMYc1h26vVwQ@mail.gmail.com>

Andy Lutomirski <luto@kernel.org> wrote:

> > > You are allowing arbitrary information flow between T and W above.  Who
> > > cares about notifications?
> >
> > I do. If Watched object is /dev/null no data flow is possible.
> > There are many objects on a modern Linux system for which this
> > is true. Even if it's "just a file" the existence of one path
> > for data to flow does not justify ignoring the rules for other
> > data paths.
> 
> Aha!
> 
> Even ignoring security, writes to things like /dev/null should
> probably not trigger notifications to people who are watching
> /dev/null.  (There are probably lots of things like this: /dev/zero,
> /dev/urandom, etc.)

Even writes to /dev/null might generate access notifications; leastways,
vfs_read() will call fsnotify_access() afterwards on success.

Whether or not you can set marks on open device files is another matter.

> David, are there any notification types that have this issue in your
> patchset?  If so, is there a straightforward way to fix it?

I'm not sure what issue you're referring to specifically.  Do you mean whether
writes to device files generate notifications?

> Generically, it seems like maybe writes to device nodes shouldn't trigger
> notifications since, despite the fact that different openers of a device
> node share an inode, there isn't necessarily any connection between them.

With the notification types I have currently implemented, I don't even notice
any accesses to a device file unless:

 (1) Someone mounts over the top of one.

 (2) The access triggers an I/O error or device reset or causes the device to
     be attached or detached.

 (3) Wangling the device causes some other superblock event.

 (4) The driver calls request_key() and that creates a new key.

> Casey, if this is fixed in general, do you have another case where the
> right to write and the right to read do not imply the right to
> communicate?
> 
> > An analogy is that two processes with different UIDs can open a file,
> > but still can't signal each other.
> 
> What do you mean "signal"?  If two processes with different UIDs can
> open the same file for read and write, then they can communicate with
> each other in many ways.  For example, one can write to the file and
> the other can read it.  One can take locks and the other can read the
> lock state.  They can both map it and use any number of memory access
> side channels to communicate.  But, of course, they can't send each
> other signals with kill().
> 
> If, however, one of these processes is using some fancy mechanism
> (inotify, dnotify, kqueue, fanotify, whatever) to watch the file, and
> the other one writes it, then it seems inconsistent to lie to the
> watching process and say that the file wasn't written because some
> security policy has decided to allow the write, allow the read, but
> suppress this particular notification.  Hence my request for a real
> example: when would it make sense to do this?

Note that fanotify requires CAP_SYS_ADMIN, but inotify and dnotify do not.

dnotify is applied to an open file, so it might be usable on a chardev such as
/dev/null, say.

David

  parent reply	other threads:[~2019-06-06 21:17 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06  9:41 [RFC][PATCH 00/10] Mount, FS, Block and Keyrings notifications [ver #3] David Howells
2019-06-06  9:42 ` [PATCH 01/10] security: Override creds in __fput() with last fputter's creds " David Howells
2019-06-06 14:57   ` Andy Lutomirski
2019-06-06 15:06   ` David Howells
2019-06-06 17:18     ` Andy Lutomirski
2019-06-06 19:09       ` Casey Schaufler
2019-06-06 19:34         ` Andy Lutomirski
2019-06-06  9:42 ` [PATCH 02/10] General notification queue with user mmap()'able ring buffer " David Howells
2019-06-06  9:42 ` [PATCH 03/10] keys: Add a notification facility " David Howells
2019-06-06  9:42 ` [PATCH 04/10] vfs: Add a mount-notification " David Howells
2019-06-06  9:42 ` [PATCH 05/10] vfs: Add superblock notifications " David Howells
2019-06-06  9:42 ` [PATCH 06/10] fsinfo: Export superblock notification counter " David Howells
2019-06-06  9:43 ` [PATCH 07/10] Add a general, global device notification watch list " David Howells
2019-06-06  9:43 ` [PATCH 08/10] block: Add block layer notifications " David Howells
2019-06-06  9:43 ` [PATCH 09/10] usb: Add USB subsystem " David Howells
2019-06-06 14:24   ` Alan Stern
2019-06-06 14:33     ` Greg Kroah-Hartman
2019-06-06 14:55       ` Alan Stern
2019-06-06 15:31         ` Greg Kroah-Hartman
2019-06-07  6:40           ` Felipe Balbi
2019-06-07 14:01             ` Alan Stern
2019-06-11  6:28               ` Felipe Balbi
2019-06-11 13:53                 ` Alan Stern
2019-06-12  6:58                   ` Felipe Balbi
2019-06-06  9:43 ` [PATCH 10/10] Add sample notification program " David Howells
2019-06-06 21:21   ` Eugeniu Rosca
2019-06-06 22:52   ` David Howells
2019-06-07 14:37   ` David Howells
2019-06-06 12:32 ` [RFC][PATCH 00/10] Mount, FS, Block and Keyrings notifications " Stephen Smalley
2019-06-06 13:16 ` David Howells
2019-06-06 14:05   ` Stephen Smalley
2019-06-06 16:43     ` Casey Schaufler
2019-06-06 17:11       ` Andy Lutomirski
2019-06-06 18:33         ` Casey Schaufler
2019-06-06 18:51           ` Andy Lutomirski
2019-06-06 17:16       ` Stephen Smalley
2019-06-06 18:56         ` Casey Schaufler
2019-06-06 19:54           ` Andy Lutomirski
2019-06-06 21:17           ` David Howells [this message]
2019-06-06 21:54             ` Andy Lutomirski
2019-06-06 22:38             ` David Howells
2019-06-06 22:42               ` Andy Lutomirski
2019-06-06 22:50               ` David Howells
2019-06-06 14:34 ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23611.1559855827@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=casey@schaufler-ca.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=paul@paul-moore.com \
    --cc=raven@themaw.net \
    --cc=sds@tycho.nsa.gov \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).