All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 04/98] umount: Do not allow unmounting rootfs.
Date: Mon, 11 Apr 2016 15:22:06 +0200	[thread overview]
Message-ID: <e1ce59d23ead0fa2d3d8e1dabcce3877312a77e9.1460380917.git.jslaby@suse.cz> (raw)
In-Reply-To: <def91dea48a3acb14c2379b9461ae659d95616a2.1460380917.git.jslaby@suse.cz>
In-Reply-To: <cover.1460380917.git.jslaby@suse.cz>

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

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

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

commit da362b09e42ee0bcaf0356afee6078b4f324baff upstream.

Andrew Vagin <avagin@parallels.com> writes:

> #define _GNU_SOURCE
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <sched.h>
> #include <unistd.h>
> #include <sys/mount.h>
>
> int main(int argc, char **argv)
> {
> 	int fd;
>
> 	fd = open("/proc/self/ns/mnt", O_RDONLY);
> 	if (fd < 0)
> 	   return 1;
> 	   while (1) {
> 	   	 if (umount2("/", MNT_DETACH) ||
> 		        setns(fd, CLONE_NEWNS))
> 					break;
> 					}
>
> 					return 0;
> }
>
> root@ubuntu:/home/avagin# gcc -Wall nsenter.c -o nsenter
> root@ubuntu:/home/avagin# strace ./nsenter
> execve("./nsenter", ["./nsenter"], [/* 22 vars */]) = 0
> ...
> open("/proc/self/ns/mnt", O_RDONLY)     = 3
> umount("/", MNT_DETACH)                 = 0
> setns(3, 131072)                        = 0
> umount("/", MNT_DETACH
>
causes:

> [  260.548301] ------------[ cut here ]------------
> [  260.550941] kernel BUG at /build/buildd/linux-3.13.0/fs/pnode.c:372!
> [  260.552068] invalid opcode: 0000 [#1] SMP
> [  260.552068] Modules linked in: xt_CHECKSUM iptable_mangle xt_tcpudp xt_addrtype xt_conntrack ipt_MASQUERADE iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack bridge stp llc dm_thin_pool dm_persistent_data dm_bufio dm_bio_prison iptable_filter ip_tables x_tables crct10dif_pclmul crc32_pclmul ghash_clmulni_intel binfmt_misc nfsd auth_rpcgss nfs_acl aesni_intel nfs lockd aes_x86_64 sunrpc fscache lrw gf128mul glue_helper ablk_helper cryptd serio_raw ppdev parport_pc lp parport btrfs xor raid6_pq libcrc32c psmouse floppy
> [  260.552068] CPU: 0 PID: 1723 Comm: nsenter Not tainted 3.13.0-30-generic #55-Ubuntu
> [  260.552068] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
> [  260.552068] task: ffff8800376097f0 ti: ffff880074824000 task.ti: ffff880074824000
> [  260.552068] RIP: 0010:[<ffffffff811e9483>]  [<ffffffff811e9483>] propagate_umount+0x123/0x130
> [  260.552068] RSP: 0018:ffff880074825e98  EFLAGS: 00010246
> [  260.552068] RAX: ffff88007c741140 RBX: 0000000000000002 RCX: ffff88007c741190
> [  260.552068] RDX: ffff88007c741190 RSI: ffff880074825ec0 RDI: ffff880074825ec0
> [  260.552068] RBP: ffff880074825eb0 R08: 00000000000172e0 R09: ffff88007fc172e0
> [  260.552068] R10: ffffffff811cc642 R11: ffffea0001d59000 R12: ffff88007c741140
> [  260.552068] R13: ffff88007c741140 R14: ffff88007c741140 R15: 0000000000000000
> [  260.552068] FS:  00007fd5c7e41740(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
> [  260.552068] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  260.552068] CR2: 00007fd5c7968050 CR3: 0000000070124000 CR4: 00000000000406f0
> [  260.552068] Stack:
> [  260.552068]  0000000000000002 0000000000000002 ffff88007c631000 ffff880074825ed8
> [  260.552068]  ffffffff811dcfac ffff88007c741140 0000000000000002 ffff88007c741160
> [  260.552068]  ffff880074825f38 ffffffff811dd12b ffffffff811cc642 0000000075640000
> [  260.552068] Call Trace:
> [  260.552068]  [<ffffffff811dcfac>] umount_tree+0x20c/0x260
> [  260.552068]  [<ffffffff811dd12b>] do_umount+0x12b/0x300
> [  260.552068]  [<ffffffff811cc642>] ? final_putname+0x22/0x50
> [  260.552068]  [<ffffffff811cc849>] ? putname+0x29/0x40
> [  260.552068]  [<ffffffff811dd88c>] SyS_umount+0xdc/0x100
> [  260.552068]  [<ffffffff8172aeff>] tracesys+0xe1/0xe6
> [  260.552068] Code: 89 50 08 48 8b 50 08 48 89 02 49 89 45 08 e9 72 ff ff ff 0f 1f 44 00 00 4c 89 e6 4c 89 e7 e8 f5 f6 ff ff 48 89 c3 e9 39 ff ff ff <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 90 66 66 66 66 90 55 b8 01
> [  260.552068] RIP  [<ffffffff811e9483>] propagate_umount+0x123/0x130
> [  260.552068]  RSP <ffff880074825e98>
> [  260.611451] ---[ end trace 11c33d85f1d4c652 ]--

Which in practice is totally uninteresting.  Only the global root user can
do it, and it is just a stupid thing to do.

However that is no excuse to allow a silly way to oops the kernel.

We can avoid this silly problem by setting MNT_LOCKED on the rootfs
mount point and thus avoid needing any special cases in the unmount
code.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/namespace.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index bdc6223a7500..d727b0ce11df 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2809,6 +2809,7 @@ static void __init init_mount_tree(void)
 
 	root.mnt = mnt;
 	root.dentry = mnt->mnt_root;
+	mnt->mnt_flags |= MNT_LOCKED;
 
 	set_fs_pwd(current->fs, &root);
 	set_fs_root(current->fs, &root);
-- 
2.8.1

  parent reply	other threads:[~2016-04-11 14:05 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-11 13:23 [PATCH 3.12 00/98] 3.12.58-stable review Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 01/98] ipr: Fix out-of-bounds null overwrite Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 02/98] ipr: Fix regression when loading firmware Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 03/98] ipv4: Don't do expensive useless work during inetdev destroy Jiri Slaby
2016-04-11 13:22 ` Jiri Slaby [this message]
2016-04-11 13:22 ` [PATCH 3.12 05/98] kernel: Provide READ_ONCE and ASSIGN_ONCE Jiri Slaby
2016-04-11 14:13   ` Christian Borntraeger
2016-04-11 13:22 ` [PATCH 3.12 06/98] xen: Add RING_COPY_REQUEST() Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 07/98] xen-netback: don't use last request to determine minimum Tx credit Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 08/98] xen-netback: use RING_COPY_REQUEST() throughout Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 09/98] xen-blkback: only read request operation from shared ring once Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 10/98] xen-blkback: read from indirect descriptors only once Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 11/98] xen/pciback: Save xen_pci_op commands before processing it Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 12/98] xen/pciback: Save the number of MSI-X entries to be copied later Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 13/98] xfs: allow inode allocations in post-growfs disk space Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 14/98] sched: Fix race between task_group and sched_task_group Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 15/98] Btrfs: skip locking when searching commit root Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 16/98] bnx2x: Add new device ids under the Qlogic vendor Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 17/98] drivers/base/memory.c: fix kernel warning during memory hotplug on ppc64 Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 18/98] ALSA: rawmidi: Make snd_rawmidi_transmit() race-free Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 19/98] ALSA: seq: Fix leak of pool buffer at concurrent writes Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 20/98] memcg: do not hang on OOM when killed by userspace OOM access to memory reserves Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 21/98] USB: fix invalid memory access in hub_activate() Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 22/98] intel_pstate: Use del_timer_sync in intel_pstate_cpu_stop Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 23/98] KVM: SVM: add rdmsr support for AMD event registers Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 24/98] USB: visor: fix null-deref at probe Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 25/98] s390/mm: four page table levels vs. fork Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 26/98] hwmon: (coretemp) Increase limit of maximum core ID from 32 to 128 Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 27/98] perf, nmi: Fix unknown NMI warning Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 28/98] Fix kmalloc overflow in LPFC driver at large core count Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 29/98] nfs: fix high load average due to callback thread sleeping Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 30/98] net/ipv6: fix DEVCONF_ constants Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 31/98] ipv6: mld: fix add_grhead skb_over_panic for devs with large MTUs Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 32/98] mld, igmp: Fix reserved tailroom calculation Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 33/98] ahci: Add Device ID for Intel Sunrise Point PCH Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 34/98] x86/iopl/64: Properly context-switch IOPL on Xen PV Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 35/98] KVM: i8254: change PIT discard tick policy Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 36/98] KVM: fix spin_lock_init order on x86 Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 37/98] KVM: VMX: avoid guest hang on invalid invept instruction Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 38/98] EDAC, amd64_edac: Shift wrapping issue in f1x_get_norm_dct_addr() Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 39/98] PCI: Disable IO/MEM decoding for devices with non-compliant BARs Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 40/98] x86/apic: Fix suspicious RCU usage in smp_trace_call_function_interrupt() Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 41/98] x86/iopl: Fix iopl capability check on Xen PV Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 42/98] sg: fix dxferp in from_to case Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 43/98] aacraid: Fix memory leak in aac_fib_map_free Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 44/98] be2iscsi: set the boot_kset pointer to NULL in case of failure Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 45/98] usb: retry reset if a device times out Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 46/98] usb: hub: fix a typo in hub_port_init() leading to wrong logic Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 47/98] USB: cdc-acm: more sanity checking Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 48/98] USB: iowarrior: fix oops with malicious USB descriptors Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 49/98] USB: usb_driver_claim_interface: add sanity checking Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 50/98] USB: mct_u232: add sanity checking in probe Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 51/98] USB: digi_acceleport: do sanity checking for the number of ports Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 52/98] USB: cypress_m8: add endpoint sanity check Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 53/98] USB: serial: cp210x: Adding GE Healthcare Device ID Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 54/98] USB: serial: ftdi_sio: Add support for ICP DAS I-756xU devices Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 55/98] USB: option: add "D-Link DWM-221 B1" device id Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 56/98] pwc: Add USB id for Philips Spc880nc webcam Jiri Slaby
2016-04-11 13:22 ` [PATCH 3.12 57/98] Input: powermate - fix oops with malicious USB descriptors Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 58/98] ALSA: usb-audio: Fix NULL dereference in create_fixed_stream_quirk() Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 59/98] ALSA: usb-audio: Add sanity checks for endpoint accesses Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 60/98] ALSA: usb-audio: Minor code cleanup in create_fixed_stream_quirk() Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 61/98] ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_stream() call Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 62/98] Bluetooth: btusb: Add new AR3012 ID 13d3:3395 Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 63/98] Bluetooth: btusb: Add a new AR3012 ID 04ca:3014 Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 64/98] Bluetooth: btusb: Add a new AR3012 ID 13d3:3472 Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 65/98] net: irda: Fix use-after-free in irtty_open() Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 66/98] 8250: use callbacks to access UART_DLL/UART_DLM Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 67/98] saa7134: Fix bytesperline not being set correctly for planar formats Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 68/98] adv7511: TX_EDID_PRESENT is still 1 after a disconnect Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 69/98] bttv: Width must be a multiple of 16 when capturing planar formats Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 70/98] media: v4l2-compat-ioctl32: fix missing length copy in put_v4l2_buffer32 Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 71/98] ALSA: intel8x0: Add clock quirk entry for AD1981B on IBM ThinkPad X41 Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 72/98] ALSA: hda - Fix unconditional GPIO toggle via automute Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 73/98] jbd2: fix FS corruption possibility in jbd2_journal_destroy() on umount path Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 74/98] bcache: fix cache_set_flush() NULL pointer dereference on OOM Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 75/98] watchdog: rc32434_wdt: fix ioctl error handling Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 76/98] Bluetooth: Add new AR3012 ID 0489:e095 Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 77/98] splice: handle zero nr_pages in splice_to_pipe() Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 78/98] xtensa: ISS: don't hang if stdin EOF is reached Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 79/98] xtensa: clear all DBREAKC registers on start Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 80/98] xfs: fix two memory leaks in xfs_attr_list.c error paths Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 81/98] md/raid5: Compare apples to apples (or sectors to sectors) Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 82/98] fs/coredump: prevent fsuid=0 dumps into user-controlled directories Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 83/98] rapidio/rionet: fix deadlock on SMP Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 84/98] drm/radeon: Don't drop DP 2.7 Ghz link setup on some cards Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 85/98] tracing: Have preempt(irqs)off trace preempt disabled functions Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 86/98] tracing: Fix crash from reading trace_pipe with sendfile Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 87/98] tracing: Fix trace_printk() to print when not using bprintk() Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 88/98] scripts/coccinelle: modernize & Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 89/98] kbuild/mkspec: fix grub2 installkernel issue Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 90/98] target: Fix target_release_cmd_kref shutdown comp leak Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 91/98] Input: ims-pcu - sanity check against missing interfaces Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 92/98] Input: ati_remote2 - fix crashes on detecting device with invalid descriptor Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 93/98] ocfs2/dlm: fix race between convert and recovery Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 94/98] ocfs2/dlm: fix BUG in dlm_move_lockres_to_recovery_list Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 95/98] mtd: onenand: fix deadlock in onenand_block_markbad Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 96/98] sched/cputime: Fix steal time accounting vs. CPU hotplug Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 97/98] perf/x86/intel: Use PAGE_SIZE for PEBS buffer size on Core2 Jiri Slaby
2016-04-11 13:23 ` [PATCH 3.12 98/98] perf/x86/intel: Fix PEBS data source interpretation on Nehalem/Westmere Jiri Slaby
2016-04-11 13:37 ` [PATCH 3.12 00/98] 3.12.58-stable review Guenter Roeck
2016-04-14  8:24   ` Jiri Slaby
2016-04-11 17:28 ` shuahkh

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=e1ce59d23ead0fa2d3d8e1dabcce3877312a77e9.1460380917.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.