From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F51AC4321E for ; Mon, 21 Nov 2022 17:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbiKURp1 (ORCPT ); Mon, 21 Nov 2022 12:45:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230132AbiKURpX (ORCPT ); Mon, 21 Nov 2022 12:45:23 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9534853ECF; Mon, 21 Nov 2022 09:45:21 -0800 (PST) Received: from [10.7.7.5] (unknown [182.253.183.240]) by gnuweeb.org (Postfix) with ESMTPSA id 8E47F816AE; Mon, 21 Nov 2022 17:45:18 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1669052720; bh=dyD0zchae5y2rg9SSls4wz00jK0afhTlcmMVE/acKtM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=K3QMGo6/Up7PCwiWCDLe90Em2kiceIrd2ngcIYlyUZEAagrFXw2qBt+Ut71X+qv9X y1JyDWDFhFBFvVpTnk5wmoIdCp8+p3xljGJHOywiRmTigyViDOCmLr6nibpGs2+6k/ pduLoutvD/hRl9lLTC+vzUD6oRua5lqmoti+wmjuerkdl33nfOl7/Fp7tdr+sjZFzb 1XCkDZrqujN2UFxgxT5Ib5H3L+kZMbW4gxYDChHvWR3rZQMrGs64vongIGC0vJ/Nx0 0eMZyIj5wfBnhT/7UliVoeyQmDllv84jtmKVGk/pI3TV7DOnwFNjGxSiWHIRODRms7 +5BCSwirUM9kA== Message-ID: <2dde9961-b820-c301-6eb7-c5a26309c019@gnuweeb.org> Date: Tue, 22 Nov 2022 00:45:15 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [RFC PATCH v4 2/3] io_uring: add api to set / get napi configuration. To: Stefan Roesch , Facebook Kernel Team Cc: Jens Axboe , Olivier Langlois , netdev Mailing List , io-uring Mailing List , Jakub Kicinski References: <20221121172953.4030697-1-shr@devkernel.io> <20221121172953.4030697-3-shr@devkernel.io> Content-Language: en-US From: Ammar Faizi In-Reply-To: <20221121172953.4030697-3-shr@devkernel.io> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org 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. -- Ammar Faizi