Skip to contentSkip to conversation

Patch for 5.10-stable

PATCH Jens Axboe 3 participants 4 messages May 19, 2022

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

Hi,

Can we get this queued up for 5.10-stable? Thanks!

Signature · 1 line
Jens Axboe

From b1da21187de121e2ed2dc2e0c70d5aabce469691 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 19 May 2022 06:05:27 -0600
Subject: [PATCH] io_uring: always grab file table for deferred statx

Lee reports that there's a use-after-free of the process file table. There's an assumption that we don't need the file table for some variants of statx invocation, but that turns out to be false and we end up with not grabbing a reference for the request even if the deferred execution uses it.

Get rid of the REQ_F_NO_FILE_TABLE optimization for statx, and always grab that reference.

This issues doesn't exist upstream since the native workers got introduced with 5.12.

---
 fs/io_uring.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
fs/io_uring.c +1 -5
index 4330603eae35..3ecf71151fb1 100644
@@ -4252,12 +4252,8 @@ static int io_statx(struct io_kiocb *req, bool force_nonblock)
 	struct io_statx *ctx = &req->statx;
 	int ret;
 
-	if (force_nonblock) {
-		/* only need file table for an actual valid fd */
-		if (ctx->dfd == -1 || ctx->dfd == AT_FDCWD)
-			req->flags |= REQ_F_NO_FILE_TABLE;
+	if (force_nonblock)
 		return -EAGAIN;
-	}
 
 	ret = do_statx(ctx->dfd, ctx->filename, ctx->flags, ctx->mask,
 		       ctx->buffer);
Signature · 1 line
2.35.1
#1 lore raw
Quoted 3 lines · Jens Axboe

Hi,

Can we get this queued up for 5.10-stable? Thanks!

Now queued up, thanks.

greg k-h

author
#2 lore raw
Quoted 6 lines · Greg Kroah-Hartman
Quoted 3 lines · Jens Axboe

Hi,

Can we get this queued up for 5.10-stable? Thanks!

Now queued up, thanks.

Thanks Greg!

Signature · 1 line
Jens Axboe
Tested-by
#3 lore raw
In reply to Jens Axboe
Quoted 19 lines · Jens Axboe

Hi,

Can we get this queued up for 5.10-stable? Thanks!

From b1da21187de121e2ed2dc2e0c70d5aabce469691 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 19 May 2022 06:05:27 -0600
Subject: [PATCH] io_uring: always grab file table for deferred statx

Lee reports that there's a use-after-free of the process file table. There's an assumption that we don't need the file table for some variants of statx invocation, but that turns out to be false and we end up with not grabbing a reference for the request even if the deferred execution uses it.

Get rid of the REQ_F_NO_FILE_TABLE optimization for statx, and always grab that reference.

Quoted 6 lines

This issues doesn't exist upstream since the native workers got introduced with 5.12.

Quoted 22 lines
---
 fs/io_uring.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
fs/io_uring.c +1 -5
index 4330603eae35..3ecf71151fb1 100644
@@ -4252,12 +4252,8 @@ static int io_statx(struct io_kiocb *req, bool force_nonblock)
 	struct io_statx *ctx = &req->statx;
 	int ret;
 
-	if (force_nonblock) {
-		/* only need file table for an actual valid fd */
-		if (ctx->dfd == -1 || ctx->dfd == AT_FDCWD)
-			req->flags |= REQ_F_NO_FILE_TABLE;
+	if (force_nonblock)
 		return -EAGAIN;
-	}
 
 	ret = do_statx(ctx->dfd, ctx->filename, ctx->flags, ctx->mask,
 		       ctx->buffer);
Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog