* [PATCH] io_uring: Replace kzalloc() + copy_from_user() with memdup_user()
@ 2025-09-05 10:18 Thorsten Blum
2025-09-08 14:22 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-09-05 10:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: Thorsten Blum, io-uring, linux-kernel
Replace kzalloc() followed by copy_from_user() with memdup_user() to
improve and simplify io_probe().
No functional changes intended.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
io_uring/register.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/io_uring/register.c b/io_uring/register.c
index a59589249fce..306252f11475 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -46,13 +46,9 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg,
nr_args = IORING_OP_LAST;
size = struct_size(p, ops, nr_args);
- p = kzalloc(size, GFP_KERNEL);
- if (!p)
- return -ENOMEM;
-
- ret = -EFAULT;
- if (copy_from_user(p, arg, size))
- goto out;
+ p = memdup_user(arg, size);
+ if (IS_ERR(p))
+ return PTR_ERR(p);
ret = -EINVAL;
if (memchr_inv(p, 0, size))
goto out;
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] io_uring: Replace kzalloc() + copy_from_user() with memdup_user()
2025-09-05 10:18 [PATCH] io_uring: Replace kzalloc() + copy_from_user() with memdup_user() Thorsten Blum
@ 2025-09-08 14:22 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2025-09-08 14:22 UTC (permalink / raw)
To: Thorsten Blum; +Cc: io-uring, linux-kernel
On Fri, 05 Sep 2025 12:18:17 +0200, Thorsten Blum wrote:
> Replace kzalloc() followed by copy_from_user() with memdup_user() to
> improve and simplify io_probe().
>
> No functional changes intended.
>
>
Applied, thanks!
[1/1] io_uring: Replace kzalloc() + copy_from_user() with memdup_user()
commit: 7b0604d77a41192316347618cce1d9c795613adb
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-08 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-05 10:18 [PATCH] io_uring: Replace kzalloc() + copy_from_user() with memdup_user() Thorsten Blum
2025-09-08 14:22 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox