public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Linus Torvalds <[email protected]>
Cc: io-uring <[email protected]>, Keith Busch <[email protected]>
Subject: Re: [GIT PULL] io_uring fixes for 6.0-rc1
Date: Fri, 12 Aug 2022 16:19:06 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 8/12/22 4:11 PM, Jens Axboe wrote:
> For that one suggestion, I suspect this will fix your issue. It's
> obviously not a thing of beauty...

While it did fix compile, it's also wrong obviously as io_rw needs to be
in that union... Thanks Keith, again!

diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
index 677a25d44d7f..7ef7cffff0d2 100644
--- a/include/linux/io_uring_types.h
+++ b/include/linux/io_uring_types.h
@@ -481,14 +481,31 @@ struct io_cqe {
 	};
 };
 
+struct io_rw {
+	/* NOTE: kiocb has the file as the first member, so don't do it here */
+	struct kiocb			kiocb;
+	u64				addr;
+	u32				len;
+	rwf_t				flags;
+};
+
 /*
  * Each request type overlays its private data structure on top of this one.
- * They must not exceed this one in size.
+ * They must not exceed this one in size. We must ensure that this is big
+ * enough to hold any command type. Currently io_rw includes struct kiocb,
+ * which is marked as having a random layout for security reasons. This can
+ * cause it to grow in size if the layout ends up adding more holes or padding.
+ * Unionize io_cmd_data with io_rw to work-around this issue.
  */
 struct io_cmd_data {
-	struct file		*file;
-	/* each command gets 56 bytes of data */
-	__u8			data[56];
+	union {
+		struct {
+			struct file		*file;
+			/* each command gets 56 bytes of data */
+			__u8			data[56];
+		};
+		struct io_rw pad;
+	};
 };
 
 static inline void io_kiocb_cmd_sz_check(size_t cmd_sz)
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 1babd77da79c..1c3a5da9dcdc 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -20,14 +20,6 @@
 #include "rsrc.h"
 #include "rw.h"
 
-struct io_rw {
-	/* NOTE: kiocb has the file as the first member, so don't do it here */
-	struct kiocb			kiocb;
-	u64				addr;
-	u32				len;
-	rwf_t				flags;
-};
-
 static inline bool io_file_supports_nowait(struct io_kiocb *req)
 {
 	return req->flags & REQ_F_SUPPORT_NOWAIT;

-- 
Jens Axboe


  reply	other threads:[~2022-08-12 22:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 12:46 [GIT PULL] io_uring fixes for 6.0-rc1 Jens Axboe
2022-08-12 20:28 ` Linus Torvalds
2022-08-12 20:44   ` Jens Axboe
2022-08-12 21:01     ` Jens Axboe
2022-08-12 21:08       ` Jens Axboe
2022-08-12 21:34         ` Jens Axboe
2022-08-12 21:43           ` Linus Torvalds
2022-08-12 21:53             ` Jens Axboe
2022-08-12 21:54             ` Linus Torvalds
2022-08-12 22:01               ` Linus Torvalds
2022-08-12 22:16                 ` Jens Axboe
2022-08-12 22:11               ` Jens Axboe
2022-08-12 22:19                 ` Jens Axboe [this message]
2022-08-12 22:23                   ` Keith Busch
2022-08-12 22:25                     ` Jens Axboe
2022-08-12 22:27                       ` Jens Axboe
2022-08-12 22:35                     ` Linus Torvalds
2022-08-12 22:38                       ` Jens Axboe
2022-08-12 22:52                         ` Linus Torvalds
2022-08-12 22:55                           ` Jens Axboe
2022-08-12 21:37         ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2022-08-11  1:01 Jens Axboe
2022-08-11 14:35 ` Jens Axboe
2022-08-13 21:48 ` pr-tracker-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox