Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1163321rwd; Thu, 25 May 2023 08:48:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5l59fyvWuTCteX3JUrXM9BIk/4V6KygExwWyOANGJ10Dp5nehXQsuodQs2iXr5JjHyj03y X-Received: by 2002:a05:6a20:3947:b0:10c:7916:f9f6 with SMTP id r7-20020a056a20394700b0010c7916f9f6mr11682641pzg.52.1685029730254; Thu, 25 May 2023 08:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685029730; cv=none; d=google.com; s=arc-20160816; b=LIpqBzUnlmold6syFj84Ta/ml0RoEzumF4P4LLkR0FZzhflj1jVzFP6e7KB0UaywJr JSt54x2PvyQOXfZpB41NB72yhUNt/jwooq04FM7P1V3i66eFOlJN+svE/ZYEE1cDXxIE ywiRQtx71iWes3/6iiRFE8sm4QbWN+f5lt5ezuFUaG5W3kYg085tF6Db3IJ9MVj1OpO3 9HpSNlTp3zovamzNLmj54LFndXCIPgkJPASocv8DiB0Y+3VUHLLtcPZAegYHu7C2trBq cmz6EffDBMxUuBbHRti/Mwu2x8PGE5Y844jc6oDvMfPryFdqZU/m9+/1Vp2iZqKDXCRR Migg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=UzHd8WpeVxHENgkCuRtLgYhIRjwiUH/W3moODWjwaEs=; b=ju1lDdccLUuDtjgrLnKCqMUzDOlaDP6IOr+YGLeMImGPqIjNyiP6jzHT27ZHWD4YNY GI8V/YsHIGvYnEDQnWgksgWrogd72cPBEVoz45Prc1W4NBBVFje04nntE5X0HCVl1sMy Ttxdc9d14bjjF+/RnhSekjEoNS0cPnyDGNSrb5aRjPlb5IKihI5SgNunISYFoelqXtII 3+zKijMHgnRU7bUZeFc15HGX0QJ/z2KO27lwwar2YIZUL2ju0gD+V7UwKNFeAXNuMUKG wgy1vHQVAXaweYG9YP1hBupUoKWRT1NEpct1M9QkO6H4kPTkgxaa9+OrZCNFt7PDJOLv 6zFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KehClflj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h18-20020a17090aa89200b002532933832csi1846415pjq.78.2023.05.25.08.48.35; Thu, 25 May 2023 08:48:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KehClflj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbjEYPeS (ORCPT + 99 others); Thu, 25 May 2023 11:34:18 -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 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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. >