public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Serge Hallyn <serge.hallyn@canonical.com>,
	Andy Lutomirski <luto@amacapital.net>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: [ 051/124] vfs: Carefully propogate mounts across user namespaces
Date: Tue,  2 Apr 2013 15:10:33 -0700	[thread overview]
Message-ID: <20130402221110.126307433@linuxfoundation.org> (raw)
In-Reply-To: <20130402221104.163133110@linuxfoundation.org>

3.8-stable review patch.  If anyone has any objections, please let me know.

------------------

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

commit 132c94e31b8bca8ea921f9f96a57d684fa4ae0a9 upstream.

As a matter of policy MNT_READONLY should not be changable if the
original mounter had more privileges than creator of the mount
namespace.

Add the flag CL_UNPRIVILEGED to note when we are copying a mount from
a mount namespace that requires more privileges to a mount namespace
that requires fewer privileges.

When the CL_UNPRIVILEGED flag is set cause clone_mnt to set MNT_NO_REMOUNT
if any of the mnt flags that should never be changed are set.

This protects both mount propagation and the initial creation of a less
privileged mount namespace.

Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Reported-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/namespace.c |    6 +++++-
 fs/pnode.c     |    6 ++++++
 fs/pnode.h     |    1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -798,6 +798,10 @@ static struct mount *clone_mnt(struct mo
 	}
 
 	mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~MNT_WRITE_HOLD;
+	/* Don't allow unprivileged users to change mount flags */
+	if ((flag & CL_UNPRIVILEGED) && (mnt->mnt.mnt_flags & MNT_READONLY))
+		mnt->mnt.mnt_flags |= MNT_LOCK_READONLY;
+
 	atomic_inc(&sb->s_active);
 	mnt->mnt.mnt_sb = sb;
 	mnt->mnt.mnt_root = dget(root);
@@ -2368,7 +2372,7 @@ static struct mnt_namespace *dup_mnt_ns(
 	/* First pass: copy the tree topology */
 	copy_flags = CL_COPY_ALL | CL_EXPIRE;
 	if (user_ns != mnt_ns->user_ns)
-		copy_flags |= CL_SHARED_TO_SLAVE;
+		copy_flags |= CL_SHARED_TO_SLAVE | CL_UNPRIVILEGED;
 	new = copy_tree(old, old->mnt.mnt_root, copy_flags);
 	if (IS_ERR(new)) {
 		up_write(&namespace_sem);
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -9,6 +9,7 @@
 #include <linux/mnt_namespace.h>
 #include <linux/mount.h>
 #include <linux/fs.h>
+#include <linux/nsproxy.h>
 #include "internal.h"
 #include "pnode.h"
 
@@ -220,6 +221,7 @@ static struct mount *get_source(struct m
 int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry,
 		    struct mount *source_mnt, struct list_head *tree_list)
 {
+	struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns;
 	struct mount *m, *child;
 	int ret = 0;
 	struct mount *prev_dest_mnt = dest_mnt;
@@ -237,6 +239,10 @@ int propagate_mnt(struct mount *dest_mnt
 
 		source =  get_source(m, prev_dest_mnt, prev_src_mnt, &type);
 
+		/* Notice when we are propagating across user namespaces */
+		if (m->mnt_ns->user_ns != user_ns)
+			type |= CL_UNPRIVILEGED;
+
 		child = copy_tree(source, source->mnt.mnt_root, type);
 		if (IS_ERR(child)) {
 			ret = PTR_ERR(child);
--- a/fs/pnode.h
+++ b/fs/pnode.h
@@ -23,6 +23,7 @@
 #define CL_MAKE_SHARED 		0x08
 #define CL_PRIVATE 		0x10
 #define CL_SHARED_TO_SLAVE	0x20
+#define CL_UNPRIVILEGED		0x40
 
 static inline void set_mnt_shared(struct mount *mnt)
 {



  parent reply	other threads:[~2013-04-02 23:11 UTC|newest]

Thread overview: 157+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-02 22:09 [ 000/124] 3.8.6-stable review Greg Kroah-Hartman
2013-04-02 22:09 ` [ 001/124] SUNRPC: Add barriers to ensure read ordering in rpc_wake_up_task_queue_locked Greg Kroah-Hartman
2013-04-02 22:09 ` [ 002/124] tile: expect new initramfs name from hypervisor file system Greg Kroah-Hartman
2013-04-02 22:09 ` [ 003/124] Bluetooth: Fix not closing SCO sockets in the BT_CONNECT2 state Greg Kroah-Hartman
2013-04-02 22:09 ` [ 004/124] Bluetooth: Add support for Dell[QCA 0cf3:0036] Greg Kroah-Hartman
2013-04-02 22:09 ` [ 005/124] Bluetooth: Add support for Dell[QCA 0cf3:817a] Greg Kroah-Hartman
2013-04-02 22:09 ` [ 006/124] staging: comedi: s626: fix continuous acquisition Greg Kroah-Hartman
2013-04-02 22:09 ` [ 007/124] Revert "crypto: talitos - add IPsec ESN support" Greg Kroah-Hartman
2013-04-02 22:09 ` [ 008/124] Revert "crypto: caam " Greg Kroah-Hartman
2013-04-02 22:09 ` [ 009/124] sysfs: fix race between readdir and lseek Greg Kroah-Hartman
2013-04-02 22:09 ` [ 010/124] sysfs: handle failure path correctly for readdir() Greg Kroah-Hartman
2013-04-02 22:09 ` [ 011/124] can: sja1000: fix define conflict on SH Greg Kroah-Hartman
2013-04-02 22:09 ` [ 012/124] ath9k_hw: revert chainmask to user configuration after calibration Greg Kroah-Hartman
2013-04-02 22:09 ` [ 013/124] ath9k: limit tx path hang check to normal data queues Greg Kroah-Hartman
2013-04-02 22:09 ` [ 014/124] ath9k: avoid queueing hw check work when suspended Greg Kroah-Hartman
2013-04-02 22:09 ` [ 015/124] HID: usbhid: quirk for Realtek Multi-card reader Greg Kroah-Hartman
2013-04-02 22:09 ` [ 016/124] HID: usbhid: quirk for MSI GX680R led panel Greg Kroah-Hartman
2013-04-02 22:09 ` [ 017/124] HID: usbhid: fix build problem Greg Kroah-Hartman
2013-04-02 22:10 ` [ 018/124] rtlwifi: usb: add missing freeing of skbuff Greg Kroah-Hartman
2013-04-02 22:10 ` [ 019/124] iwlwifi: fix length check in multi-TB HCMD Greg Kroah-Hartman
2013-04-02 22:10 ` [ 020/124] b43: N-PHY: increase initial value of "mind" in RSSI calibration Greg Kroah-Hartman
2013-04-02 22:10 ` [ 021/124] b43: A fix for DMA transmission sequence errors Greg Kroah-Hartman
2013-04-02 22:10 ` [ 022/124] b43: N-PHY: use more bits for offset in RSSI calibration Greg Kroah-Hartman
2013-04-02 22:10 ` [ 023/124] tg3: fix length overflow in VPD firmware parsing Greg Kroah-Hartman
2013-04-02 22:10 ` [ 024/124] mac80211: always synchronize_net() during station removal Greg Kroah-Hartman
2013-04-02 22:10 ` [ 025/124] iommu/amd: Make sure dma_ops are set for hotplug devices Greg Kroah-Hartman
2013-04-02 22:10 ` [ 026/124] xen-pciback: notify hypervisor about devices intended to be assigned to guests Greg Kroah-Hartman
2013-04-02 22:10 ` [ 027/124] xen/blkback: correctly respond to unknown, non-native requests Greg Kroah-Hartman
2013-04-02 22:10 ` [ 028/124] xen-blkback: fix dispatch_rw_block_io() error path Greg Kroah-Hartman
2013-04-02 22:10 ` [ 029/124] xen-blkfront: switch from llist to list Greg Kroah-Hartman
2013-04-02 22:10 ` [ 030/124] tty: atmel_serial_probe(): index of atmel_ports[] fix Greg Kroah-Hartman
2013-04-02 22:10 ` [ 031/124] usb: ftdi_sio: Add support for Mitsubishi FX-USB-AW/-BD Greg Kroah-Hartman
2013-04-02 22:10 ` [ 032/124] vt: synchronize_rcu() under spinlock is not nice Greg Kroah-Hartman
2013-04-02 22:10 ` [ 033/124] mwifiex: fix race when queuing commands Greg Kroah-Hartman
2013-04-02 22:10 ` [ 034/124] mwifiex: skip pending commands after function shutdown Greg Kroah-Hartman
2013-04-02 22:10 ` [ 035/124] mwifiex: cancel cmd timer and free curr_cmd in shutdown process Greg Kroah-Hartman
2013-04-02 22:10 ` [ 036/124] pnfs-block: removing DM device maybe cause oops when call dev_remove Greg Kroah-Hartman
2013-04-02 22:10 ` [ 037/124] NFSv4: Fix the string length returned by the idmapper Greg Kroah-Hartman
2013-04-02 22:10 ` [ 038/124] NFSv4.1: Fix a race in pNFS layoutcommit Greg Kroah-Hartman
2013-04-02 22:10 ` [ 039/124] NFSv4.1: Always clear the NFS_INO_LAYOUTCOMMIT in layoutreturn Greg Kroah-Hartman
2013-04-02 22:10 ` [ 040/124] net/irda: add missing error path release_sock call Greg Kroah-Hartman
2013-04-02 22:10 ` [ 041/124] Nest rename_lock inside vfsmount_lock Greg Kroah-Hartman
2013-04-02 22:10 ` [ 042/124] USB: EHCI: fix bug in iTD/siTD DMA pool allocation Greg Kroah-Hartman
2013-04-02 22:10 ` [ 043/124] usb: xhci: Fix TRB transfer length macro used for Event TRB Greg Kroah-Hartman
2013-04-02 22:10 ` [ 044/124] target: Fix RESERVATION_CONFLICT status regression for iscsi-target special case Greg Kroah-Hartman
2013-04-02 22:10 ` [ 045/124] media: [REGRESSION] bt8xx: Fix too large height in cropcap Greg Kroah-Hartman
2013-04-02 22:10 ` [ 046/124] mac80211: prevent spurious HT/VHT downgrade message Greg Kroah-Hartman
2013-04-02 22:10 ` [ 047/124] scm: Require CAP_SYS_ADMIN over the current pidns to spoof pids Greg Kroah-Hartman
2013-04-02 22:10 ` [ 048/124] pid: Handle the exit of a multi-threaded init Greg Kroah-Hartman
2013-04-02 22:10 ` [ 049/124] userns: Dont allow creation if the user is chrooted Greg Kroah-Hartman
2013-04-02 22:10 ` [ 050/124] vfs: Add a mount flag to lock read only bind mounts Greg Kroah-Hartman
2013-04-02 22:10 ` Greg Kroah-Hartman [this message]
2013-04-02 22:10 ` [ 052/124] ipc: Restrict mounting the mqueue filesystem Greg Kroah-Hartman
2013-04-02 22:10 ` [ 053/124] userns: Restrict when proc and sysfs can be mounted Greg Kroah-Hartman
2013-04-02 22:10 ` [ 054/124] Btrfs: use set_nlink if our i_nlink is 0 Greg Kroah-Hartman
2013-04-02 22:10 ` [ 055/124] Btrfs: fix locking on ROOT_REPLACE operations in tree mod log Greg Kroah-Hartman
2013-04-02 22:10 ` [ 056/124] Btrfs: fix race between mmap writes and compression Greg Kroah-Hartman
2013-04-02 22:10 ` [ 057/124] Btrfs: limit the global reserve to 512mb Greg Kroah-Hartman
2013-04-02 22:10 ` [ 058/124] Btrfs: dont drop path when printing out tree errors in scrub Greg Kroah-Hartman
2013-04-02 22:10 ` [ 059/124] USB: serial: add modem-status-change wait queue Greg Kroah-Hartman
2013-04-02 22:10 ` [ 060/124] USB: serial: fix hang when opening port Greg Kroah-Hartman
2013-04-02 22:10 ` [ 061/124] USB: quatech2: fix use-after-free in TIOCMIWAIT Greg Kroah-Hartman
2013-04-02 22:10 ` [ 062/124] USB: mos7840: fix broken TIOCMIWAIT Greg Kroah-Hartman
2013-04-02 22:10 ` [ 063/124] USB: io_ti: fix use-after-free in TIOCMIWAIT Greg Kroah-Hartman
2013-04-02 22:10 ` [ 064/124] USB: oti6858: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 065/124] USB: ftdi_sio: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 066/124] USB: pl2303: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 067/124] USB: mos7840: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 068/124] USB: spcp8x5: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 069/124] USB: ssu100: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 070/124] USB: ch341: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 071/124] USB: io_edgeport: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 072/124] USB: f81232: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 073/124] USB: ark3116: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 074/124] USB: mct_u232: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 075/124] USB: cypress_m8: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 076/124] USB: ti_usb_3410_5052: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 077/124] usb: gadget: udc-core: fix a regression during gadget driver unbinding Greg Kroah-Hartman
2013-04-02 22:11 ` [ 078/124] signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer Greg Kroah-Hartman
2013-04-02 22:11 ` [ 079/124] kernel/signal.c: use __ARCH_HAS_SA_RESTORER instead of SA_RESTORER Greg Kroah-Hartman
2013-04-02 22:11 ` [ 080/124] loop: prevent bdev freeing while device in use Greg Kroah-Hartman
2013-04-02 22:11 ` [ 081/124] ARM: cns3xxx: fix mapping of private memory region Greg Kroah-Hartman
2013-04-02 22:11 ` [ 082/124] ARM: imx: fix sync issue between imx_cpu_die and imx_cpu_kill Greg Kroah-Hartman
2013-04-02 22:11 ` [ 083/124] ARM: kirkwood: Fix chip-delay for GoFlex Net Greg Kroah-Hartman
2013-04-02 22:11 ` [ 084/124] ARM: OMAP: clocks: Delay clk inits atleast until slab is initialized Greg Kroah-Hartman
2013-04-02 22:11 ` [ 085/124] virtio: console: rename cvq_lock to c_ivq_lock Greg Kroah-Hartman
2013-04-02 22:11 ` [ 086/124] virtio: console: add locking around c_ovq operations Greg Kroah-Hartman
2013-04-02 22:11 ` [ 087/124] nfsd4: reject "negative" acl lengths Greg Kroah-Hartman
2013-04-02 22:11 ` [ 088/124] drm/i915: Use the fixed pixel clock for eDP in intel_dp_set_m_n() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 089/124] drm/i915: Dont clobber crtc->fb when queue_flip fails Greg Kroah-Hartman
2013-04-02 22:11 ` [ 090/124] iwlwifi: dvm: dont send HCMD in restart flow Greg Kroah-Hartman
2013-04-02 22:11 ` [ 091/124] Btrfs: fix space leak when we fail to reserve metadata space Greg Kroah-Hartman
2013-04-02 22:11 ` [ 092/124] xen/events: avoid race with raising an event in unmask_evtchn() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 093/124] tracing: Prevent buffer overwrite disabled for latency tracers Greg Kroah-Hartman
2013-04-02 22:11 ` [ 094/124] efivars: explicitly calculate length of VariableName Greg Kroah-Hartman
2013-04-02 22:11 ` [ 095/124] efivars: Handle duplicate names from get_next_variable() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 096/124] regulator: Fix memory garbage dev_err printout Greg Kroah-Hartman
2013-04-02 22:11 ` [ 097/124] net: remove a WARN_ON() in net_enable_timestamp() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 098/124] sky2: Receive Overflows not counted Greg Kroah-Hartman
2013-04-02 22:11 ` [ 099/124] sky2: Threshold for Pause Packet is set wrong Greg Kroah-Hartman
2013-04-02 22:11 ` [ 100/124] tcp: preserve ACK clocking in TSO Greg Kroah-Hartman
2013-04-02 22:11 ` [ 101/124] tcp: undo spurious timeout after SACK reneging Greg Kroah-Hartman
2013-04-02 22:11 ` [ 102/124] 8021q: fix a potential use-after-free Greg Kroah-Hartman
2013-04-02 22:11 ` [ 103/124] thermal: shorten too long mcast group name Greg Kroah-Hartman
2013-04-02 22:11 ` [ 104/124] unix: fix a race condition in unix_release() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL Greg Kroah-Hartman
2013-04-03 11:41   ` Sven Joachim
2013-04-03 14:00     ` Eric Dumazet
2013-04-03 15:10       ` Sven Joachim
2013-04-03 15:27         ` Greg Kroah-Hartman
2013-04-03 19:11           ` Stefan Lippers-Hollmann
2013-04-03 15:35         ` Eric Dumazet
2013-04-03 17:58           ` Andy Lutomirski
2013-04-03 18:43             ` Eric Dumazet
2013-04-03 19:01               ` Andy Lutomirski
2013-04-04  0:14                 ` Eric W. Biederman
2013-04-04  0:05     ` Eric W. Biederman
2013-04-04  0:19       ` Eric Dumazet
2013-04-04  0:30         ` Eric Dumazet
2013-04-04  1:01           ` Eric W. Biederman
2013-04-04  2:13             ` [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL" Eric W. Biederman
2013-04-04  2:14               ` [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages Eric W. Biederman
2013-04-04  3:28                 ` [PATCH 3/2] scm: Stop passing struct cred Eric W. Biederman
2013-04-05  4:47                   ` David Miller
2013-04-04  7:56                 ` [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages dingtianhong
2013-04-04 10:36                   ` Eric W. Biederman
2013-04-05  4:47                 ` David Miller
2013-04-04  7:51               ` [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL" dingtianhong
2013-04-04 10:22                 ` Eric W. Biederman
2013-04-05  4:47               ` David Miller
2013-04-04  0:47         ` [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL Eric W. Biederman
2013-04-04  0:53           ` Andy Lutomirski
2013-04-04  2:24             ` Eric W. Biederman
2013-04-05  4:47     ` David Miller
2013-04-05 16:24       ` Greg KH
2013-04-07 21:17       ` Ben Hutchings
2013-04-02 22:11 ` [ 106/124] bonding: remove already created master sysfs link on failure Greg Kroah-Hartman
2013-04-02 22:11 ` [ 107/124] bonding: fix disabling of arp_interval and miimon Greg Kroah-Hartman
2013-04-02 22:11 ` [ 108/124] drivers: net: ethernet: davinci_emac: use netif_wake_queue() while restarting tx queue Greg Kroah-Hartman
2013-04-02 22:11 ` [ 109/124] drivers: net: ethernet: cpsw: " Greg Kroah-Hartman
2013-04-02 22:11 ` [ 110/124] net: fix *_DIAG_MAX constants Greg Kroah-Hartman
2013-04-02 22:11 ` [ 111/124] aoe: reserve enough headroom on skbs Greg Kroah-Hartman
2013-04-02 22:11 ` [ 112/124] atl1e: drop pci-msi support because of packet corruption Greg Kroah-Hartman
2013-04-02 22:11 ` [ 113/124] DM9000B: driver initialization upgrade Greg Kroah-Hartman
2013-04-02 22:11 ` [ 114/124] fec: Fix the build as module Greg Kroah-Hartman
2013-04-02 22:11 ` [ 115/124] ipv6: fix bad free of addrconf_init_net Greg Kroah-Hartman
2013-04-02 22:11 ` [ 116/124] ipv6: dont accept multicast traffic with scope 0 Greg Kroah-Hartman
2013-04-02 22:11 ` [ 117/124] ipv6: dont accept node local multicast traffic from the wire Greg Kroah-Hartman
2013-04-02 22:11 ` [ 118/124] ks8851: Fix interpretation of rxlen field Greg Kroah-Hartman
2013-04-02 22:11 ` [ 119/124] net: add a synchronize_net() in netdev_rx_handler_unregister() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 120/124] net: ethernet: cpsw: fix erroneous condition in error check Greg Kroah-Hartman
2013-04-02 22:11 ` [ 121/124] net: fix the use of this_cpu_ptr Greg Kroah-Hartman
2013-04-02 22:11 ` [ 122/124] net: fq_codel: Fix off-by-one error Greg Kroah-Hartman
2013-04-02 22:11 ` [ 123/124] pch_gbe: fix ip_summed checksum reporting on rx Greg Kroah-Hartman
2013-04-02 22:11 ` [ 124/124] smsc75xx: fix jumbo frame support Greg Kroah-Hartman
2013-04-03 15:17 ` [ 000/124] 3.8.6-stable review Shuah Khan
2013-04-03 15:28   ` Greg Kroah-Hartman

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=20130402221110.126307433@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=serge.hallyn@canonical.com \
    --cc=stable@vger.kernel.org \
    /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