Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp184746rbe; Wed, 28 Feb 2024 17:02:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUWlNBMdsUKeU3UZde6CPMQhSTiYpFOxSvHkKdzC8cYm7PhhwBmfOQ+rGfNOsraNhcaLwXbxuLY/iINuVwiOAnr+V/f42LqO+64TCcd6Q== X-Google-Smtp-Source: AGHT+IEDlouihkp5u7L1Vk0udqsHCy6Dyz63pfv/EhEubpywech9BherNpOS3MkTjeByTR28nk5I X-Received: by 2002:a17:90a:8b02:b0:299:464c:c9fc with SMTP id y2-20020a17090a8b0200b00299464cc9fcmr700545pjn.45.1709168575004; Wed, 28 Feb 2024 17:02:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709168574; cv=pass; d=google.com; s=arc-20160816; b=L1rfWbv0gNVQwM3MZ3Vt/RfjVSibHkVWt5E9mUkuSSLDqMnN3XJ1Nfy07nr4+zo2Q1 ufxSULjLSXfv+28F+Inmx5Y8ZQ9jXz4TCZSCEzfoKAnP1HMFA4kFSFDqLGhDZqEwo1fI lGbPGctRySBKlawPmPjFqAoVzHkOoVBcP682GbAk8zo/UONGXcvDxACO9vmKR64JnpzN sL2jBvLodyfZw4Me0yxOuVwOWuF70GZ7KX0uNB+mZalluH+8T+UWjwp4eoiPJTOoWZi2 OmLARm1aKftLV9r3gdMj8sFJxFr330DIIbITwgxwq/Uf4e3tUdMJLMzr4tFatp8UhdC3 r2lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=3VZ+5l9EO3ybuvy/GPyumjGZjU8MKGzO5OeXTL30v08=; fh=I+wNhN54JXqsP8tW5AKFfPYq5lqJ5wvTW68JrBsFGdg=; b=U1GPttgSSH4KlBsAtDNkM6zURTloU9uS3m3LQroBLL1K9byk07q82ltgKF3jVPJCbV W0b/frw3XBLGuX6Bk5g2RdZQwM4lcwY35CNTeYeIuQ3R4ZtcpWkKDV5k1DBl6MPy02at Xq7ruOihugvGashwxAyKgnVCWW2d/IaamIcDtQBuuakCY9f8z3B0khUnRyy3Rc+rEUSC NTYErjIk2pmml03STe9Y1mFdVpm5VH08lmAMF2rOjLDIoEVLHFOOrQ1EMbTWM70YTY0C uLU68lsaFRelwthhF/dI/INF6OdQgKGwvpTGJILrE/njd0f7UUAtNmKzHE6nGFYJfGM5 nTRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dtr4muXV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id np4-20020a17090b4c4400b0029af707b480si392445pjb.16.2024.02.28.17.02.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 17:02:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dtr4muXV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DF79D28314A for ; Thu, 29 Feb 2024 01:02:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 273B32E83F; Thu, 29 Feb 2024 00:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dtr4muXV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EC1213D2E8; Thu, 29 Feb 2024 00:56:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709168172; cv=none; b=MM3q5JCcg1HxwnRY4Sz9sNO7kzsiamEePIThx+lJKLZODAynIsKUkH/dscStXh3nwEuXa83Qsy+cZOzRyZ/AVsM9k4gzE0mJO+0M42VMGeNxmPOSnwkosDnuyFWQINj+XzFW64WXXldkeXmkOueFWYPcRuWskQGNKzEYYOEobeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709168172; c=relaxed/simple; bh=8INiMNb8bGe9aH8MD1xrZEujm+XkODnaql/+pLNknt0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p6OqHIbueUtxk1Dr1eMs5BZH6HxoOYl+qaU+HH5xBE/IXaktzYRTtBF6aIZiS83DaUREBNcVwQHPsy73zprL4c36VI5DhlEMbUYWSEmfh7j3G+wejsg9Y46wl2oIP2WQ4tYIt4JPu3K5uviv2Yrv+uAjTLGPbqnJ8oorA1VmZck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dtr4muXV; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 :(