Skip to content

Commit effd9c4

Browse files
committed
Merge branch 'io_uring-6.18' into for-next
* io_uring-6.18: io_uring: fix regbuf vector size truncation
2 parents d993592 + 146eb58 commit effd9c4

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

io_uring/rsrc.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,11 @@ static int io_estimate_bvec_size(struct iovec *iov, unsigned nr_iovs,
14051405
size_t max_segs = 0;
14061406
unsigned i;
14071407

1408-
for (i = 0; i < nr_iovs; i++)
1408+
for (i = 0; i < nr_iovs; i++) {
14091409
max_segs += (iov[i].iov_len >> shift) + 2;
1410+
if (max_segs > INT_MAX)
1411+
return -EOVERFLOW;
1412+
}
14101413
return max_segs;
14111414
}
14121415

@@ -1512,7 +1515,11 @@ int io_import_reg_vec(int ddir, struct iov_iter *iter,
15121515
if (unlikely(ret))
15131516
return ret;
15141517
} else {
1515-
nr_segs = io_estimate_bvec_size(iov, nr_iovs, imu);
1518+
int ret = io_estimate_bvec_size(iov, nr_iovs, imu);
1519+
1520+
if (ret < 0)
1521+
return ret;
1522+
nr_segs = ret;
15161523
}
15171524

15181525
if (sizeof(struct bio_vec) > sizeof(struct iovec)) {

0 commit comments

Comments
 (0)