aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-06-15 14:00:11 +0100
committerJens Axboe <axboe@kernel.dk>2021-06-15 15:37:11 -0600
commitfdd1dc316e8959b6730d733fba025a39dac7938f (patch)
treeba1c43a46f63968b4ad9e49392075c59c3cc1d06
parentaeab9506ef50d23b350d1822c324023c9e1cb783 (diff)
downloadlinux-fdd1dc316e8959b6730d733fba025a39dac7938f.tar.gz
io_uring: Fix incorrect sizeof operator for copy_from_user call
Static analysis is warning that the sizeof being used is should be of *data->tags[i] and not data->tags[i]. Although these are the same size on 64 bit systems it is not a portable assumption to assume this is true for all cases. Fix this by using a temporary pointer tag_slot to make the code a clearer. Addresses-Coverity: ("Sizeof not portable") Fixes: d878c81610e1 ("io_uring: hide rsrc tag copy into generic helpers") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/20210615130011.57387-1-colin.king@canonical.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--fs/io_uring.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index d665c9419ad3..3692bbc7bd01 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7230,8 +7230,10 @@ static int io_rsrc_data_alloc(struct io_ring_ctx *ctx, rsrc_put_fn *do_put,
if (utags) {
ret = -EFAULT;
for (i = 0; i < nr; i++) {
- if (copy_from_user(io_get_tag_slot(data, i), &utags[i],
- sizeof(data->tags[i])))
+ u64 *tag_slot = io_get_tag_slot(data, i);
+
+ if (copy_from_user(tag_slot, &utags[i],
+ sizeof(*tag_slot)))
goto fail;
}
}