linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Halcrow <mhalcrow@us.ibm.com>
To: Erez Zadok <ezk@cs.sunysb.edu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Miklos Szeredi <miklos@szeredi.hu>,
	akpm@linux-foundation.org, torvalds@linux-foundation.org,
	dave@linux.vnet.ibm.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Rusty Russell <prussell@au1.ibm.com>
Subject: Re: [patch 00/13] vfs: add helpers to check r/o bind mounts
Date: Thu, 24 Apr 2008 18:33:47 -0500	[thread overview]
Message-ID: <20080424233347.GF18686@localhost.austin.ibm.com> (raw)
In-Reply-To: <200804242239.m3OMd7hO020968@agora.fsl.cs.sunysb.edu>

On Thu, Apr 24, 2008 at 06:39:07PM -0400, Erez Zadok wrote:
> In message <20080424201630.GC18686@localhost.austin.ibm.com>,
> Michael Halcrow writes:
> > I think the right way to do it will be to allow up to two persistent
> > files. If the user with read-only perms opens, then open the
> > persistent file RO. Then a user with write-only (but not read) perms
> > opens; open another persistent file WO. Allow subsequent reads or
> > writes by the various users to go through whichever persistent file
> > has the right access. Then a user with RW access opens the file; close
> > both the RO file and the WO file and open a new file RW. All the
> > while, make sure that ecryptfs_open() performs all the requisite perm
> > checks.
> 
> Correct me if I'm wrong, but what you call "persistent" file is
> simply (in my stacking-speek :-) the lower file, right?  If so, then
> calling it persistent may be confusing, b/c you could be stacked on
> top of a volatile f/s (e.g., tmpfs or even *gasp* another stackable
> f/s) -- yes, even if it may not make much sense from a security
> perspective.

So long as the eCryptfs inode is alive, it will have at least one open
file in the corresponding inode for the lower filesystem. This file is
"persistent" for the life of the eCryptfs inode.

> The comment above ecryptfs_init_persistent_file() states that you
> only ever keep a single open file for every lower inode.  Was this a
> security decision (say, to prevent different access modes to the
> same ciphertext?); or was that the attempt to workaround the
> limitation of the address_space_operations API (that ->writepage
> doesn't get a struct file, which you need to pass to vfs_write)?

I intend to use the persistent file as a means to use vfs_read() and
vfs_write() in readpage() and writepage().

> I'm unclear what you mean above wrt two open files: do you mean
> 
> 1. two struct file's, each pointing to a SEPARATE copy of the physical lower
>   file?
> 	or
> 2. two struct file's, BOTH pointing to the same lower physical file?

I intned two lower files, both opened against the same lower inode,
via any dentry that happened to be used to get to that inode.

> Option #1 may be racy and I'm not clear what happens if a data file
> gets 'forked' that way: do you then have to merge it later on?
> 
> Or, are you propsing to keep alternating b/t an open struct file for
> RO, and another open struct file for RW (or WO)?  If you alternate
> b/t the two, keeping only one open at a time, what happens if two
> threads want to access the same file: one reading and another
> writing the file.

I proposed two open files, one with RO access, and one with WO access,
in the circumstance that one process only had read access on open, and
the other process only had write access on open. A write-only
ecryptfs_open() would result in an eCryptfs file struct that only used
the WO persistent file, after the appropriate permission checks are
done.

> Does that mean that for every read(2) or write(2) you'll have to
> essentially release one open file and open another (could slow
> things down a lot)?

Not really; I was proposing to keep two lower files open to use for
write-only or read-only operations, and if I ever got RW permission on
a file linked to the lower inode, I would just get rid of both and
replace them with a single RW persistent file. All while maintaining
proper permission checks in ecryptfs_open(), so a RO ecryptfs_open()
would only ever be allowed to read from the RW persistent file.

Really, this business with possibly two lower persistent files is
probably too much of a game to play. Rusty suggested that perhaps I
should just create a root-owned kernel thread in eCryptfs that would
have the responsibility of acquiring a RW lower persistent file,
regardless of the euid and permissions of whatever process made the
initial syscall that brought the eCryptfs inode into existence. I am
tempted to go that route instead.

Mike

  reply	other threads:[~2008-04-24 23:35 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-24 11:39 [patch 00/13] vfs: add helpers to check r/o bind mounts Miklos Szeredi
2008-04-24 11:39 ` [patch 01/13] ecryptfs: add missing lock around notify_change Miklos Szeredi
2008-04-24 16:56   ` Erez Zadok
2008-04-24 17:09     ` Miklos Szeredi
2008-04-24 11:39 ` [patch 02/13] ecryptfs: clean up (un)lock_parent Miklos Szeredi
2008-04-24 11:39 ` [patch 03/13] nfsd: clean up mnt_want_write calls Miklos Szeredi
2008-04-24 11:39 ` [patch 04/13] vfs: add path_create() and path_mknod() Miklos Szeredi
2008-04-24 11:39 ` [patch 05/13] vfs: add path_mkdir() Miklos Szeredi
2008-04-24 11:39 ` [patch 06/13] vfs: add path_rmdir() Miklos Szeredi
2008-04-24 11:39 ` [patch 07/13] vfs: add path_unlink() Miklos Szeredi
2008-04-24 11:39 ` [patch 08/13] vfs: add path_symlink() Miklos Szeredi
2008-04-24 11:39 ` [patch 09/13] vfs: add path_link() Miklos Szeredi
2008-04-24 11:40 ` [patch 10/13] vfs: add path_rename() Miklos Szeredi
2008-04-24 11:40 ` [patch 11/13] vfs: add path_setattr() Miklos Szeredi
2008-04-24 11:40 ` [patch 12/13] vfs: add path_setxattr() Miklos Szeredi
2008-04-24 11:40 ` [patch 13/13] vfs: add path_removexattr() Miklos Szeredi
2008-04-24 12:42 ` [patch 00/13] vfs: add helpers to check r/o bind mounts Al Viro
2008-04-24 13:05   ` Miklos Szeredi
2008-04-24 13:48     ` Al Viro
2008-04-24 14:00       ` Al Viro
2008-04-24 14:16         ` Miklos Szeredi
2008-04-24 14:35           ` Al Viro
2008-04-24 14:42             ` Miklos Szeredi
2008-04-24 14:48               ` Al Viro
2008-04-24 14:58                 ` Miklos Szeredi
2008-04-24 15:21                   ` Al Viro
2008-04-24 15:37                     ` Miklos Szeredi
2008-04-24 15:59                       ` Al Viro
2008-04-24 16:16                         ` Miklos Szeredi
2008-04-28 10:15                           ` Miklos Szeredi
2008-04-28 14:20                             ` Michael Halcrow
2008-04-28 14:52                               ` Miklos Szeredi
2008-04-25  7:22                         ` Miklos Szeredi
2008-04-24 17:55                       ` Dave Hansen
2008-04-24 18:47                         ` Miklos Szeredi
2008-04-24 14:09       ` Miklos Szeredi
2008-04-24 14:28         ` Al Viro
2008-04-24 14:36           ` Miklos Szeredi
2008-04-24 14:44             ` Al Viro
2008-04-24 14:53               ` Miklos Szeredi
2008-04-24 15:12                 ` Al Viro
2008-04-24 15:18                   ` Miklos Szeredi
2008-04-24 15:38                     ` Al Viro
2008-04-24 15:43                       ` Miklos Szeredi
2008-04-24 17:29           ` Erez Zadok
2008-04-24 18:13             ` Al Viro
2008-04-24 19:40               ` Erez Zadok
2008-04-24 20:16                 ` Michael Halcrow
2008-04-24 22:39                   ` Erez Zadok
2008-04-24 23:33                     ` Michael Halcrow [this message]
2008-04-28 21:53               ` J. Bruce Fields
2008-04-24 17:25       ` Erez Zadok
2008-04-24 17:30         ` Al Viro
2008-04-24 19:56           ` Erez Zadok
2008-04-24 17:04   ` Erez Zadok
2008-04-24 16:52 ` Erez Zadok
2008-04-24 16:58   ` Miklos Szeredi
2008-04-24 17:14     ` Erez Zadok
2008-04-24 17:23       ` Miklos Szeredi
2008-05-01  5:40 ` Dave Hansen
2008-05-01  8:08   ` Miklos Szeredi
2008-05-01 16:40     ` Dave Hansen
2008-05-01 17:04       ` Miklos Szeredi

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=20080424233347.GF18686@localhost.austin.ibm.com \
    --to=mhalcrow@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@linux.vnet.ibm.com \
    --cc=ezk@cs.sunysb.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=prussell@au1.ibm.com \
    --cc=torvalds@linux-foundation.org \
    --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).