mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
xfs: validate fsmap offsets specified in the query keys
Improve the validation of the fsmap offset fields in the query keys and move the validation to the top of the function now that we have pushed the low key adjustment code downwards. Also fix some indenting issues that aren't worth a separate patch. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
@@ -802,6 +802,19 @@ xfs_getfsmap_check_keys(
|
|||||||
struct xfs_fsmap *low_key,
|
struct xfs_fsmap *low_key,
|
||||||
struct xfs_fsmap *high_key)
|
struct xfs_fsmap *high_key)
|
||||||
{
|
{
|
||||||
|
if (low_key->fmr_flags & (FMR_OF_SPECIAL_OWNER | FMR_OF_EXTENT_MAP)) {
|
||||||
|
if (low_key->fmr_offset)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (high_key->fmr_flags != -1U &&
|
||||||
|
(high_key->fmr_flags & (FMR_OF_SPECIAL_OWNER |
|
||||||
|
FMR_OF_EXTENT_MAP))) {
|
||||||
|
if (high_key->fmr_offset && high_key->fmr_offset != -1ULL)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (high_key->fmr_length && high_key->fmr_length != -1ULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (low_key->fmr_device > high_key->fmr_device)
|
if (low_key->fmr_device > high_key->fmr_device)
|
||||||
return false;
|
return false;
|
||||||
if (low_key->fmr_device < high_key->fmr_device)
|
if (low_key->fmr_device < high_key->fmr_device)
|
||||||
@@ -874,6 +887,8 @@ xfs_getfsmap(
|
|||||||
if (!xfs_getfsmap_is_valid_device(mp, &head->fmh_keys[0]) ||
|
if (!xfs_getfsmap_is_valid_device(mp, &head->fmh_keys[0]) ||
|
||||||
!xfs_getfsmap_is_valid_device(mp, &head->fmh_keys[1]))
|
!xfs_getfsmap_is_valid_device(mp, &head->fmh_keys[1]))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
if (!xfs_getfsmap_check_keys(&head->fmh_keys[0], &head->fmh_keys[1]))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
use_rmap = xfs_has_rmapbt(mp) &&
|
use_rmap = xfs_has_rmapbt(mp) &&
|
||||||
has_capability_noaudit(current, CAP_SYS_ADMIN);
|
has_capability_noaudit(current, CAP_SYS_ADMIN);
|
||||||
@@ -919,15 +934,8 @@ xfs_getfsmap(
|
|||||||
* other mapping for the same physical block range.
|
* other mapping for the same physical block range.
|
||||||
*/
|
*/
|
||||||
dkeys[0] = head->fmh_keys[0];
|
dkeys[0] = head->fmh_keys[0];
|
||||||
if (dkeys[0].fmr_flags & (FMR_OF_SPECIAL_OWNER | FMR_OF_EXTENT_MAP)) {
|
|
||||||
if (dkeys[0].fmr_offset)
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
memset(&dkeys[1], 0xFF, sizeof(struct xfs_fsmap));
|
memset(&dkeys[1], 0xFF, sizeof(struct xfs_fsmap));
|
||||||
|
|
||||||
if (!xfs_getfsmap_check_keys(dkeys, &head->fmh_keys[1]))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
info.next_daddr = head->fmh_keys[0].fmr_physical +
|
info.next_daddr = head->fmh_keys[0].fmr_physical +
|
||||||
head->fmh_keys[0].fmr_length;
|
head->fmh_keys[0].fmr_length;
|
||||||
info.fsmap_recs = fsmap_recs;
|
info.fsmap_recs = fsmap_recs;
|
||||||
|
Reference in New Issue
Block a user