ext4: clean up len and offset checks in ext4_fallocate()
authorEric Biggers <ebiggers@google.com>
Tue, 31 Dec 2019 18:04:38 +0000 (12:04 -0600)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 17 Jan 2020 21:24:54 +0000 (16:24 -0500)
commit9b02e4987ab092caed8f3bccdacaef9acf9015dd
tree7b28f65ccfc3d875ff086079e13370332c6120d8
parentdd6683e6efad2339894575da46bc519646e37c24
ext4: clean up len and offset checks in ext4_fallocate()

- Fix some comments.

- Consistently access i_size directly rather than using i_size_read(),
  since in all relevant cases we're under inode_lock().

- Simplify the alignment checks by using the IS_ALIGNED() macro.

- In ext4_insert_range(), do the check against s_maxbytes in a way
  that is safe against signed overflow.  (This doesn't currently matter
  for ext4 due to ext4's limited max file size, but this is something
  other filesystems have gotten wrong.  We might as well do it safely.)

Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20191231180444.46586-3-ebiggers@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
Reviewed-by: Jan Kara <jack@suse.cz>
fs/ext4/extents.c