Skip to contentSkip to conversation

io_uring: Fix a read of ununitialized pointer tctx

PATCH In review Colin King 2 participants 2 messages Sep 3, 2021

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 io_uring: Fix a read of ununitialized pointer tctx

From: Colin Ian King <[email protected]>

In the unlikely case where ctx->flags & IORING_SETUP_SQPOLL is true and sqd is NULL the pointer tctx is not assigned a valid value and can contain a garbage value when it is dereferenced. Fix this by initializing it to NULL.

Addresses-Coverity: ("Uninitialized pointer read")

Fixes 9e30726065ea ("io_uring: ensure IORING_REGISTER_IOWQ_MAX_WORKERS works with SQPOLL")
---
 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
index 132dd38e89ce..843362bebd8c 100644
@@ -10525,7 +10525,7 @@ static int io_register_iowq_max_workers(struct io_ring_ctx *ctx,
 					void __user *arg)
 {
 	struct io_sq_data *sqd = NULL;
-	struct io_uring_task *tctx;
+	struct io_uring_task *tctx = NULL;
 	__u32 new_count[2];
 	int i, ret;
 
Signature · 1 line
2.32.0
maintainer
#1 lore raw
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

In the unlikely case where ctx->flags & IORING_SETUP_SQPOLL is true and sqd is NULL the pointer tctx is not assigned a valid value and can contain a garbage value when it is dereferenced. Fix this by initializing it to NULL.

Doh - thanks, I folded this one in.

Signature · 1 line
Jens Axboe