Skip to content

Commit 96a7b71

Browse files
committed
ubd: Use pointer-to-pointers for io_thread_req arrays
Having an unbounded array for irq_req_buffer and io_req_buffer doesn't provide any bounds safety, and confuses the needed allocation type, which is returning a pointer to pointers. Instead of the implicit cast, switch the variable types. Reported-by: Nathan Chancellor <nathan@kernel.org> Reported-by: Guenter Roeck <linux@roeck-us.net> Closes: https://lore.kernel.org/all/b04b6c13-7d0e-4a89-9e68-b572b6c686ac@roeck-us.net Fixes: 69050f8 ("treewide: Replace kmalloc with kmalloc_obj for non-scalar types") Acked-by: Richard Weinberger <richard@nod.at> Link: https://patch.msgid.link/20260223214341.work.846-kees@kernel.org Signed-off-by: Kees Cook <kees@kernel.org>
1 parent 6de23f8 commit 96a7b71

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

arch/um/drivers/ubd_kern.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ struct io_thread_req {
6969
};
7070

7171

72-
static struct io_thread_req * (*irq_req_buffer)[];
72+
static struct io_thread_req **irq_req_buffer;
7373
static struct io_thread_req *irq_remainder;
7474
static int irq_remainder_size;
7575

76-
static struct io_thread_req * (*io_req_buffer)[];
76+
static struct io_thread_req **io_req_buffer;
7777
static struct io_thread_req *io_remainder;
7878
static int io_remainder_size;
7979

@@ -398,7 +398,7 @@ static int thread_fd = -1;
398398

399399
static int bulk_req_safe_read(
400400
int fd,
401-
struct io_thread_req * (*request_buffer)[],
401+
struct io_thread_req **request_buffer,
402402
struct io_thread_req **remainder,
403403
int *remainder_size,
404404
int max_recs
@@ -465,7 +465,7 @@ static irqreturn_t ubd_intr(int irq, void *dev)
465465
&irq_remainder, &irq_remainder_size,
466466
UBD_REQ_BUFFER_SIZE)) >= 0) {
467467
for (i = 0; i < len / sizeof(struct io_thread_req *); i++)
468-
ubd_end_request((*irq_req_buffer)[i]);
468+
ubd_end_request(irq_req_buffer[i]);
469469
}
470470

471471
if (len < 0 && len != -EAGAIN)
@@ -1512,7 +1512,7 @@ void *io_thread(void *arg)
15121512
}
15131513

15141514
for (count = 0; count < n/sizeof(struct io_thread_req *); count++) {
1515-
struct io_thread_req *req = (*io_req_buffer)[count];
1515+
struct io_thread_req *req = io_req_buffer[count];
15161516
int i;
15171517

15181518
io_count++;

0 commit comments

Comments
 (0)