From 7fcbf2e6e70746e36f2d4959f77c579aa1f21afe Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 3 Mar 2020 15:28:17 -0700 Subject: [PATCH] io_uring: add end-of-bits marker and build time verify it to #28170604 commit 84557871f2ff332edd445d70349c8724c313c683 upstream Not easy to tell if we're going over the size of bits we can shove in req->flags, so add an end-of-bits marker and a BUILD_BUG_ON() check for it. Signed-off-by: Jens Axboe Acked-by: Joseph Qi Signed-off-by: Xiaoguang Wang --- fs/io_uring.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index 5228cee2920c..5505789aed5a 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -513,6 +513,9 @@ enum { REQ_F_OVERFLOW_BIT, REQ_F_POLLED_BIT, REQ_F_BUFFER_SELECTED_BIT, + + /* not a real bit, just to check we're not overflowing the space */ + __REQ_F_LAST_BIT, }; enum { @@ -8039,6 +8042,7 @@ static int __init io_uring_init(void) BUILD_BUG_SQE_ELEM(44, __s32, splice_fd_in); BUILD_BUG_ON(ARRAY_SIZE(io_op_defs) != IORING_OP_LAST); + BUILD_BUG_ON(__REQ_F_LAST_BIT >= 8 * sizeof(int)); req_cachep = KMEM_CACHE(io_kiocb, SLAB_HWCACHE_ALIGN | SLAB_PANIC); return 0; }; -- GitLab