stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [added to the 3.18 stable tree] mnt: Refactor the logic for mounting sysfs and proc in a user namespace
@ 2015-07-13 13:43 Sasha Levin
  2015-07-13 13:43 ` [added to the 3.18 stable tree] tty/serial: at91: RS485 mode: 0 is valid for delay_rts_after_send Sasha Levin
                   ` (35 more replies)
  0 siblings, 36 replies; 44+ messages in thread
From: Sasha Levin @ 2015-07-13 13:43 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric W. Biederman, Sasha Levin

From: "Eric W. Biederman" <ebiederm@xmission.com>

This patch has been added to the 3.18 stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 1b852bceb0d111e510d1a15826ecc4a19358d512 ]

Fresh mounts of proc and sysfs are a very special case that works very
much like a bind mount.  Unfortunately the current structure can not
preserve the MNT_LOCK... mount flags.  Therefore refactor the logic
into a form that can be modified to preserve those lock bits.

Add a new filesystem flag FS_USERNS_VISIBLE that requires some mount
of the filesystem be fully visible in the current mount namespace,
before the filesystem may be mounted.

Move the logic for calling fs_fully_visible from proc and sysfs into
fs/namespace.c where it has greater access to mount namespace state.

Cc: stable@vger.kernel.org
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 fs/namespace.c     | 8 +++++++-
 fs/proc/root.c     | 5 +----
 fs/sysfs/mount.c   | 5 +----
 include/linux/fs.h | 2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index a19d05c..5f01463 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2297,6 +2297,8 @@ unlock:
 	return err;
 }
 
+static bool fs_fully_visible(struct file_system_type *fs_type);
+
 /*
  * create a new mount for userspace and request it to be added into the
  * namespace's tree
@@ -2328,6 +2330,10 @@ static int do_new_mount(struct path *path, const char *fstype, int flags,
 			flags |= MS_NODEV;
 			mnt_flags |= MNT_NODEV | MNT_LOCK_NODEV;
 		}
+		if (type->fs_flags & FS_USERNS_VISIBLE) {
+			if (!fs_fully_visible(type))
+				return -EPERM;
+		}
 	}
 
 	mnt = vfs_kern_mount(type, flags, name, data);
@@ -3125,7 +3131,7 @@ bool current_chrooted(void)
 	return chrooted;
 }
 
-bool fs_fully_visible(struct file_system_type *type)
+static bool fs_fully_visible(struct file_system_type *type)
 {
 	struct mnt_namespace *ns = current->nsproxy->mnt_ns;
 	struct mount *mnt;
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 094e44d..9e772f1 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -112,9 +112,6 @@ static struct dentry *proc_mount(struct file_system_type *fs_type,
 		ns = task_active_pid_ns(current);
 		options = data;
 
-		if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type))
-			return ERR_PTR(-EPERM);
-
 		/* Does the mounter have privilege over the pid namespace? */
 		if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
 			return ERR_PTR(-EPERM);
@@ -159,7 +156,7 @@ static struct file_system_type proc_fs_type = {
 	.name		= "proc",
 	.mount		= proc_mount,
 	.kill_sb	= proc_kill_sb,
-	.fs_flags	= FS_USERNS_MOUNT,
+	.fs_flags	= FS_USERNS_VISIBLE | FS_USERNS_MOUNT,
 };
 
 void __init proc_root_init(void)
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 8a49486..1c6ac6f 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -31,9 +31,6 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
 	bool new_sb;
 
 	if (!(flags & MS_KERNMOUNT)) {
-		if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type))
-			return ERR_PTR(-EPERM);
-
 		if (!kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET))
 			return ERR_PTR(-EPERM);
 	}
@@ -58,7 +55,7 @@ static struct file_system_type sysfs_fs_type = {
 	.name		= "sysfs",
 	.mount		= sysfs_mount,
 	.kill_sb	= sysfs_kill_sb,
-	.fs_flags	= FS_USERNS_MOUNT,
+	.fs_flags	= FS_USERNS_VISIBLE | FS_USERNS_MOUNT,
 };
 
 int __init sysfs_init(void)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9ab779e..84d6729 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1791,6 +1791,7 @@ struct file_system_type {
 #define FS_HAS_SUBTYPE		4
 #define FS_USERNS_MOUNT		8	/* Can be mounted by userns root */
 #define FS_USERNS_DEV_MOUNT	16 /* A userns mount does not imply MNT_NODEV */
+#define FS_USERNS_VISIBLE	32	/* FS must already be visible */
 #define FS_RENAME_DOES_D_MOVE	32768	/* FS will handle d_move() during rename() internally. */
 	struct dentry *(*mount) (struct file_system_type *, int,
 		       const char *, void *);
@@ -1878,7 +1879,6 @@ extern int vfs_ustat(dev_t, struct kstatfs *);
 extern int freeze_super(struct super_block *super);
 extern int thaw_super(struct super_block *super);
 extern bool our_mnt(struct vfsmount *mnt);
-extern bool fs_fully_visible(struct file_system_type *);
 
 extern int current_umask(void);
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 44+ messages in thread
* [added to the 3.18 stable tree] ata: ahci_mvebu: Fix wrongly set base address for the MBus window setting
@ 2015-07-04  3:00 Sasha Levin
  2015-07-04  3:02 ` [added to the 3.18 stable tree] can: fix loss of CAN frames in raw_rcv Sasha Levin
  0 siblings, 1 reply; 44+ messages in thread
From: Sasha Levin @ 2015-07-04  3:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Nadav Haklai, Gregory CLEMENT, Tejun Heo, Sasha Levin

From: Nadav Haklai <nadavh@marvell.com>

This patch has been added to the 3.18 stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e96998fc200867f005dd14c7d1dd35e1107d4914 ]

According to the Armada 38x datasheet, the window base address
registers value is set in bits [31:4] of the register and corresponds
to the transaction address bits [47:20].

Therefore, the 32bit base address value should be shifted right by
20bits and left by 4bits, resulting in 16 bit shift right.

The bug as not been noticed yet because if the memory available on
the platform is less than 2GB, then the base address is zero.

[gregory.clement@free-electrons.com: add extra-explanation]

Fixes: a3464ed2f14 (ata: ahci_mvebu: new driver for Marvell Armada 380
AHCI interfaces)
Signed-off-by: Nadav Haklai <nadavh@marvell.com>
Reviewed-by: Omri Itach <omrii@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/ata/ahci_mvebu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c
index 68672d2..e3267b7 100644
--- a/drivers/ata/ahci_mvebu.c
+++ b/drivers/ata/ahci_mvebu.c
@@ -43,7 +43,7 @@ static void ahci_mvebu_mbus_config(struct ahci_host_priv *hpriv,
 		writel((cs->mbus_attr << 8) |
 		       (dram->mbus_dram_target_id << 4) | 1,
 		       hpriv->mmio + AHCI_WINDOW_CTRL(i));
-		writel(cs->base, hpriv->mmio + AHCI_WINDOW_BASE(i));
+		writel(cs->base >> 16, hpriv->mmio + AHCI_WINDOW_BASE(i));
 		writel(((cs->size - 1) & 0xffff0000),
 		       hpriv->mmio + AHCI_WINDOW_SIZE(i));
 	}
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2015-07-21  1:14 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-13 13:43 [added to the 3.18 stable tree] mnt: Refactor the logic for mounting sysfs and proc in a user namespace Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] tty/serial: at91: RS485 mode: 0 is valid for delay_rts_after_send Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] mnt: Modify fs_fully_visible to deal with locked ro nodev and atime Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] kprobes/x86: Return correct length in __copy_instruction() Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] config: Enable NEED_DMA_MAP_STATE by default when SWIOTLB is selected Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] netfilter: nfnetlink_cthelper: Remove 'const' and '&' to avoid warnings Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] fs/ufs: revert "ufs: fix deadlocks introduced by sb mutex merge" Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] fs/ufs: restore s_lock mutex Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] can: fix loss of CAN frames in raw_rcv Sasha Levin
2015-07-13 13:54   ` Marc Kleine-Budde
2015-07-13 15:53     ` Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] fs: Fix S_NOSEC handling Sasha Levin
2015-07-13 13:43 ` [added to the 3.18 stable tree] tracing: Have filter check for balanced ops Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] sb_edac: Fix erroneous bytes->gigabytes conversion Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] netfilter: Zero the tuple in nfnl_cthelper_parse_tuple() Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] netfilter: nf_tables: allow to change chain policy without hook if it exists Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] x86/microcode/intel: Guard against stack overflow in the loader Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] Btrfs: make xattr replace operations atomic Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] ARM: clk-imx6q: refine sata's parent Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] KVM: nSVM: Check for NRIPS support before updating control field Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] arm64/kvm: Fix assembler compatibility of macros Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] iommu/amd: Handle large pages correctly in free_pagetable Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] arm: KVM: force execution of HCPTR access on VM exit Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] KVM: x86: make vapics_in_nmi_mode atomic Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] vfs: Remove incorrect debugging WARN in prepend_path Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] x86/boot: Fix overflow warning with 32-bit binutils Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] perf: Fix ring_buffer_attach() RCU sync, again Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] perf/x86: Honor the architectural performance monitoring version Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] ARM: dts: sunxi: Adjust touchscreen compatible for sun5i and later Sasha Levin
2015-07-19 10:43   ` Hans de Goede
2015-07-21  1:14     ` Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] usb: gadget: f_fs: add extra check before unregister_gadget_item Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] selinux: fix setting of security labels on NFS Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] KVM: s390: virtio-ccw: don't overwrite config space values Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] KVM: x86: properly restore LVT0 Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] vfs: Ignore unlocked mounts in fs_fully_visible Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] ufs: Fix warning from unlock_new_inode() Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] ufs: Fix possible deadlock when looking up directories Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] fs/ufs: restore s_lock mutex_init() Sasha Levin
2015-07-13 13:44 ` [added to the 3.18 stable tree] Revert "nfs: take extra reference to fl->fl_file when running a LOCKU operation" Sasha Levin
  -- strict thread matches above, loose matches on Subject: below --
2015-07-04  3:00 [added to the 3.18 stable tree] ata: ahci_mvebu: Fix wrongly set base address for the MBus window setting Sasha Levin
2015-07-04  3:02 ` [added to the 3.18 stable tree] can: fix loss of CAN frames in raw_rcv Sasha Levin
2015-07-04 15:35   ` Oliver Hartkopp
2015-07-05 14:28     ` Sasha Levin

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).