diff mbox series

[for-next,1/1] io_uring: limit registration w/ SINGLE_ISSUER

Message ID f52a6a9c8a8990d4a831f73c0571e7406aac2bba.1664237592.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series [for-next,1/1] io_uring: limit registration w/ SINGLE_ISSUER | expand

Commit Message

Pavel Begunkov Sept. 27, 2022, 12:13 a.m. UTC
IORING_SETUP_SINGLE_ISSUER restricts what tasks can submit requests.
Extend it to registration as well, so non-owning task can't do
registrations. It's not necessary at the moment but might be useful in
the future.

Cc: <stable@vger.kernel.org> # 6.0
Fixes: 97bbdc06a444 ("io_uring: add IORING_SETUP_SINGLE_ISSUER")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/io_uring.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jens Axboe Sept. 27, 2022, 12:43 a.m. UTC | #1
On Tue, 27 Sep 2022 01:13:30 +0100, Pavel Begunkov wrote:
> IORING_SETUP_SINGLE_ISSUER restricts what tasks can submit requests.
> Extend it to registration as well, so non-owning task can't do
> registrations. It's not necessary at the moment but might be useful in
> the future.
> 
> 

Applied, thanks!

[1/1] io_uring: limit registration w/ SINGLE_ISSUER
      commit: 567a9ba00f144a1d2ec291e5188043c2db8c2b77

Best regards,
diff mbox series

Patch

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 73ac6948debb..3f6eb3cf07ac 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3890,6 +3890,9 @@  static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
 	if (WARN_ON_ONCE(percpu_ref_is_dying(&ctx->refs)))
 		return -ENXIO;
 
+	if (ctx->submitter_task && ctx->submitter_task != current)
+		return -EEXIST;
+
 	if (ctx->restricted) {
 		if (opcode >= IORING_REGISTER_LAST)
 			return -EINVAL;