linux/fs/nilfs2
Torsten Hilbrich 63d2f95d63 fs/nilfs2: fix potential underflow in call to crc32_le
The value `bytes' comes from the filesystem which is about to be
mounted.  We cannot trust that the value is always in the range we
expect it to be.

Check its value before using it to calculate the length for the crc32_le
call.  It value must be larger (or equal) sumoff + 4.

This fixes a kernel bug when accidentially mounting an image file which
had the nilfs2 magic value 0x3434 at the right offset 0x406 by chance.
The bytes 0x01 0x00 were stored at 0x408 and were interpreted as a
s_bytes value of 1.  This caused an underflow when substracting sumoff +
4 (20) in the call to crc32_le.

  BUG: unable to handle kernel paging request at ffff88021e600000
  IP:  crc32_le+0x36/0x100
  ...
  Call Trace:
    nilfs_valid_sb.part.5+0x52/0x60 [nilfs2]
    nilfs_load_super_block+0x142/0x300 [nilfs2]
    init_nilfs+0x60/0x390 [nilfs2]
    nilfs_mount+0x302/0x520 [nilfs2]
    mount_fs+0x38/0x160
    vfs_kern_mount+0x67/0x110
    do_mount+0x269/0xe00
    SyS_mount+0x9f/0x100
    entry_SYSCALL_64_fastpath+0x16/0x71

Link: http://lkml.kernel.org/r/1466778587-5184-2-git-send-email-konishi.ryusuke@lab.ntt.co.jp
Signed-off-by: Torsten Hilbrich <torsten.hilbrich@secunet.com>
Tested-by: Torsten Hilbrich <torsten.hilbrich@secunet.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-06-24 17:23:52 -07:00
..
Kconfig fs/nilfs2: remove depends on CONFIG_EXPERIMENTAL 2013-01-11 11:39:04 -08:00
Makefile nilfs2: integrate sysfs support into driver 2014-08-08 15:57:21 -07:00
alloc.c nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
alloc.h nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
bmap.c nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
bmap.h nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
btnode.c nilfs2: clean up old e-mail addresses 2016-05-23 17:04:14 -07:00
btnode.h nilfs2: clean up old e-mail addresses 2016-05-23 17:04:14 -07:00
btree.c nilfs2: remove unnecessary else after return or break 2016-05-23 17:04:14 -07:00
btree.h nilfs2: clean up old e-mail addresses 2016-05-23 17:04:14 -07:00
cpfile.c nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
cpfile.h nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
dat.c nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
dat.h nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
dir.c nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
direct.c nilfs2: remove unnecessary else after return or break 2016-05-23 17:04:14 -07:00
direct.h nilfs2: clean up old e-mail addresses 2016-05-23 17:04:14 -07:00
export.h nilfs2: replace __attribute__((packed)) with __packed 2016-05-23 17:04:14 -07:00
file.c nilfs2: clean up old e-mail addresses 2016-05-23 17:04:14 -07:00
gcinode.c nilfs2: clean up old e-mail addresses 2016-05-23 17:04:14 -07:00
ifile.c nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
ifile.h nilfs2: add missing line spacing 2016-05-23 17:04:14 -07:00
inode.c nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
ioctl.c nilfs2: get rid of nilfs_mdt_mark_block_dirty() 2016-05-23 17:04:14 -07:00
mdt.c nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
mdt.h nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
namei.c nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
nilfs.h nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
page.c nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
page.h nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
recovery.c nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
segbuf.c nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
segbuf.h nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
segment.c nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
segment.h nilfs2: fix block comments 2016-05-23 17:04:14 -07:00
sufile.c nilfs2: add missing line spacing 2016-05-23 17:04:14 -07:00
sufile.h nilfs2: clean up old e-mail addresses 2016-05-23 17:04:14 -07:00
super.c nilfs2: fix code indent coding style issue 2016-05-23 17:04:14 -07:00
sysfs.c nilfs2: avoid bare use of 'unsigned' 2016-05-23 17:04:14 -07:00
sysfs.h nilfs2: clean trailing semicolons in macros 2016-05-23 17:04:14 -07:00
the_nilfs.c fs/nilfs2: fix potential underflow in call to crc32_le 2016-06-24 17:23:52 -07:00
the_nilfs.h nilfs2: remove loops of single statement macros 2016-05-23 17:04:14 -07:00