1
0
Fork 0
remarkable-linux/fs/ext4
Eryu Guan 7925f4fb3d ext4: fix NULL pointer dereference in ext4_mark_inode_dirty()
[ Upstream commit 5e1021f2b6 ]

ext4_reserve_inode_write() in ext4_mark_inode_dirty() could fail on
error (e.g. EIO) and iloc.bh can be NULL in this case. But the error is
ignored in the following "if" condition and ext4_expand_extra_isize()
might be called with NULL iloc.bh set, which triggers NULL pointer
dereference.

This is uncovered by commit 8b4953e13f ("ext4: reserve code points for
the project quota feature"), which enlarges the ext4_inode size, and
run the following script on new kernel but with old mke2fs:

  #/bin/bash
  mnt=/mnt/ext4
  devname=ext4-error
  dev=/dev/mapper/$devname
  fsimg=/home/fs.img

  trap cleanup 0 1 2 3 9 15

  cleanup()
  {
          umount $mnt >/dev/null 2>&1
          dmsetup remove $devname
          losetup -d $backend_dev
          rm -f $fsimg
          exit 0
  }

  rm -f $fsimg
  fallocate -l 1g $fsimg
  backend_dev=`losetup -f --show $fsimg`
  devsize=`blockdev --getsz $backend_dev`

  good_tab="0 $devsize linear $backend_dev 0"
  error_tab="0 $devsize error $backend_dev 0"

  dmsetup create $devname --table "$good_tab"

  mkfs -t ext4 $dev
  mount -t ext4 -o errors=continue,strictatime $dev $mnt

  dmsetup load $devname --table "$error_tab" && dmsetup resume $devname
  echo 3 > /proc/sys/vm/drop_caches
  ls -l $mnt
  exit 0

[ Patch changed to simplify the function a tiny bit. -- Ted ]

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
2016-07-10 23:07:14 -04:00
..
Kconfig ext4 crypto: do not select from EXT4_FS_ENCRYPTION 2015-05-02 10:29:19 -04:00
Makefile ext4 crypto: filename encryption facilities 2015-04-12 00:56:17 -04:00
acl.c ext4: remove unused header files 2015-04-02 23:47:42 -04:00
acl.h ext2/3/4: use generic posix ACL infrastructure 2014-01-25 23:58:19 -05:00
balloc.c ext4: remove unnecessary lock/unlock of i_block_reservation_lock 2015-04-03 00:02:53 -04:00
bitmap.c ext4: remove unused header files 2015-04-02 23:47:42 -04:00
block_validity.c ext4: remove unused header files 2015-04-02 23:47:42 -04:00
crypto.c ext4 crypto: add ext4 encryption facilities 2015-04-12 00:43:56 -04:00
crypto_fname.c ext4 crypto: add padding to filenames before encrypting 2015-05-01 16:56:50 -04:00
crypto_key.c ext4 crypto: add padding to filenames before encrypting 2015-05-01 16:56:50 -04:00
crypto_policy.c ext4 crypto: add padding to filenames before encrypting 2015-05-01 16:56:50 -04:00
dir.c ext4 crypto: simplify and speed up filename encryption 2015-05-01 16:56:45 -04:00
ext4.h ext4: add lockdep annotations for i_data_sem 2016-04-20 01:03:43 -04:00
ext4_crypto.h ext4 crypto: add padding to filenames before encrypting 2015-05-01 16:56:50 -04:00
ext4_extents.h ext4: teach ext4_ext_find_extent() to realloc path if necessary 2014-09-01 14:40:09 -04:00
ext4_jbd2.c ext4: fix potential use after free in __ext4_journal_stop 2015-12-14 21:24:35 -08:00
ext4_jbd2.h ext4: don't use MAXQUOTAS value 2014-09-11 11:15:15 -04:00
extents.c ext4: fix races of writeback with punch hole and zero range 2016-03-23 10:20:24 -04:00
extents_status.c ext4: fix data corruption caused by unwritten and delayed extents 2015-05-02 21:36:55 -04:00
extents_status.h ext4: introduce aging to extent status tree 2014-11-25 11:55:24 -05:00
file.c dax: don't abuse get_block mapping for endio callbacks 2016-04-11 22:44:21 -04:00
fsync.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
hash.c ext4: remove unused header files 2015-04-02 23:47:42 -04:00
ialloc.c ext4: clean up error handling when orphan list is corrupted 2016-06-03 19:15:39 -04:00
indirect.c ext4: don't retry file block mapping on bigalloc fs with non-extent file 2015-08-03 09:28:59 -07:00
inline.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
inode.c ext4: fix NULL pointer dereference in ext4_mark_inode_dirty() 2016-07-10 23:07:14 -04:00
ioctl.c ext4 crypto: add encryption policy and password salt support 2015-04-11 07:48:01 -04:00
mballoc.c ext4: silence UBSAN in ext4_mb_init() 2016-06-03 19:15:48 -04:00
mballoc.h ext4: remove unused ac_ex_scanned 2014-02-20 13:32:10 -05:00
migrate.c ext4: correctly migrate a file with a hole at the beginning 2015-08-03 09:29:00 -07:00
mmp.c ext4: Replace open coded mdata csum feature to helper function 2014-10-13 03:36:16 -04:00
move_extent.c ext4: add lockdep annotations for i_data_sem 2016-04-20 01:03:43 -04:00
namei.c ext4: fix oops on corrupted filesystem 2016-06-03 19:15:47 -04:00
page-io.c ext4 crypto: fix memory leak in ext4_bio_write_page() 2015-12-14 21:24:35 -08:00
readpage.c ext4 crypto: implement the ext4 decryption read path 2015-04-12 00:56:10 -04:00
resize.c ext4: fix potential integer overflow 2016-03-04 10:25:42 -05:00
super.c ext4: ignore quota mount options if the quota feature is enabled 2016-04-20 01:03:44 -04:00
symlink.c Some miscellaneous bug fixes and some final on-disk and ABI changes 2015-05-03 18:23:53 -07:00
truncate.h ext4: fix races between page faults and hole punching 2016-03-23 10:20:24 -04:00
xattr.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
xattr.h ext4 crypto: add encryption xattr support 2015-04-11 07:47:00 -04:00
xattr_security.c VFS: normal filesystems (and lustre): d_inode() annotations 2015-04-15 15:06:57 -04:00
xattr_trusted.c VFS: normal filesystems (and lustre): d_inode() annotations 2015-04-15 15:06:57 -04:00
xattr_user.c VFS: normal filesystems (and lustre): d_inode() annotations 2015-04-15 15:06:57 -04:00