Skip to contentSkip to conversation

buffer overflow in io_sq_thread()

DISCUSSION Alexey Dobriyan 3 participants 3 messages Mar 31, 2021 – Apr 1, 2021 io_uring

lore
Share & tools
lore
#0 lore raw

The code below will overflow because TASK_COMM_LEN is 16 but PID can be as large as 1 billion which is 10 digit number.

Currently not even Fedora ships pid_max that large but still...

Alexey

static int io_sq_thread(void *data)

{
        struct io_sq_data *sqd = data;
        struct io_ring_ctx *ctx;
        unsigned long timeout = 0;
        char buf[TASK_COMM_LEN];
        DEFINE_WAIT(wait);

        sprintf(buf, "iou-sqp-%d", sqd->task_pid);
#1 lore raw
Quoted 4 lines · Alexey Dobriyan

The code below will overflow because TASK_COMM_LEN is 16 but PID can be as large as 1 billion which is 10 digit number.

Currently not even Fedora ships pid_max that large but still...

And is safer limited in any case. Thanks

Quoted 13 lines

Alexey

static int io_sq_thread(void *data)

{
        struct io_sq_data *sqd = data;
        struct io_ring_ctx *ctx;
        unsigned long timeout = 0;
        char buf[TASK_COMM_LEN];
        DEFINE_WAIT(wait);

        sprintf(buf, "iou-sqp-%d", sqd->task_pid);
Signature · 1 line
Pavel Begunkov
#2 lore raw

Am 01.04.21 um 10:51 schrieb Pavel Begunkov:

Quoted 20 lines · Alexey Dobriyan
Quoted 4 lines

The code below will overflow because TASK_COMM_LEN is 16 but PID can be as large as 1 billion which is 10 digit number.

Currently not even Fedora ships pid_max that large but still...

And is safer limited in any case. Thanks

Quoted 12 lines

Alexey

static int io_sq_thread(void *data)

{
        struct io_sq_data *sqd = data;
        struct io_ring_ctx *ctx;
        unsigned long timeout = 0;
        char buf[TASK_COMM_LEN];
        DEFINE_WAIT(wait);

        sprintf(buf, "iou-sqp-%d", sqd->task_pid);

I have patches for this see
https://lore.kernel.org/io-uring/[email protected]/T/#m9a9707c76e0ca73b54676b5d0fe198587b36c1b4

As there's no urgent problem in 5.12 I'll repost them for 5.13...

metze