linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Quigley <selinux@davequigley.com>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: David Howells <dhowells@redhat.com>,
	"J. R. Okajima" <hooanon05@yahoo.co.jp>,
	<linux-fsdevel@vger.kernel.org>, <viro@zeniv.linux.org.uk>,
	<valerie.aurora@gmail.com>, <linux-kernel@vger.kernel.org>,
	<sds@tycho.nsa.gov>, <selinux@tycho.nsa.gov>,
	LSM <linux-security-module@vger.kernel.org>
Subject: Re: copy-up xattr (Re: [RFC][PATCH 00/73] Union Mount [ver #2])
Date: Tue, 27 Mar 2012 09:10:07 -0400	[thread overview]
Message-ID: <12cbdde6e0fb9e497d7cd9c277ab9cf5@countercultured.net> (raw)
In-Reply-To: <4F714463.7090508@schaufler-ca.com>

On 03/27/2012 00:38, Casey Schaufler wrote:
> On 3/26/2012 7:22 AM, David Howells wrote:
>> J. R. Okajima <hooanon05@yahoo.co.jp> wrote:
>>
>>>>  (4) Added some code to override the credentials around upper 
>>>> inode
>>>>      creation to make sure the inode gets the right UID/GID.  This 
>>>> doesn't
>>>>      help if the lower inode has some sort of foreign user 
>>>> identifier.
>>>>
>>>>      Also, I'm not sure whether the LSM xattrs should be blindly 
>>>> copied up.
>>>>      Should the LSM policies applicable to the lower fs's apply to 
>>>> the upper
>>>>      fs too?
>>> Obviously the xattr entry may not have its meanings on the upper 
>>> fs,
>> True.  I'm not sure what's the best way to deal with that.  Possibly 
>> add an
>> extra flag to vfs_setxattr() and have the fs vet them...  OTOH, this 
>> gives us
>> files on the lowerfs that may well differ in appearance to files on 
>> the
>> upperfs with respect to their xattrs.
>
> Are you suggesting that you would have heterogeneous filesystems
> with different xattr behavior stacked at the same time as you're
> using an LSM that cares about the behavior of xattrs? Oh dear. As
> I typed that sentence I identified a viable use case.

The most common use case for union mounts is a livecd. In this case the 
livecd iso has a tmpfs rw mount above it for copyup. I don't know how 
useful having a smart xattr copyup mechanism is in that place as most of 
the labels will be whatever is assigned to the iso. Another usecase is 
snapshotting of a filesystem for rollback. In this case it is probably 
important to retain the existing label as the copyup is supposed to be 
to the same location. The last case which is similar to the snapshotting 
case but with a persistant upper branch would be to have an NFS mount 
and have local configuration changes stored locally. In that case as 
well I can see simple copy up as being ok to do since you're using it 
more as an overlay than a union mount.

Now the tricky case is when you have two filesystems with two different 
directories with the same name. You're going to merge those namespaces. 
The problem occurs when the parent directories have different labels.

For example /mnt/upper/foo is labeled foo_t and /mnt/lower/foo is 
labeled foo2_t. What do you use for the label for files created in 
/mnt/union/foo?

>
>>> or the upper fs may return an error when setting the xattr. 
>>> Additionally the
>>> returned errno may not follow the generic semantics (ENOTSUP, 
>>> ENOSPC, or
>>> EDQUOT) since the fs may return fs-specific error.
>> Also true.  It's possible that the best way is just to ignore 
>> everything but a
>> medium-related error such as EIO, ENOSPC and EDQUOT: We tried...  Oh 
>> well.
>>
>>> On the other hand, users may expect that the all xattrs are 
>>> copied-up,
>>> particulary when he knows that the xattrs works well on the upper 
>>> fs too.
>>> In copy-up, it will be hard to support all cases.
>> Yeah.  Ideally, the copied-up file would be indistinguishable from 
>> the lower
>> file, but in practice that's not possible unless inode numbers and 
>> other
>> physical characteristics of the lower file are recorded in the upper 
>> fs (say
>> on an xattr).
>>
>>> In order to leave users how to handle the xattrs, I'd suggest
>>> introducing some mount options, which are similar to cp(1).
>>> cp(1) has several options
>>> 	--preserve=mode,ownership,timestamps,context,links,xattr,all
>>> 	('mode' includes acl which are based upon xattr)
>>>
>>> Since the mode (without acl), ownership and timestamps should 
>>> always be
>>> copied-up, the new mount options will be something like
>>> 	cpup-xattr=acl,context,all
>> I would suggest 'cpyup' or 'copyup' rather than 'cpup' - the latter 
>> looks like
>> something to do with CPUs, but yes, it's worth considering.
>>
>>> And only when the option is specfied, the xattrs are copied up. No
>>> special error handling is necessary, all the errors should be 
>>> returned
>>> to users unconditionally.
>> That's not necessarily good enough.  What if and LSM, say SELinux, 
>> is in
>> force?  Now SELinux will happily label the files for you - but 
>> there's a
>> reasonable chance they won't be correct.  OTOH, they may not be 
>> correct even
>> if they are copied up.
>
> The underlying storage (the "real" file) has to have the xattr 
> attached
> to it.
> Any other behavior is incorrect. If the underlying filesystem does 
> not
> support
> xattrs that lack of support has to be propagated upwards even if the 
> higher
> layer filesystem supports xattrs.
>
> In the case of Smack filesystems that don't support xattrs are still 
> given
> labels based on mount options. If the lower filesystem is NTFS and 
> the upper
> ext4 you've got to respect the NTFS labeling behavior for files 
> there.
>
>>> Does union-mount preserve mtime? If not, it is critical for some
>>> applications such like "make" I am afraid.
>> Ummm...  Interesting question.  If it copies up a file, then that 
>> file must
>> have been opened for writing.  Is the mtime altered by such an 
>> event, or only
>> by a write() having been issued?  Also, what about ctime?  That 
>> doesn't seem
>> to have been copied up either.
>
> What is the expected behavior of union mounts for all attributes? Is 
> it
> specified anywhere?
>

I would assume its under their documentation patch. I tried to lookup 
up what we did for our copyup semantics for file attributes. Its not 
simple or straight forward in the original UnionFS. I think its safe to 
say all the first class attributes need to be copied up. When possible 
we also copied the xattrs as well. Its important to realize though that 
union mounts are namespace unification and not fileunification so if you 
copy one xattr up you need to copy them all because any that don't get 
copied will get left behind.

>>
>> David
>> --
>> To unsubscribe from this list: send the line "unsubscribe 
>> linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>
>
> --
> This message was distributed to subscribers of the selinux mailing 
> list.
> If you no longer wish to subscribe, send mail to 
> majordomo@tycho.nsa.gov with
> the words "unsubscribe selinux" without quotes as the message.


  reply	other threads:[~2012-03-27 13:16 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21 17:57 [RFC][PATCH 00/73] Union Mount [ver #2] David Howells
2012-02-21 17:57 ` [PATCH 01/73] VFS: Make chown() and lchown() call fchownat() " David Howells
2012-02-21 17:57 ` [PATCH 02/73] VFS: Make clone_mnt()/copy_tree()/collect_mounts() return errors " David Howells
2012-02-21 17:57 ` [PATCH 03/73] VFS: Comment mount following code " David Howells
2012-02-21 17:57 ` [PATCH 04/73] VFS: Make lookup_hash() return a struct path " David Howells
2012-02-21 17:58 ` [PATCH 05/73] VFS: Pass mount flags to sget() " David Howells
2012-02-21 17:58 ` [PATCH 06/73] VFS: Split inode_permission() " David Howells
2012-02-21 17:58 ` [PATCH 07/73] VFS: Add hard read-only users count to superblock " David Howells
2012-02-21 17:58 ` [PATCH 08/73] VFS: Add CL_NO_SHARED flag to clone_mnt()/copy_tree() " David Howells
2012-02-29  6:56   ` Ram Pai
2012-02-21 17:58 ` [PATCH 09/73] VFS: Add CL_NO_SLAVE " David Howells
2012-02-29  6:58   ` Ram Pai
2012-02-21 17:58 ` [PATCH 10/73] VFS: Add CL_MAKE_HARD_READONLY " David Howells
2012-02-21 17:58 ` [PATCH 11/73] whiteout/NFSD: Don't return information about whiteouts to userspace " David Howells
2012-02-21 17:58 ` [PATCH 12/73] whiteout: Define flags and operations for opaque inodes " David Howells
2012-02-21 17:59 ` [PATCH 13/73] whiteout: Add vfs_whiteout() and whiteout inode operation " David Howells
2012-02-21 17:59 ` [PATCH 14/73] whiteout: Allow removal of a directory with whiteouts " David Howells
2012-02-21 17:59 ` [PATCH 15/73] tmpfs: Add whiteout support " David Howells
2012-02-21 17:59 ` [PATCH 16/73] VFS: Basic fallthru definitions " David Howells
2012-02-21 17:59 ` [PATCH 17/73] tmpfs: Add fallthru support " David Howells
2012-02-21 17:59 ` [PATCH 18/73] union-mount: Union mounts documentation " David Howells
2012-02-27  2:57   ` Randy Dunlap
2012-02-21 17:59 ` [PATCH 19/73] union-mount: Introduce MNT_UNION and MS_UNION flags " David Howells
2012-02-21 18:00 ` [PATCH 20/73] union-mount: Add CONFIG_UNION_MOUNT option " David Howells
2012-02-21 18:00 ` [PATCH 21/73] union-mount: Create union_stack structure " David Howells
2012-02-21 18:00 ` [PATCH 22/73] union-mount: Add two superblock fields for union mounts " David Howells
2012-02-21 18:00 ` [PATCH 23/73] union-mount: Add union_alloc() " David Howells
2012-02-21 18:00 ` [PATCH 24/73] union-mount: Add union_find_dir() " David Howells
2012-02-21 18:00 ` [PATCH 25/73] union-mount: Create d_free_unions() " David Howells
2012-02-21 18:00 ` [PATCH 26/73] union-mount: Free union stack on removal of topmost dentry from dcache " David Howells
2012-02-21 18:00 ` [PATCH 27/73] union-mount: Create union_add_dir() " David Howells
2012-02-21 18:01 ` [PATCH 28/73] union-mount: Add union_create_topmost_dir() " David Howells
2012-02-21 18:01 ` [PATCH 29/73] union-mount: Create IS_MNT_UNION() " David Howells
2012-02-21 18:01 ` [PATCH 30/73] union-mount: Create needs_lookup_union() " David Howells
2012-02-21 18:01 ` [PATCH 31/73] union-mount: Create check_topmost_union_mnt() " David Howells
2012-02-21 18:01 ` [PATCH 32/73] union-mount: Add clone_union_tree() and put_union_sb() " David Howells
2012-02-21 18:01 ` [PATCH 33/73] unionmount: Mark lower layers in union " David Howells
2012-02-21 18:01 ` [PATCH 34/73] union-mount: Create build_root_union() " David Howells
2012-02-21 18:01 ` [PATCH 35/73] union-mount: Create prepare_mnt_union() and cleanup_mnt_union() " David Howells
2012-02-21 18:02 ` [PATCH 36/73] union-mount: Prevent improper union-related remounts " David Howells
2012-02-21 18:02 ` [PATCH 37/73] union-mount: Prevent topmost file system from being mounted elsewhere " David Howells
2012-02-21 18:02 ` [PATCH 38/73] union-mount: Prevent bind mounts of union mounts " David Howells
2012-02-21 18:02 ` [PATCH 39/73] union-mount: Duplicate the i_{, dir_}mutex lock classes and use for upper layer " David Howells
2012-02-21 18:02 ` [PATCH 40/73] union-mount: Implement union mount " David Howells
2012-02-21 18:02 ` [PATCH 41/73] union-mount: Temporarily disable some syscalls " David Howells
2012-02-21 18:02 ` [PATCH 42/73] union-mount: Basic infrastructure of __lookup_union() " David Howells
2012-02-21 18:02 ` [PATCH 43/73] union-mount: Process negative dentries in " David Howells
2012-02-21 18:03 ` [PATCH 44/73] union-mount: Return files found in lower layers " David Howells
2012-02-21 18:03 ` [PATCH 45/73] union-mount: Build union stack " David Howells
2012-02-21 18:03 ` [PATCH 46/73] union-mount: Follow mount " David Howells
2012-02-21 18:03 ` [PATCH 47/73] union-mount: Add lookup_union_locked() " David Howells
2012-02-21 18:03 ` [PATCH 48/73] union-mount: Add wrapper for lookup_union_locked() and RCU hook " David Howells
2012-02-21 18:03 ` [PATCH 49/73] union-mount: Call union lookup functions in lookup path " David Howells
2012-02-21 18:03 ` [PATCH 50/73] union-mount: Create whiteout on unlink() " David Howells
2012-02-21 18:03 ` [PATCH 51/73] union-mount: Create whiteout on rmdir() " David Howells
2012-02-21 18:03 ` [PATCH 52/73] union-mount: Set opaque flag on new directories in unioned file systems " David Howells
2012-02-21 18:04 ` [PATCH 53/73] union-mount: Copy up directory entries on first readdir() " David Howells
2012-02-21 18:04 ` [PATCH 54/73] union-mount: Add generic_readdir_fallthru() helper " David Howells
2012-02-21 18:04 ` [PATCH 55/73] fallthru: tmpfs support for lookup of d_type/d_ino in fallthrus " David Howells
2012-02-21 18:04 ` [PATCH 56/73] union-mount: In-kernel file copyup routines " David Howells
2012-02-21 18:04 ` [PATCH 57/73] VFS: Create user_path_nd() to lookup both parent and target " David Howells
2012-02-21 18:04 ` [PATCH 58/73] unionmount: Add LOOKUP_COPY_UP " David Howells
2012-02-21 18:04 ` [PATCH 59/73] unionmount: Override creds when copying up a file to correctly set ownership " David Howells
2012-02-21 18:05 ` [PATCH 60/73] union-mount: Implement union-aware access()/faccessat() " David Howells
2012-02-21 18:05 ` [PATCH 61/73] union-mount: Make various syscalls aware (link, chmod, chown, utimes & setxattr) " David Howells
2012-02-21 18:05 ` [PATCH 62/73] union-mount: Implement union-aware rename() " David Howells
2012-02-21 18:05 ` [PATCH 63/73] union-mount: Implement union-aware writable open() " David Howells
2012-02-21 18:05 ` [PATCH 64/73] union-mount: Implement union-aware truncate() " David Howells
2012-02-21 18:05 ` [PATCH 65/73] ext2: Add ext2_dirent_in_use() " David Howells
2012-02-21 18:05 ` [PATCH 66/73] ext2: Split ext2_add_entry() from ext2_add_link() " David Howells
2012-02-27  0:04   ` Ted Ts'o
2012-02-27  3:30     ` Andreas Dilger
2012-02-27 19:09       ` Ted Ts'o
2012-02-27 20:45         ` Andreas Dilger
2012-02-21 18:05 ` [PATCH 67/73] ext2: Remove target inode pointer from ext2_add_entry() " David Howells
2012-02-27  0:22   ` Ted Ts'o
2012-02-21 18:06 ` [PATCH 68/73] ext2: Add whiteout and opaque directory support " David Howells
2012-02-21 18:06 ` [PATCH 69/73] ext2: Add fallthru " David Howells
2012-02-27  0:33   ` Ted Ts'o
2012-02-21 18:06 ` [PATCH 70/73] fallthru: ext2 support for lookup of d_type/d_ino in fallthrus " David Howells
2012-02-21 18:06 ` [PATCH 71/73] jffs2: Add whiteout support " David Howells
2012-02-21 18:06 ` [PATCH 72/73] jffs2: Add fallthru " David Howells
2012-02-21 18:06 ` [PATCH 73/73] fallthru: jffs2 support for lookup of d_type/d_ino in fallthrus " David Howells
2012-02-26  6:48 ` copy-up xattr (Re: [RFC][PATCH 00/73] Union Mount [ver #2]) J. R. Okajima
2012-03-26 14:22 ` David Howells
2012-03-27  4:38   ` Casey Schaufler
2012-03-27 13:10     ` David Quigley [this message]
2012-03-27 16:37       ` Casey Schaufler
2012-03-28 14:51   ` J. R. Okajima

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=12cbdde6e0fb9e497d7cd9c277ab9cf5@countercultured.net \
    --to=selinux@davequigley.com \
    --cc=casey@schaufler-ca.com \
    --cc=dhowells@redhat.com \
    --cc=hooanon05@yahoo.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=valerie.aurora@gmail.com \
    --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).