[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <qvqwwn7o3zlv.fsf@dev0134.prn3.facebook.com>
Date: Mon, 21 Nov 2022 10:56:39 -0800
From: Stefan Roesch <shr@...kernel.io>
To: Ammar Faizi <ammarfaizi2@...weeb.org>
Cc: Facebook Kernel Team <kernel-team@...com>,
Jens Axboe <axboe@...nel.dk>,
Olivier Langlois <olivier@...llion01.com>,
netdev Mailing List <netdev@...r.kernel.org>,
io-uring Mailing List <io-uring@...r.kernel.org>,
Jakub Kicinski <kuba@...nel.org>
Subject: Re: [RFC PATCH v4 2/3] io_uring: add api to set / get napi
configuration.
Ammar Faizi <ammarfaizi2@...weeb.org> writes:
> On 11/22/22 12:29 AM, Stefan Roesch wrote:
>> +static int io_register_napi(struct io_ring_ctx *ctx, void __user *arg)
>> +{
>> +#ifdef CONFIG_NET_RX_BUSY_POLL
>> + const struct io_uring_napi curr = {
>> + .busy_poll_to = ctx->napi_busy_poll_to,
>> + };
>> + struct io_uring_napi *napi;
>> +
>> + napi = memdup_user(arg, sizeof(*napi));
>> + if (IS_ERR(napi))
>> + return PTR_ERR(napi);
>> +
>> + WRITE_ONCE(ctx->napi_busy_poll_to, napi->busy_poll_to);
>> +
>> + kfree(napi);
>> +
>> + if (copy_to_user(arg, &curr, sizeof(curr)))
>> + return -EFAULT;
>> +
>> + return 0;
>
> Considering:
>
> 1) `struct io_uring_napi` is 16 bytes in size.
>
> 2) The lifetime of `struct io_uring_napi *napi;` is brief.
>
> There is no need to use memdup_user() and kfree(). You can place it
> on the stack and use copy_from_user() instead.
The next version of the patch will use copy_from_user.
Powered by blists - more mailing lists