public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 0/3] check errors in early init
@ 2025-01-31 16:24 Pavel Begunkov
  2025-01-31 16:24 ` [PATCH 1/3] io_uring: propagate req cache creation errors Pavel Begunkov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pavel Begunkov @ 2025-01-31 16:24 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence

Do the diligence of checking if any of the (inicall) io_uring_init()
fail and if so return an error.

Pavel Begunkov (3):
  io_uring: propagate req cache creation errors
  io_uring: propagate io_buffer creation errors
  io_uring: check for iowq alloc_workqueue errors

 io_uring/io_uring.c | 7 +++++++
 1 file changed, 7 insertions(+)

-- 
2.47.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] io_uring: propagate req cache creation errors
  2025-01-31 16:24 [PATCH 0/3] check errors in early init Pavel Begunkov
@ 2025-01-31 16:24 ` Pavel Begunkov
  2025-01-31 16:26   ` Jens Axboe
  2025-01-31 16:24 ` [PATCH 2/3] io_uring: propagate io_buffer " Pavel Begunkov
  2025-01-31 16:24 ` [PATCH 3/3] io_uring: check for iowq alloc_workqueue errors Pavel Begunkov
  2 siblings, 1 reply; 6+ messages in thread
From: Pavel Begunkov @ 2025-01-31 16:24 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence

It's very unlikely, but in theory cache creation can fail during
initcall, so don't forget to return errors back if something goes wrong.

Fixes: 2b188cc1bb857 ("Add io_uring IO interface")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 263e504be4a8b..9335144495299 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3916,6 +3916,9 @@ static int __init io_uring_init(void)
 	req_cachep = kmem_cache_create("io_kiocb", sizeof(struct io_kiocb), &kmem_args,
 				SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT |
 				SLAB_TYPESAFE_BY_RCU);
+	if (!req_cachep)
+		return -ENOMEM;
+
 	io_buf_cachep = KMEM_CACHE(io_buffer,
 					  SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT);
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] io_uring: propagate io_buffer creation errors
  2025-01-31 16:24 [PATCH 0/3] check errors in early init Pavel Begunkov
  2025-01-31 16:24 ` [PATCH 1/3] io_uring: propagate req cache creation errors Pavel Begunkov
@ 2025-01-31 16:24 ` Pavel Begunkov
  2025-01-31 16:24 ` [PATCH 3/3] io_uring: check for iowq alloc_workqueue errors Pavel Begunkov
  2 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2025-01-31 16:24 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence

It's very unlikely, but in theory cache creation can fail during
initcall, so don't forget to return errors back if something goes wrong.

Fixes: b3a4dbc89d402 ("io_uring/kbuf: Use slab for struct io_buffer objects")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 9335144495299..b05580c1a6424 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3921,6 +3921,8 @@ static int __init io_uring_init(void)
 
 	io_buf_cachep = KMEM_CACHE(io_buffer,
 					  SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT);
+	if (!io_buf_cachep)
+		return -ENOMEM;
 
 	iou_wq = alloc_workqueue("iou_exit", WQ_UNBOUND, 64);
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] io_uring: check for iowq alloc_workqueue errors
  2025-01-31 16:24 [PATCH 0/3] check errors in early init Pavel Begunkov
  2025-01-31 16:24 ` [PATCH 1/3] io_uring: propagate req cache creation errors Pavel Begunkov
  2025-01-31 16:24 ` [PATCH 2/3] io_uring: propagate io_buffer " Pavel Begunkov
@ 2025-01-31 16:24 ` Pavel Begunkov
  2 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2025-01-31 16:24 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence

alloc_workqueue() can fail, check the result and return an error back
from io_uring_init() if needed.

Fixes: 73eaa2b583493 ("io_uring: use private workqueue for exit work")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index b05580c1a6424..78a6cc84304f2 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3925,6 +3925,8 @@ static int __init io_uring_init(void)
 		return -ENOMEM;
 
 	iou_wq = alloc_workqueue("iou_exit", WQ_UNBOUND, 64);
+	if (!iou_wq)
+		return -ENOMEM;
 
 #ifdef CONFIG_SYSCTL
 	register_sysctl_init("kernel", kernel_io_uring_disabled_table);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] io_uring: propagate req cache creation errors
  2025-01-31 16:24 ` [PATCH 1/3] io_uring: propagate req cache creation errors Pavel Begunkov
@ 2025-01-31 16:26   ` Jens Axboe
  2025-01-31 16:30     ` Pavel Begunkov
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2025-01-31 16:26 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 1/31/25 9:24 AM, Pavel Begunkov wrote:
> It's very unlikely, but in theory cache creation can fail during
> initcall, so don't forget to return errors back if something goes wrong.

This is why SLAB_PANIC is used, it'll panic if this fails. That's
commonly used for setup/init time kind of setups, where we never
expect any failure to occur. Hence this can never return NULL.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] io_uring: propagate req cache creation errors
  2025-01-31 16:26   ` Jens Axboe
@ 2025-01-31 16:30     ` Pavel Begunkov
  0 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2025-01-31 16:30 UTC (permalink / raw)
  To: Jens Axboe, io-uring

On 1/31/25 16:26, Jens Axboe wrote:
> On 1/31/25 9:24 AM, Pavel Begunkov wrote:
>> It's very unlikely, but in theory cache creation can fail during
>> initcall, so don't forget to return errors back if something goes wrong.
> 
> This is why SLAB_PANIC is used, it'll panic if this fails. That's
> commonly used for setup/init time kind of setups, where we never
> expect any failure to occur. Hence this can never return NULL.

Yeah, missed it, thanks

-- 
Pavel Begunkov


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-01-31 16:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-31 16:24 [PATCH 0/3] check errors in early init Pavel Begunkov
2025-01-31 16:24 ` [PATCH 1/3] io_uring: propagate req cache creation errors Pavel Begunkov
2025-01-31 16:26   ` Jens Axboe
2025-01-31 16:30     ` Pavel Begunkov
2025-01-31 16:24 ` [PATCH 2/3] io_uring: propagate io_buffer " Pavel Begunkov
2025-01-31 16:24 ` [PATCH 3/3] io_uring: check for iowq alloc_workqueue errors Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox