An error occurred while fetching folder content.
fs: create and use seq_show_option for escaping
Kees Cook authored
Many file systems that implement the show_options hook fail to correctly
escape their output which could lead to unescaped characters (e.g.  new
lines) leaking into /proc/mounts and /proc/[pid]/mountinfo files.  This
could lead to confusion, spoofed entries (resulting in things like
systemd issuing false d-bus "mount" notifications), and who knows what
else.  This looks like it would only be the root user stepping on
themselves, but it's possible weird things could happen in containers or
in other situations with delegated mount privileges.

Here's an example using overlay with setuid fusermount trusting the
contents of /proc/mounts (via the /etc/mtab symlink).  Imagine the use
of "sudo" is something more sneaky:

  $ BASE="ovl"
  $ MNT="$BASE/mnt"
  $ LOW="$BASE/lower"
  $ UP="$BASE/upper"
  $ WORK="$BASE/work/ 0 0
  none /proc fuse.pwn user_id=1000"
  $ mkdir -p "$LOW" "$UP" "$WORK"
  $ sudo mount -t overlay -o "lowerdir=$LOW,upperdir=$UP,workdir=$WORK" none /mnt
  $ cat /proc/mounts
  none /root/ovl/mnt overlay rw,relatime,lowerdir=ovl/lower,upperdir=ovl/upper,workdir=ovl/work/ 0 0
  none /proc fuse.pwn user_id=1000 0 0
  $ fusermount -u /proc
  $ cat /proc/mounts
  cat: /proc/mounts: No such file or directory

This fixes the problem by adding new seq_show_option and
seq_show_option_n helpers, and updating the vulnerable show_option
handlers to use them as needed.  Some, like SELinux, need to be open
coded due to unusual existing escape mechanisms.

[akpm@linux-foundation.org: add lost chunk, per Kees]
[keescook@chromium.org: seq_show_option should be using const parameters]
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
Acked-by: default avatarJan Kara <jack@suse.com>
Acked-by: default avatarPaul Moore <paul@paul-moore.com>
Cc: J. R. Okajima <hooanon05g@gmail.com>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
a068acf2
Name Last commit Last update
..
amba uart: pl011: Add support to ZTE ZX296702 uart
bcma bcma: switch GPIO portions to use GPIOLIB_IRQCHIP
byteorder include/linux/byteorder/generic.h: minor comment fix
can can: replace timestamp as unique skb attribute
ceph libceph: enable ceph in a non-default network namespace
clk Merge tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
crush crush: sync up with userspace
decompress initramfs: support initramfs that is bigger than 2GiB
dma dmaengine: pxa: add pxa dmaengine driver
extcon extcon: Use the unique id for external connector instead of string
fsl/bestcomm dma: mxs-dma: remove code left from generic DMA binding conversion
gpio gpiolib: add description for gpio irqchip fields in struct gpio_chip
hsi Documentation: Add "@" in front of private structure members.
i2c mfd: twl4030-power: Fix pmic for boards that need AC charger disabled
iio iio: Add inverse unit conversion macros
input Input: improve parsing OF parameters for touchscreens
irqchip Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
isdn isdn/capi: move capi_info2str to capidrv.c
lockd lockd: eliminate LOCKD_DEBUG
mfd Merge tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
mlx4 net/mlx4_en: Add support for hardware accelerated 802.1ad vlan
mlx5 net/mlx5e: Support ethtool get/set_pauseparam
mmc mmc: mediatek: Add Mediatek MMC driver
mtd mtd: nand: Fix NAND_USE_BOUNCE_BUFFER flag conflict
netfilter netfilter: nf_conntrack: make nf_ct_zone_dflt built-in
netfilter_arp
netfilter_bridge
netfilter_ipv4
netfilter_ipv6
perf
phy
pinctrl
platform_data
power
raid
regulator
reset
rtc
sched
soc
spi
ssb
sunrpc
ulpi
unaligned
usb
uwb
wimax
8250_pci.h
a.out.h
acct.h
acpi.h
acpi_dma.h
acpi_irq.h
acpi_pmtmr.h
adb.h
adfs_fs.h
aer.h
agp_backend.h
agpgart.h
ahci_platform.h
aio.h
alarmtimer.h
altera_jtaguart.h
altera_uart.h
amd-iommu.h
amifd.h
amifdreg.h
amigaffs.h
anon_inodes.h
apm-emulation.h
apm_bios.h
apple_bl.h
arcdevice.h
arm-cci.h
asn1.h
asn1_ber_bytecode.h
asn1_decoder.h
assoc_array.h
assoc_array_priv.h
async.h
async_tx.h
ata.h
ata_platform.h
atalk.h
ath9k_platform.h
atm.h
atm_suni.h
atm_tcp.h
atmdev.h
atmel-mci.h
atmel-ssc.h
atmel_pdc.h
atmel_serial.h
atmel_tc.h
atomic.h
attribute_container.h
audit.h
auto_dev-ioctl.h
auto_fs.h