linux-uconsole/fs/xfs/linux-2.6
Hugh Dickins f38039a248 tmpfs,ceph,gfs2,isofs,reiserfs,xfs: fix fh_len checking
commit 35c2a7f490 upstream.

Fuzzing with trinity oopsed on the 1st instruction of shmem_fh_to_dentry(),
	u64 inum = fid->raw[2];
which is unhelpfully reported as at the end of shmem_alloc_inode():

BUG: unable to handle kernel paging request at ffff880061cd3000
IP: [<ffffffff812190d0>] shmem_alloc_inode+0x40/0x40
Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
Call Trace:
 [<ffffffff81488649>] ? exportfs_decode_fh+0x79/0x2d0
 [<ffffffff812d77c3>] do_handle_open+0x163/0x2c0
 [<ffffffff812d792c>] sys_open_by_handle_at+0xc/0x10
 [<ffffffff83a5f3f8>] tracesys+0xe1/0xe6

Right, tmpfs is being stupid to access fid->raw[2] before validating that
fh_len includes it: the buffer kmalloc'ed by do_sys_name_to_handle() may
fall at the end of a page, and the next page not be present.

But some other filesystems (ceph, gfs2, isofs, reiserfs, xfs) are being
careless about fh_len too, in fh_to_dentry() and/or fh_to_parent(), and
could oops in the same way: add the missing fh_len checks to those.

Reported-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Sage Weil <sage@inktank.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-21 09:17:10 -07:00
..
kmem.c xfs: Convert linux-2.6/ files to new logging interface 2011-03-07 10:00:35 +11:00
kmem.h xfs: replace KM_LARGE with explicit vmalloc use 2010-01-21 13:44:56 -06:00
mrlock.h
time.h
xfs_acl.c xfs: fix acl count validation in xfs_acl_from_disk() 2012-01-12 11:35:55 -08:00
xfs_aops.c Fix common misspellings 2011-03-31 11:26:23 -03:00
xfs_aops.h xfs: kill xfs_iomap 2010-12-16 16:05:51 -06:00
xfs_buf.c vmscan: change shrinker API by passing shrink_control struct 2011-05-25 08:39:26 -07:00
xfs_buf.h xfs: fix buffer flushing during unmount 2011-11-26 09:10:06 -08:00
xfs_discard.c xfs: fix endian conversion issue in discard code 2012-02-03 09:18:55 -08:00
xfs_discard.h xfs: add online discard support 2011-05-24 11:17:13 -05:00
xfs_export.c tmpfs,ceph,gfs2,isofs,reiserfs,xfs: fix fh_len checking 2012-10-21 09:17:10 -07:00
xfs_export.h
xfs_file.c xfs: avoid direct I/O write vs buffered I/O race 2011-11-26 09:10:05 -08:00
xfs_fs_subr.c xfs: use range primitives for xfs page cache operations 2010-10-18 15:07:24 -05:00
xfs_globals.c xfs: remove xfs_cred.h 2010-10-18 15:08:06 -05:00
xfs_ioctl.c xfs: preallocation transactions do not need to be synchronous 2011-03-26 09:13:08 +11:00
xfs_ioctl.h xfs: convert attr to use unsigned names 2010-01-20 10:47:48 +11:00
xfs_ioctl32.c xfs: add an x86 compat handler for XFS_IOC_ZERO_RANGE 2011-04-28 13:27:46 -05:00
xfs_ioctl32.h xfs: add an x86 compat handler for XFS_IOC_ZERO_RANGE 2011-04-28 13:27:46 -05:00
xfs_iops.c xfs: Return -EIO when xfs_vn_getattr() failed 2011-11-26 09:10:05 -08:00
xfs_iops.h
xfs_linux.h xfs: revert to using a kthread for AIL pushing 2011-10-25 07:10:16 +02:00
xfs_message.c xfs: kill off xfs_printk() 2011-05-19 11:38:09 -05:00
xfs_message.h xfs: kill off xfs_printk() 2011-05-19 11:38:09 -05:00
xfs_quotaops.c Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs-2.6 2010-08-07 12:57:07 -07:00
xfs_stats.c xfs: switch to seq_file 2009-09-15 12:29:24 -05:00
xfs_stats.h
xfs_super.c xfs: log the inode in ->write_inode calls for kupdate 2012-01-06 14:14:12 -08:00
xfs_super.h xfs: remove xfs_version.h 2010-10-18 15:08:04 -05:00
xfs_sync.c xfs: log all dirty inodes in xfs_fs_sync_fs 2012-01-06 14:14:12 -08:00
xfs_sync.h xfs: log all dirty inodes in xfs_fs_sync_fs 2012-01-06 14:14:12 -08:00
xfs_sysctl.c xfs: Convert linux-2.6/ files to new logging interface 2011-03-07 10:00:35 +11:00
xfs_sysctl.h
xfs_trace.c xfs: remove unneeded #include statements 2010-07-26 13:16:33 -05:00
xfs_trace.h xfs: fix compiler warning in xfs_trace.h 2011-04-28 13:27:06 -05:00
xfs_vnode.h xfs: event tracing support 2009-12-14 23:08:16 -06:00
xfs_xattr.c xfs: constify xattr_handler 2010-05-21 18:31:19 -04:00