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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22409C5475B for ; Thu, 29 Feb 2024 00:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9nAu8Vwz6bcfEbtdiqC7B//lIsoYQp7CjOuHnqlYErc=; b=NgRE2PDJRbMRzH kY7ZqeySKnLBDSBuTlmO+tGE6DBpN6YBr023NZ1SEqpKx4qwGBu6GENBE2zi9G68VBEpu0bTo9oXk 6ySl3FMuJxNsgHEMmDEKmM+Rq0xguCHKuYw0X8nzuX5tZ/gTfvsGeakdKgv7C7CjHehthlZI6kg7J 0ASkFhzW1utYrN0HpM6IPTqOWm8xJp3lZQvYfYZVx3guM9vLmRcziH9FZ/DluI6kQS6E+oqaqCbnq V2yayFAJUWUL2eHb9DUbA5U2ArJvHDpncjRhQoUEUHArunBNvZnObRg+sdi1CFbctGV3H7JzK8AGa OwvEuftfciOv3ib3t3Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfUie-0000000BUAm-1AQO; Thu, 29 Feb 2024 00:56:16 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfUia-0000000BU8X-282y for linux-arm-kernel@lists.infradead.org; Thu, 29 Feb 2024 00:56:14 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DEE2F61648; Thu, 29 Feb 2024 00:56:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6112C433C7; Thu, 29 Feb 2024 00:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709168171; bh=8INiMNb8bGe9aH8MD1xrZEujm+XkODnaql/+pLNknt0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Dtr4muXV2rTHbzpPr88K48luIP2g5EU4EX+96sQpgs2qtpPNDRTn8rPggkUSD2ZfG 48BtLthfzFgdoGiQGSW+PLQjm11pds7mKoPGIR3Rw/7bEKrfufh4/jMX4q/Z8g5tAl oZTnu3DWuw1pvw9su+znP5UltSVjQB+QRC7dqkr1zFT8CYpE3nijeKnOMri4ozteck awembGWUfpqTpg/GNSa7/gHIq14jzb43s58g+58dZoM6Os779mvmpqmvCu1B9BC7Ms TKaGc1dS8DssrFm+AArg8gWcpHiw6UtNWSLatVqVUQ4JwwprQnoAH1ePVxfwbp3zaf XsNBq1wjQWgtQ== Date: Wed, 28 Feb 2024 16:56:09 -0800 From: Jakub Kicinski To: Kees Cook Cc: Andy Shevchenko , Vinod Koul , Linus Walleij , Jonathan Cameron , Mark Brown , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-spi@vger.kernel.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen , "David S. Miller" , Eric Dumazet , Paolo Abeni , "Gustavo A. R. Silva" Subject: Re: [PATCH v4 7/8] net-device: Use new helpers from overflow.h in netdevice APIs Message-ID: <20240228165609.06f5254a@kernel.org> In-Reply-To: <202402281554.C1CEEF744@keescook> References: <20240228204919.3680786-1-andriy.shevchenko@linux.intel.com> <20240228204919.3680786-8-andriy.shevchenko@linux.intel.com> <202402281341.AC67EB6E35@keescook> <20240228144148.5c227487@kernel.org> <202402281554.C1CEEF744@keescook> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_165612_710593_F7BF8940 X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 28 Feb 2024 16:01:49 -0800 Kees Cook wrote: > So, I found several cases where struct net_device is included in the > middle of another structure, which makes my proposal more awkward. But I > also don't understand why it's in the _middle_. Shouldn't it always be > at the beginning (with priv stuff following it?) > Quick search and examined manually: git grep 'struct net_device [a-z0-9_]*;' > > struct rtw89_dev > struct ath10k > etc. Ugh, yes, the (ab)use of NAPI. > Some even have two included (?) And some seem to be cargo-culted from out-of-tree code and are unused :S > But I still like the idea -- Gustavo has been solving these cases with > having two structs, e.g.: > > struct net_device { > ...unchanged... > }; > > struct net_device_alloc { > struct net_device dev; > u32 priv_size; > u8 priv_data[] __counted_by(priv_size) __aligned(NETDEV_ALIGN); > }; > > And internals can use struct net_device_alloc... That's... less pretty. I'd rather push the ugly into the questionable users. Make them either allocate the netdev dynamically and store a pointer, or move the netdev to the end of the struct. But yeah, that's a bit of a cleanup :( _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel