diff options
author | Jens Axboe <axboe@kernel.dk> | 2022-05-18 15:34:37 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-05-18 16:21:30 -0600 |
commit | 2fcabce2d7d34f69a888146dab15b36a917f09d4 (patch) | |
tree | 304aa433253eb4c6bb57eca34a895993506b5480 /fs | |
parent | 1d0dbbfa282d9be57792e3b5827dc57b010181ee (diff) | |
download | linux-2fcabce2d7d34f69a888146dab15b36a917f09d4.tar.bz2 |
io_uring: disallow mixed provided buffer group registrations
It's nonsensical to register a provided buffer ring, if a classic
provided buffer group with the same ID exists. Depending on the order of
which we decide what type to pick, the other type will never get used.
Explicitly disallow it and return an error if this is attempted.
Fixes: c7fb19428d67 ("io_uring: add support for ring mapped supplied buffers")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/io_uring.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 8fc3dd49bc04..0bc5fbf64e49 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -12157,9 +12157,11 @@ static int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg) } bl = io_buffer_get_list(ctx, reg.bgid); - if (bl && bl->buf_nr_pages) - return -EEXIST; - if (!bl) { + if (bl) { + /* if mapped buffer ring OR classic exists, don't allow */ + if (bl->buf_nr_pages || !list_empty(&bl->buf_list)) + return -EEXIST; + } else { bl = kzalloc(sizeof(*bl), GFP_KERNEL); if (!bl) return -ENOMEM; |