diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-04-01 10:55:04 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-04-01 17:21:18 +0200 |
commit | 696ee88a7c50f96573f98aa76cc74286033140c1 (patch) | |
tree | b215f2544b7f3c95374a7a1ebaa85262296d05e5 /fs/io-wq.c | |
parent | io_uring: don't mark S_ISBLK async work as unbounded (diff) | |
download | linux-696ee88a7c50f96573f98aa76cc74286033140c1.tar.xz linux-696ee88a7c50f96573f98aa76cc74286033140c1.zip |
io_uring/io-wq: protect against sprintf overflow
task_pid may be large enough to not fit into the left space of
TASK_COMM_LEN-sized buffers and overflow in sprintf. We not so care
about uniqueness, so replace it with safer snprintf().
Reported-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/1702c6145d7e1c46fbc382f28334c02e1a3d3994.1617267273.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io-wq.c')
-rw-r--r-- | fs/io-wq.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/io-wq.c b/fs/io-wq.c index 7434eb40ca8c..433c4d3c3c1c 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -484,7 +484,7 @@ static int io_wqe_worker(void *data) worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING); io_wqe_inc_running(worker); - sprintf(buf, "iou-wrk-%d", wq->task_pid); + snprintf(buf, sizeof(buf), "iou-wrk-%d", wq->task_pid); set_task_comm(current, buf); while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)) { @@ -711,7 +711,7 @@ static int io_wq_manager(void *data) char buf[TASK_COMM_LEN]; int node; - sprintf(buf, "iou-mgr-%d", wq->task_pid); + snprintf(buf, sizeof(buf), "iou-mgr-%d", wq->task_pid); set_task_comm(current, buf); do { |