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 5AC62C77B7E for ; Thu, 25 May 2023 15:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241729AbjEYPeT (ORCPT ); Thu, 25 May 2023 11:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233645AbjEYPeQ (ORCPT ); Thu, 25 May 2023 11:34:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B6C1198; Thu, 25 May 2023 08:34:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 950BC611AA; Thu, 25 May 2023 15:34:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11C46C433D2; Thu, 25 May 2023 15:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685028854; bh=ZwxDw4oLnHr9NVa2Db8a36we5S0GgqD9byINGJspxSk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=KehClfljd08SNiuPE4jni76oBuDKLXGUmANCqL7/UO6wUHMuyIm+n6ggIVVhoUlmY LREtu62b1a1RCt93q7jbljeXRCl9QNxYgWMn4GUm577jivEdaP/AXvOIs8fJc35k0R W5VQNhj/k4TlaFwOnpY2sTmJ/dVZpS509wvLrM8BojgLntvl5xUQq34Doi9w1Lty+9 9MmOX8aaMLPUqgeAAdpNvzF0oKVdnzkrCUvtq90WqfMlNODzJgdZ7DNKOuWG1krc+g Km06GOnkf69sxnPQTjBzhzozkwkVi41IYH2B5rC+ZVAwySJNZ5I31mHb7vj28Gs+IR 8RMVYyqfndX+g== Message-ID: Date: Thu, 25 May 2023 09:34:12 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH net-next v3] net: ioctl: Use kernel memory on protocol ioctl callbacks Content-Language: en-US To: Willem de Bruijn , Breno Leitao Cc: Remi Denis-Courmont , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexander Aring , Stefan Schmidt , Miquel Raynal , Matthieu Baerts , Mat Martineau , Marcelo Ricardo Leitner , Xin Long , leit@fb.com, axboe@kernel.dk, asml.silence@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.linux.dev, linux-sctp@vger.kernel.org References: <20230525125503.400797-1-leitao@debian.org> From: David Ahern In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/25/23 9:05 AM, Willem de Bruijn wrote: >> +/* A wrapper around sock ioctls, which copies the data from userspace >> + * (depending on the protocol/ioctl), and copies back the result to userspace. >> + * The main motivation for this function is to pass kernel memory to the >> + * protocol ioctl callbacks, instead of userspace memory. >> + */ >> +int sk_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) >> +{ >> + int rc = 1; >> + >> + if (ipmr_is_sk(sk)) >> + rc = ipmr_sk_ioctl(sk, cmd, arg); >> + else if (ip6mr_is_sk(sk)) >> + rc = ip6mr_sk_ioctl(sk, cmd, arg); >> + else if (phonet_is_sk(sk)) >> + rc = phonet_sk_ioctl(sk, cmd, arg); > > I don't understand what this buys us vs testing the sk_family, > sk_protocol and cmd here. To keep protocol specific code out of core files is the reason I suggested it. > > It introduces even deeper dependencies on the protocol specific > header files. And the CONFIG issues that result from that. And it > adds a bunch of wrappers that are only used once. >