Re: [Devel] [PATCH rh7 1/3] vfs: fix fallocate(FALLOC_FL_CONVERT_AND_EXTEND)

2016-03-10 Thread Dmitry Monakhov
Maxim Patlasov writes: > Modern vfs_fallocate() checks flags for sanity. To avoid EOPNOTSUPP error, > we have to list FALLOC_FL_CONVERT_AND_EXTEND among other valid flags. Also, > to keep checks uniform, the patch also enforces exclusiveness of the flag. Ack-by: dmonak...@openvz.org > > https://j

Re: [Devel] [PATCH rh7 2/3] ext4: rework fallocate(FALLOC_FL_CONVERT_AND_EXTEND)

2016-03-10 Thread Dmitry Monakhov
Maxim Patlasov writes: > Since Oct 9 2014 (commit 671ddaaab74a8495a549fccae49eb4305c11e5d2), ploop has > not used FALLOC_FL_KEEP_SIZE. This means that the part of > fallocate(FALLOC_FL_CONVERT_AND_EXTEND) extending i_size is redundant now. > Hence, we can use existing (and well tested) ext4_conve

Re: [Devel] [PATCH rh7 3/3] ext4: rename fallocate(FALLOC_FL_CONVERT_AND_EXTEND)

2016-03-10 Thread Dmitry Monakhov
Maxim Patlasov writes: > The feature doesn't extend i_size anymore. Let's rename it properly: > > s/convert_and_extend/convert_unwritten > s/CONVERT_AND_EXTEND/CONVERT_UNWRITTEN > > https://jira.sw.ru/browse/PSBM-22381 Ack-by: dmonak...@openvz.org > > Signed-off-by: Maxim Patlasov > --- > fs/ex

[Devel] [PATCH RH7 03/22] fs: fix a posible leak of allocated superblock

2016-03-10 Thread Pavel Tikhomirov
Imagine posible code path in sget_userns: we iterate in type->fs_supers and do not find suitable sb, we drop sb_lock to allocate s and go to retry. After we dropped sb_lock some other task from different userns takes sb_lock, it is already in retry stage and has s allocated, so it puts its s in typ

[Devel] [PATCH RH7 04/22] ms/mnt: Only change user settable mount flags in remount

2016-03-10 Thread Pavel Tikhomirov
commit a6138db815df ("mnt: Only change user settable mount flags in remount") Kenton Varda discovered that by remounting a read-only bind mount read-only in a user namespace the MNT_LOCK_READONLY bit would be cleared, allowing an unprivileged user to the remount a read-only mount read-write. Co

[Devel] [PATCH RH7 19/22] ms/fs: Add a missing permission check to do_umount

2016-03-10 Thread Pavel Tikhomirov
commit a1480dcc3c70 ("fs: Add a missing permission check to do_umount") Accessing do_remount_sb should require global CAP_SYS_ADMIN, but only one of the two call sites was appropriately protected. Fixes CVE-2014-7975. Signed-off-by: Andy Lutomirski Signed-off-by: Pavel Tikhomirov --- fs/names

[Devel] [PATCH RH7 21/22] port/capabilities: Allow privileged user in s_user_ns to set security.* xattrs

2016-03-10 Thread Pavel Tikhomirov
A privileged user in s_user_ns will generally have the ability to manipulate the backing store and insert security.* xattrs into the filesystem directly. Therefore the kernel must be prepared to handle these xattrs from unprivileged mounts, and it makes little sense for commoncap to prevent writing

[Devel] [PATCH RH7 01/22] ms/fs/super.c: fix WARN on alloc_super() fail path

2016-03-10 Thread Pavel Tikhomirov
commit b5bd856a0c2a ("fs/super.c: fix WARN on alloc_super() fail path") On fail path alloc_super() calls destroy_super(), which issues a warning if the sb's s_mounts list is not empty, in particular if it has not been initialized. That said s_mounts must be initialized in alloc_super() before any

[Devel] [PATCH RH7 18/22] port/fs: Don't remove suid for CAP_FSETID in s_user_ns

2016-03-10 Thread Pavel Tikhomirov
Expand the check in should_remove_suid() to keep privileges for CAP_FSETID in s_user_ns rather than init_user_ns. Signed-off-by: Seth Forshee Acked-by: Serge Hallyn Signed-off-by: Pavel Tikhomirov --- fs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b

[Devel] [PATCH RH7 09/22] port/block_dev: Support checking inode permissions in lookup_bdev()

2016-03-10 Thread Pavel Tikhomirov
When looking up a block device by path no permission check is done to verify that the user has access to the block device inode at the specified path. In some cases it may be necessary to check permissions towards the inode, such as allowing unprivileged users to mount block devices in user namespa

[Devel] [PATCH RH7 00/22] Port: user namespace owned mounts

2016-03-10 Thread Pavel Tikhomirov
We need it as secure way to provide privileged access to mounts in containers. For instance setting suid bit, security.capability xattr, allowing remount in CT. Those patches are not all in MS now, but actually "[PATCH v4 0/7] Initial support for user namespace owned mounts" patch series is partia

[Devel] [PATCH RH7 06/22] ms/mnt: Correct permission checks in do_remount

2016-03-10 Thread Pavel Tikhomirov
commit 9566d6742852 ("mnt: Correct permission checks in do_remount") While invesgiating the issue where in "mount --bind -oremount,ro ..." would result in later "mount --bind -oremount,rw" succeeding even if the mount started off locked I realized that there are several additional mount flags that

[Devel] [PATCH RH7 12/22] fs: remove excess check for in_userns

2016-03-10 Thread Pavel Tikhomirov
Signed-off-by: Pavel Tikhomirov --- security/commoncap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/security/commoncap.c b/security/commoncap.c index ca0c04ae..82f930c 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -445,8 +445,6 @@ static int get_file_caps(struct linux_

[Devel] [PATCH RH7 05/22] ms/mnt: Move the test for MNT_LOCK_READONLY from change_mount_flags into do_remount

2016-03-10 Thread Pavel Tikhomirov
commit 07b645589dcd ("mnt: Move the test for MNT_LOCK_READONLY from change_mount_flags into do_remount") There are no races as locked mount flags are guaranteed to never change. Moving the test into do_remount makes it more visible, and ensures all filesystem remounts pass the MNT_LOCK_READONLY

[Devel] [PATCH RH7 07/22] ebiederm/userns: Simpilify MNT_NODEV handling.

2016-03-10 Thread Pavel Tikhomirov
changes: we do not have fs_fully_visible so skip its hunk (we do not inherit flags so we do not need to cut them), also skip hunk in do_remount. git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git for-testing commit 4aceccd65a57 ("userns: Simpilify MNT_NODEV handling.") - C

[Devel] [PATCH RH7 22/22] draft/ext4: add option to set userns of superblock

2016-03-10 Thread Pavel Tikhomirov
* these one is TEMPORARY and for testing only, as changing userns of sb is not safe! We need it as NOW ploop device for VZCT can be mounted long before the container userns is created so we can't be satisfied with just setting userns on sb creation, we need to change it later. Show userns inum of

[Devel] [PATCH RH7 08/22] ebiederm/fs: Limit file caps to the user namespace of the super block

2016-03-10 Thread Pavel Tikhomirov
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git for-testing commit a8c473e95079 ("fs: Limit file caps to the user namespace of the super block") Capability sets attached to files must be ignored except in the user namespaces where the mounter is privileged, i.e. s_user_

[Devel] [PATCH RH7 02/22] ebiederm/fs: Add user namesapace member to struct super_block

2016-03-10 Thread Pavel Tikhomirov
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git for-testing commit b2bc2ff70dca ("fs: Add user namesapace member to struct super_block") Initially this will be used to eliminate the implicit MNT_NODEV flag for mounts from user namespaces. In the future it will also be us

[Devel] [PATCH RH7 14/22] port/fs: Check for invalid i_uid in may_follow_link()

2016-03-10 Thread Pavel Tikhomirov
Filesystem uids which don't map into a user namespace may result in inode->i_uid being INVALID_UID. A symlink and its parent could have different owners in the filesystem can both get mapped to INVALID_UID, which may result in following a symlink when this would not have otherwise been permitted wh

[Devel] [PATCH RH7 17/22] port/fs: Ensure the mounter of a filesystem is privileged towards its inodes

2016-03-10 Thread Pavel Tikhomirov
The mounter of a filesystem should be privileged towards the inodes of that filesystem. Extend the checks in inode_owner_or_capable() and capable_wrt_inode_uidgid() to permit access by users priviliged in the user namespace of the inode's superblock. Signed-off-by: Seth Forshee Acked-by: Serge Ha

[Devel] [PATCH RH7 11/22] port/fs: Treat foreign mounts as nosuid

2016-03-10 Thread Pavel Tikhomirov
change: move hunk for check_nnp_nosuid to selinux_bprm_set_creds If a process gets access to a mount from a different user namespace, that process should not be able to take advantage of setuid files or selinux entrypoints from that filesystem. Prevent this by treating mounts from other mount nam

[Devel] [PATCH RH7 16/22] port/fs: Refuse uid/gid changes which don't map into s_user_ns

2016-03-10 Thread Pavel Tikhomirov
Add checks to inode_change_ok to verify that uid and gid changes will map into the superblock's user namespace. If they do not fail with -EOVERFLOW. This cannot be overriden with ATTR_FORCE. Signed-off-by: Seth Forshee Acked-by: Serge Hallyn Signed-off-by: Pavel Tikhomirov --- fs/attr.c | 11 +

[Devel] [PATCH RH7 20/22] port/fs: Allow superblock owner to access do_remount_sb()

2016-03-10 Thread Pavel Tikhomirov
changes: we had ve_capable instead of capable in do_remount Superblock level remounts are currently restricted to global CAP_SYS_ADMIN, as is the path for changing the root mount to read only on umount. Loosen both of these permission checks to also allow CAP_SYS_ADMIN in any namespace which is pr

[Devel] [PATCH RH7 15/22] port/cred: Reject inodes with invalid ids in set_create_file_as()

2016-03-10 Thread Pavel Tikhomirov
Using INVALID_[UG]ID for the LSM file creation context doesn't make sense, so return an error if the inode passed to set_create_file_as() has an invalid id. Signed-off-by: Seth Forshee Acked-by: Serge Hallyn Signed-off-by: Pavel Tikhomirov --- kernel/cred.c | 2 ++ 1 file changed, 2 insertions

[Devel] [PATCH RH7 10/22] port/block_dev: Check permissions towards block device inode when mounting

2016-03-10 Thread Pavel Tikhomirov
Unprivileged users should not be able to mount block devices when they lack sufficient privileges towards the block device inode. Update blkdev_get_by_path() to validate that the user has the required access to the inode at the specified path. The check will be skipped for CAP_SYS_ADMIN, so privile

[Devel] [PATCH RH7 13/22] port/userns: Replace in_userns with current_in_userns

2016-03-10 Thread Pavel Tikhomirov
All current callers of in_userns pass current_user_ns as the first argument. Simplify by replacing in_userns with current_in_userns which checks whether current_user_ns is in the namespace supplied as an argument. Signed-off-by: Seth Forshee Acked-by: James Morris Acked-by: Serge Hallyn Signed-