|
Gabriel Krisman Bertazi |
e53cfa |
From e25cb3f0f70e18fb13128e16a16075fe271ac063 Mon Sep 17 00:00:00 2001
|
|
Gabriel Krisman Bertazi |
e53cfa |
From: Gabriel Krisman Bertazi <krisman@suse.de>
|
|
Gabriel Krisman Bertazi |
e53cfa |
Date: Mon, 1 May 2023 11:49:09 -0400
|
|
Gabriel Krisman Bertazi |
e53cfa |
Subject: [PATCH] io_uring: prevent race on registering fixed files
|
|
Gabriel Krisman Bertazi |
e53cfa |
Patch-mainline: Never, specific to 15SP3
|
|
Gabriel Krisman Bertazi |
704a6c |
References: bsc#1210414 CVE-2023-1872
|
|
Gabriel Krisman Bertazi |
e53cfa |
|
|
Gabriel Krisman Bertazi |
e53cfa |
in 5.3, io_sqe_files_unregister is called without holding the io_uring ctx lock
|
|
Gabriel Krisman Bertazi |
e53cfa |
when in sqpoll,which means it can race with the io_sqe_files_unregister. This
|
|
Gabriel Krisman Bertazi |
e53cfa |
was fixed in commit 8a4955ff1cca7d4da480774034a16e7c28bafec8 ("io_uring:
|
|
Gabriel Krisman Bertazi |
e53cfa |
sqthread should grab ctx->uring_lock for submissions"), but this has quite a few
|
|
Gabriel Krisman Bertazi |
e53cfa |
dependencies that we don't want to carry in SP3.
|
|
Gabriel Krisman Bertazi |
e53cfa |
|
|
Gabriel Krisman Bertazi |
e53cfa |
This version, instead, only acquires the lock prior to registering the files in
|
|
Gabriel Krisman Bertazi |
e53cfa |
the sqpoll path and releases right after, which should be safe todo and doesn't
|
|
Gabriel Krisman Bertazi |
e53cfa |
add extra dependencies.
|
|
Gabriel Krisman Bertazi |
e53cfa |
|
|
Gabriel Krisman Bertazi |
e53cfa |
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
|
|
Gabriel Krisman Bertazi |
e53cfa |
---
|
|
Gabriel Krisman Bertazi |
e53cfa |
fs/io_uring.c | 8 ++++++++
|
|
Gabriel Krisman Bertazi |
e53cfa |
1 file changed, 8 insertions(+)
|
|
Gabriel Krisman Bertazi |
e53cfa |
|
|
Gabriel Krisman Bertazi |
e53cfa |
diff --git a/fs/io_uring.c b/fs/io_uring.c
|
|
Gabriel Krisman Bertazi |
e53cfa |
index 2c2803f9d936..66d3a2420aaf 100644
|
|
Gabriel Krisman Bertazi |
e53cfa |
--- a/fs/io_uring.c
|
|
Gabriel Krisman Bertazi |
e53cfa |
+++ b/fs/io_uring.c
|
|
Gabriel Krisman Bertazi |
e53cfa |
@@ -2241,7 +2241,15 @@ static void io_submit_sqe(struct io_ring_ctx *ctx, struct sqe_submit *s,
|
|
Gabriel Krisman Bertazi |
e53cfa |
goto err;
|
|
Gabriel Krisman Bertazi |
e53cfa |
}
|
|
Gabriel Krisman Bertazi |
e53cfa |
|
|
Gabriel Krisman Bertazi |
e53cfa |
+ /*
|
|
Gabriel Krisman Bertazi |
e53cfa |
+ * SLE15-SP3: Guard file table insertion from racing with
|
|
Gabriel Krisman Bertazi |
e53cfa |
+ * io_sqe_files_unregister. The SQPOLL path can get here unlocked.
|
|
Gabriel Krisman Bertazi |
e53cfa |
+ */
|
|
Gabriel Krisman Bertazi |
e53cfa |
+ if (s->needs_lock)
|
|
Gabriel Krisman Bertazi |
e53cfa |
+ mutex_lock(&ctx->uring_lock);
|
|
Gabriel Krisman Bertazi |
e53cfa |
ret = io_req_set_file(ctx, s, state, req);
|
|
Gabriel Krisman Bertazi |
e53cfa |
+ if (s->needs_lock)
|
|
Gabriel Krisman Bertazi |
e53cfa |
+ mutex_unlock(&ctx->uring_lock);
|
|
Gabriel Krisman Bertazi |
e53cfa |
if (unlikely(ret)) {
|
|
Gabriel Krisman Bertazi |
e53cfa |
err_req:
|
|
Gabriel Krisman Bertazi |
e53cfa |
io_free_req(req);
|
|
Gabriel Krisman Bertazi |
e53cfa |
--
|
|
Gabriel Krisman Bertazi |
e53cfa |
2.40.0
|
|
Gabriel Krisman Bertazi |
e53cfa |
|