]> git.baikalelectronics.ru Git - kernel.git/commit
fibmap: Warn and return an error in case of block > INT_MAX
authorRitesh Harjani <riteshh@linux.ibm.com>
Thu, 30 Apr 2020 14:57:46 +0000 (07:57 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 30 Apr 2020 14:57:46 +0000 (07:57 -0700)
commitd232d4e1ad74eafc51d0b3087b49cd1559858196
treeabece67f8ee91b33799198ff314ea56d8e536ea2
parenta3c98f842c1888b4df27e091ed5a315b6f7c1aa9
fibmap: Warn and return an error in case of block > INT_MAX

We better warn the fibmap user and not return a truncated and therefore
an incorrect block map address if the bmap() returned block address
is greater than INT_MAX (since user supplied integer pointer).

It's better to pr_warn() all user of ioctl_fibmap() and return a proper
error code rather than silently letting a FS corruption happen if the
user tries to fiddle around with the returned block map address.

We fix this by returning an error code of -ERANGE and returning 0 as the
block mapping address in case if it is > INT_MAX.

Now iomap_bmap() could be called from either of these two paths.
Either when a user is calling an ioctl_fibmap() interface to get
the block mapping address or by some filesystem via use of bmap()
internal kernel API.
bmap() kernel API is well equipped with handling of u64 addresses.

WARN condition in iomap_bmap_actor() was mainly added to warn all
the fibmap users. But now that we have directly added this warning
for all fibmap users and also made sure to return 0 as block map address
in case if addr > INT_MAX.
So we can now remove this logic from iomap_bmap_actor().

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/ioctl.c
fs/iomap/fiemap.c