bcachefs: fix overflow in fiemap
authorReed Riley <reed@riley.engineer>
Sat, 4 May 2024 22:12:23 +0000 (22:12 +0000)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 6 May 2024 14:58:17 +0000 (10:58 -0400)
commit9a0ec045110dbaad4b8d609142b534f913354101
treed0731fffb8d616c2764a0a394114dc1944ecff49
parentdb42549d402cb44fe67c95d08f1a9ea902d32e7e
bcachefs: fix overflow in fiemap

filefrag (and potentially other utilities that call fiemap) sometimes
pass ULONG_MAX as the length.  fiemap_prep clamps excessively large
lengths - but the calculation of end can overflow if it occurs before
calling fiemap_prep.  When this happens, filefrag assumes it has read to
the end and exits.

Signed-off-by: Reed Riley <reed@riley.engineer>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs.c