Skip to content

Commit 463626a

Browse files
committed
btrfs: use common eb range validation in read_extent_buffer_to_user_nofault()
The extent buffer access is checked in other helpers by check_eb_range(), which validates the requested start, length against the extent buffer. While this almost never fails we should still handle it as an error and not just warn. Reviewed-by: Boris Burkov <boris@bur.io> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent b8aa337 commit 463626a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/btrfs/extent_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4061,8 +4061,8 @@ int read_extent_buffer_to_user_nofault(const struct extent_buffer *eb,
40614061
unsigned long i;
40624062
int ret = 0;
40634063

4064-
WARN_ON(start > eb->len);
4065-
WARN_ON(start + len > eb->start + eb->len);
4064+
if (check_eb_range(eb, start, len))
4065+
return -EINVAL;
40664066

40674067
if (eb->addr) {
40684068
if (copy_to_user_nofault(dstv, eb->addr + start, len))

0 commit comments

Comments
 (0)