1
0
Fork 0
alistair23-linux/fs/hfs
Kees Cook a068acf2ee fs: create and use seq_show_option for escaping
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: Kees Cook <keescook@chromium.org>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Acked-by: Jan Kara <jack@suse.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Cc: J. R. Okajima <hooanon05g@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-09-04 16:54:41 -07:00
..
Kconfig fs/hfs: remove depends on CONFIG_EXPERIMENTAL 2013-01-21 14:39:05 -08:00
Makefile Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
attr.c VFS: normal filesystems (and lustre): d_inode() annotations 2015-04-15 15:06:57 -04:00
bfind.c hfs/hfsplus: convert printks to pr_<level> 2013-04-30 17:04:05 -07:00
bitmap.c hfs/hfsplus: convert dprint to hfs_dbg 2013-04-30 17:04:05 -07:00
bnode.c hfs: avoid crash in hfs_bnode_create 2013-05-24 16:22:51 -07:00
brec.c hfs/hfsplus: convert printks to pr_<level> 2013-04-30 17:04:05 -07:00
btree.c hfs/hfsplus: convert printks to pr_<level> 2013-04-30 17:04:05 -07:00
btree.h fs/hfs/btree.h: remove duplicate defines 2013-11-13 12:09:32 +09:00
catalog.c fs/hfs/catalog.c: fix comparison bug in hfs_cat_keycmp 2014-12-10 17:41:16 -08:00
dir.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2015-04-26 17:22:07 -07:00
extent.c hfs/hfsplus: convert dprint to hfs_dbg 2013-04-30 17:04:05 -07:00
hfs.h address hfs on-disk corruption robustness review comments 2008-02-06 10:41:05 -08:00
hfs_fs.h fs: cleanup slight list_entry abuse 2015-06-23 18:01:59 -04:00
inode.c VFS: normal filesystems (and lustre): d_inode() annotations 2015-04-15 15:06:57 -04:00
mdb.c hfs/hfsplus: convert printks to pr_<level> 2013-04-30 17:04:05 -07:00
part_tbl.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
string.c Don't pass inode to ->d_hash() and ->d_compare() 2013-06-29 12:57:36 +04:00
super.c fs: create and use seq_show_option for escaping 2015-09-04 16:54:41 -07:00
sysdep.c VFS: normal filesystems (and lustre): d_inode() annotations 2015-04-15 15:06:57 -04:00
trans.c hfs: add sanity check for file name length 2011-11-15 14:29:42 -02:00