diff options
author | Hugh Dickins <hughd@google.com> | 2012-10-07 23:32:51 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-09 23:33:55 -0400 |
commit | 35c2a7f4908d404c9124c2efc6ada4640ca4d5d5 (patch) | |
tree | 4ef3fa1953b939fb4bfff935b3d351f76d97252b /mm | |
parent | 8e22cc88d68ca1a46d7d582938f979eb640ed30f (diff) |
tmpfs,ceph,gfs2,isofs,reiserfs,xfs: fix fh_len checking
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>
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/shmem.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index cc12072f8787..67afba5117f2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2220,12 +2220,14 @@ static struct dentry *shmem_fh_to_dentry(struct super_block *sb, | |||
2220 | { | 2220 | { |
2221 | struct inode *inode; | 2221 | struct inode *inode; |
2222 | struct dentry *dentry = NULL; | 2222 | struct dentry *dentry = NULL; |
2223 | u64 inum = fid->raw[2]; | 2223 | u64 inum; |
2224 | inum = (inum << 32) | fid->raw[1]; | ||
2225 | 2224 | ||
2226 | if (fh_len < 3) | 2225 | if (fh_len < 3) |
2227 | return NULL; | 2226 | return NULL; |
2228 | 2227 | ||
2228 | inum = fid->raw[2]; | ||
2229 | inum = (inum << 32) | fid->raw[1]; | ||
2230 | |||
2229 | inode = ilookup5(sb, (unsigned long)(inum + fid->raw[0]), | 2231 | inode = ilookup5(sb, (unsigned long)(inum + fid->raw[0]), |
2230 | shmem_match, fid->raw); | 2232 | shmem_match, fid->raw); |
2231 | if (inode) { | 2233 | if (inode) { |