btrfs: don't read from userspace twice in btrfs_uring_encoded_read()
authorMark Harmstone <maharmstone@fb.com>
Fri, 3 Jan 2025 15:02:26 +0000 (15:02 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 6 Jan 2025 12:59:29 +0000 (13:59 +0100)
commitc21b89d495bab6ae7ce0a1592bb955e5e80127fd
treee49ca741c9107643e72449b72ed582fbc8d3473b
parentb0af20d33f63c74985a6dd98344326e5111b2fea
btrfs: don't read from userspace twice in btrfs_uring_encoded_read()

If we return -EAGAIN the first time because we need to block,
btrfs_uring_encoded_read() will get called twice. Take a copy of args,
the iovs, and the iter the first time, as by the time we are called the
second time these may have gone out of scope.

Reported-by: Jens Axboe <axboe@kernel.dk>
Fixes: 34310c442e17 ("btrfs: add io_uring command for encoded reads (ENCODED_READ ioctl)")
Signed-off-by: Mark Harmstone <maharmstone@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c