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 smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.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 A341EC5475B for ; Fri, 8 Mar 2024 20:20:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4D8C741CC6; Fri, 8 Mar 2024 20:20:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7pdvlLOboqZA; Fri, 8 Mar 2024 20:20:30 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A104340AFB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1709929230; bh=dCwA1ZEnNSWwn/RUD3zA3y9EWHi8z80JtCHdS7qOyRY=; h=Date:From:To:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=3MDmeadaWjiDq5TSijt/pby5l8Lsx1psXZyJT01iro2GoTmCfVaNaLBYpHud5s43g DUCfCjYlzSbs4/Rev66FNy/TWL2IJrzesJXORmz0UH9mMtJ8T2SHmrl2ATFiFcPQFl sdIVPyzRe455EfiH5eDG93N56Kqij+DVrCDRdWOSlE/YUVZOgQ/nkfCFM7uX3oyfi7 c40fh84A1VG7PVITUutxk5UHmK+TC/DyEEE1RTYSKU8hWydzPay3dChEVI4HCHNrRI h1U6ZBoKWtxGev5MTH7OK3cq8ssZnz6G1EYO5ervKMzPNOpJ6A4QgpymEmwyFh+3Uc x+S+JCtKckkFA== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id A104340AFB; Fri, 8 Mar 2024 20:20:30 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 76E3B1BF306 for ; Fri, 8 Mar 2024 20:20:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6FED4406E5 for ; Fri, 8 Mar 2024 20:20:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DZ7MHxpY3V-x for ; Fri, 8 Mar 2024 20:20:28 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=145.40.73.55; helo=sin.source.kernel.org; envelope-from=horms@kernel.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 1FDB84067F DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 1FDB84067F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by smtp4.osuosl.org (Postfix) with ESMTPS id 1FDB84067F for ; Fri, 8 Mar 2024 20:20:27 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id BCF3ACE296F; Fri, 8 Mar 2024 20:20:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33931C433C7; Fri, 8 Mar 2024 20:20:20 +0000 (UTC) Date: Fri, 8 Mar 2024 20:20:18 +0000 From: Simon Horman To: Kees Cook Message-ID: <20240308202018.GC603911@kernel.org> References: <20240306235128.it.933-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240306235128.it.933-kees@kernel.org> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709929223; bh=gYgxy4F5CnKyHPKbcHJaavUq/XxDolwE8qGCqjDXh+8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bwXjVQtGGIi4z05dXM7t+mW349nAbNwduE6oKVrFaZqaqvjJAZm1gY9cyKAaaGzVz jeIwty/w36mFs0a1IIzAQA0eel7mIwNKMwXnn3QRuKZkesAf96SFGm2HRHvyWsDzkR Ic29K329b7pgj1Ddkv8YZlovz2x7xk9WTC7TuDGbyRR8eYWnkB7FsGpkAIgQQnlntd KR14Yc8aUhx3c87tFBIAuvlqn7x+QBYUvhD9n6gwg2+m1QsW0zm6rybHTFwnjK6Rt1 YJtX06wEpTmXnvJUMUeHrD1N9CvJAHtpr9tlqrVU8cJkkGHb34BD4L2HIBH+pmpn0R UYec58b4sG9Wg== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=kernel.org X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=bwXjVQtG Subject: Re: [Intel-wired-lan] [PATCH v2] overflow: Change DEFINE_FLEX to take __counted_by member X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Przemek Kitszel , "Gustavo A. R. Silva" , Eric Dumazet , netdev@vger.kernel.org, Tony Nguyen , linux-hardening@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Jakub Kicinski , Andrew Morton , Paolo Abeni , "David S. Miller" , linux-kernel@vger.kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Wed, Mar 06, 2024 at 03:51:36PM -0800, Kees Cook wrote: > The norm should be flexible array structures with __counted_by > annotations, so DEFINE_FLEX() is updated to expect that. Rename > the non-annotated version to DEFINE_RAW_FLEX(), and update the > few existing users. > > Signed-off-by: Kees Cook Hi Kees, I'm unclear what this is based on, as it doesn't appear to apply cleanly to net-next or the dev-queue branch of the iwl-next tree. But I manually applied it to the latter and ran some checks. ... > diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c > index f84bab80ca42..d4baae8c3b72 100644 > --- a/drivers/net/ethernet/intel/ice/ice_switch.c > +++ b/drivers/net/ethernet/intel/ice/ice_switch.c Given what is currently in the dev-queue branch of the iwl-next tree, the following hunk also seems to be required for ice_switch.c. @@ -5378,7 +5378,7 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo, */ static int ice_subscribe_recipe(struct ice_hw *hw, u16 rid) { - DEFINE_FLEX(struct ice_aqc_alloc_free_res_elem, sw_buf, elem, 1); + DEFINE_RAW_FLEX(struct ice_aqc_alloc_free_res_elem, sw_buf, elem, 1); u16 buf_len = __struct_size(sw_buf); u16 res_type; int status; ... > diff --git a/include/linux/overflow.h b/include/linux/overflow.h > index aa691f2119b0..677b03c4c84f 100644 > --- a/include/linux/overflow.h > +++ b/include/linux/overflow.h > @@ -396,9 +396,9 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend) > * @name: Name for a variable to define. > * @member: Name of the array member. > * @count: Number of elements in the array; must be compile-time const. > - * @initializer: initializer expression (could be empty for no init). > + * @initializer...: initializer expression (could be empty for no init). Curiously kernel-doc --none seems happier without the line above changed. > */ > -#define _DEFINE_FLEX(type, name, member, count, initializer) \ > +#define _DEFINE_FLEX(type, name, member, count, initializer...) \ > _Static_assert(__builtin_constant_p(count), \ > "onstack flex array members require compile-time const count"); \ > union { \ ... From mboxrd@z Thu Jan 1 00:00:00 1970 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 5F4262D60B; Fri, 8 Mar 2024 20:20:23 +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=1709929223; cv=none; b=W1R5/fexdQ0cJTju+1IArxCy2eNXtp+LD1cUeWOkaisBwojvk8ki1YwDch+Xsp0w7pkdSnEimQQ9iBuk+dr2W8HlUNyO02dST/+5s7NtXdLhAW65Ux9cwg6lrgDRxvdta+OST8h8c75dFEMoTykxKZFiVK56S9jD+S2u77l2W1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709929223; c=relaxed/simple; bh=gYgxy4F5CnKyHPKbcHJaavUq/XxDolwE8qGCqjDXh+8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WeCE+apYQ4hPwFER36veNPFS7q2fCbAKtOvdRnBRzpbd5QMbHMpXvJoN2c9uAxpYYvW+rdsdVuC0b0Sq92Hl3irjMeMfsq/w13DR8kshqUOxopDjXdgq4beUerNRVCxtlr/NbGeP6MJbd2XqXl9F+DZl2xC3txywWNz9T1qZF7w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bwXjVQtG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bwXjVQtG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33931C433C7; Fri, 8 Mar 2024 20:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709929223; bh=gYgxy4F5CnKyHPKbcHJaavUq/XxDolwE8qGCqjDXh+8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bwXjVQtGGIi4z05dXM7t+mW349nAbNwduE6oKVrFaZqaqvjJAZm1gY9cyKAaaGzVz jeIwty/w36mFs0a1IIzAQA0eel7mIwNKMwXnn3QRuKZkesAf96SFGm2HRHvyWsDzkR Ic29K329b7pgj1Ddkv8YZlovz2x7xk9WTC7TuDGbyRR8eYWnkB7FsGpkAIgQQnlntd KR14Yc8aUhx3c87tFBIAuvlqn7x+QBYUvhD9n6gwg2+m1QsW0zm6rybHTFwnjK6Rt1 YJtX06wEpTmXnvJUMUeHrD1N9CvJAHtpr9tlqrVU8cJkkGHb34BD4L2HIBH+pmpn0R UYec58b4sG9Wg== Date: Fri, 8 Mar 2024 20:20:18 +0000 From: Simon Horman To: Kees Cook Cc: Przemek Kitszel , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Gustavo A. R. Silva" , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org, Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] overflow: Change DEFINE_FLEX to take __counted_by member Message-ID: <20240308202018.GC603911@kernel.org> References: <20240306235128.it.933-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240306235128.it.933-kees@kernel.org> On Wed, Mar 06, 2024 at 03:51:36PM -0800, Kees Cook wrote: > The norm should be flexible array structures with __counted_by > annotations, so DEFINE_FLEX() is updated to expect that. Rename > the non-annotated version to DEFINE_RAW_FLEX(), and update the > few existing users. > > Signed-off-by: Kees Cook Hi Kees, I'm unclear what this is based on, as it doesn't appear to apply cleanly to net-next or the dev-queue branch of the iwl-next tree. But I manually applied it to the latter and ran some checks. ... > diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c > index f84bab80ca42..d4baae8c3b72 100644 > --- a/drivers/net/ethernet/intel/ice/ice_switch.c > +++ b/drivers/net/ethernet/intel/ice/ice_switch.c Given what is currently in the dev-queue branch of the iwl-next tree, the following hunk also seems to be required for ice_switch.c. @@ -5378,7 +5378,7 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo, */ static int ice_subscribe_recipe(struct ice_hw *hw, u16 rid) { - DEFINE_FLEX(struct ice_aqc_alloc_free_res_elem, sw_buf, elem, 1); + DEFINE_RAW_FLEX(struct ice_aqc_alloc_free_res_elem, sw_buf, elem, 1); u16 buf_len = __struct_size(sw_buf); u16 res_type; int status; ... > diff --git a/include/linux/overflow.h b/include/linux/overflow.h > index aa691f2119b0..677b03c4c84f 100644 > --- a/include/linux/overflow.h > +++ b/include/linux/overflow.h > @@ -396,9 +396,9 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend) > * @name: Name for a variable to define. > * @member: Name of the array member. > * @count: Number of elements in the array; must be compile-time const. > - * @initializer: initializer expression (could be empty for no init). > + * @initializer...: initializer expression (could be empty for no init). Curiously kernel-doc --none seems happier without the line above changed. > */ > -#define _DEFINE_FLEX(type, name, member, count, initializer) \ > +#define _DEFINE_FLEX(type, name, member, count, initializer...) \ > _Static_assert(__builtin_constant_p(count), \ > "onstack flex array members require compile-time const count"); \ > union { \ ...