Skip to content

Commit 1c78544

Browse files
fdmananakdave
authored andcommitted
btrfs: fix wrong address when faulting in pages in the search ioctl
When faulting in the pages for the user supplied buffer for the search ioctl, we are passing only the base address of the buffer to the function fault_in_pages_writeable(). This means that after the first iteration of the while loop that searches for leaves, when we have a non-zero offset, stored in 'sk_offset', we try to fault in a wrong page range. So fix this by adding the offset in 'sk_offset' to the base address of the user supplied buffer when calling fault_in_pages_writeable(). Several users have reported that the applications compsize and bees have started to operate incorrectly since commit a48b73e ("btrfs: fix potential deadlock in the search ioctl") was added to stable trees, and these applications make heavy use of the search ioctls. This fixes their issues. Link: https://lore.kernel.org/linux-btrfs/632b888d-a3c3-b085-cdf5-f9bb61017d92@lechevalier.se/ Link: kilobyte/compsize#34 Fixes: a48b73e ("btrfs: fix potential deadlock in the search ioctl") CC: stable@vger.kernel.org # 4.4+ Tested-by: A L <mail@lechevalier.se> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 2d892cc commit 1c78544

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/btrfs/ioctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2193,7 +2193,8 @@ static noinline int search_ioctl(struct inode *inode,
21932193
key.offset = sk->min_offset;
21942194

21952195
while (1) {
2196-
ret = fault_in_pages_writeable(ubuf, *buf_size - sk_offset);
2196+
ret = fault_in_pages_writeable(ubuf + sk_offset,
2197+
*buf_size - sk_offset);
21972198
if (ret)
21982199
break;
21992200

0 commit comments

Comments
 (0)