]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ubd: Use pointer-to-pointers for io_thread_req arrays
authorKees Cook <kees@kernel.org>
Mon, 23 Feb 2026 21:43:45 +0000 (13:43 -0800)
committerKees Cook <kees@kernel.org>
Mon, 23 Feb 2026 22:35:16 +0000 (14:35 -0800)
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: 69050f8d6d07 ("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>
arch/um/drivers/ubd_kern.c

index 012b2bcaa8a07b6bd6ea35e49eeebce145dd244d..20fc33300a955376aede1f96b3e61ec7c5a1797d 100644 (file)
@@ -69,11 +69,11 @@ struct io_thread_req {
 };
 
 
-static struct io_thread_req * (*irq_req_buffer)[];
+static struct io_thread_req **irq_req_buffer;
 static struct io_thread_req *irq_remainder;
 static int irq_remainder_size;
 
-static struct io_thread_req * (*io_req_buffer)[];
+static struct io_thread_req **io_req_buffer;
 static struct io_thread_req *io_remainder;
 static int io_remainder_size;
 
@@ -398,7 +398,7 @@ static int thread_fd = -1;
 
 static int bulk_req_safe_read(
        int fd,
-       struct io_thread_req * (*request_buffer)[],
+       struct io_thread_req **request_buffer,
        struct io_thread_req **remainder,
        int *remainder_size,
        int max_recs
@@ -465,7 +465,7 @@ static irqreturn_t ubd_intr(int irq, void *dev)
                        &irq_remainder, &irq_remainder_size,
                        UBD_REQ_BUFFER_SIZE)) >= 0) {
                for (i = 0; i < len / sizeof(struct io_thread_req *); i++)
-                       ubd_end_request((*irq_req_buffer)[i]);
+                       ubd_end_request(irq_req_buffer[i]);
        }
 
        if (len < 0 && len != -EAGAIN)
@@ -1512,7 +1512,7 @@ void *io_thread(void *arg)
                }
 
                for (count = 0; count < n/sizeof(struct io_thread_req *); count++) {
-                       struct io_thread_req *req = (*io_req_buffer)[count];
+                       struct io_thread_req *req = io_req_buffer[count];
                        int i;
 
                        io_count++;