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 351B2C001DF for ; Wed, 2 Aug 2023 15:19:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id ACB3541498; Wed, 2 Aug 2023 15:19:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org ACB3541498 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1690989562; bh=K69sIGcSSfUNVZc7X8Ga3lFRGugNiS41+80vZsaCIzU=; h=Date:From:To:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=3S9+CNNlOg0nXbHAjoEJCjQsZO94drdUsHsmx+nh4XKYpp5k/1Yw7K/yUuC83F40R lYXvb5zwwFRdU/TBvDz3ocvYLXXaph/ZhM37Zh969CDF99VIC5JgoKUvYLKIRqbvwy kMjFco0TEmap9uA+EsTjzUpYJI2DFc/oRr8sLZesuIlzkIqGKB80nyIpthHDbke2Wn yBUTQjd+9QVkOHS9HLDsG6UNG4NOOjQbIKSMuqOLQUh3x1cyo48BqEghiEgwKZ2i65 8KpUKl0mWQHGZSWn8GOHumRfkRG2cRO1sgUOm5WPHqWtj355X8b76lUe24X+ga/cli 89EB93S+mMOeg== 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 egr-QT_JzZYG; Wed, 2 Aug 2023 15:19:21 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 9ECE4414BB; Wed, 2 Aug 2023 15:19:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9ECE4414BB Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 640D41BF372 for ; Wed, 2 Aug 2023 15:19:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5EDFE61263 for ; Wed, 2 Aug 2023 15:19:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5EDFE61263 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s2Bpc8Q2HJ87 for ; Wed, 2 Aug 2023 15:19:00 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by smtp3.osuosl.org (Postfix) with ESMTPS id 7417461242 for ; Wed, 2 Aug 2023 15:19:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7417461242 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 53A24619F1; Wed, 2 Aug 2023 15:18:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5061C433C8; Wed, 2 Aug 2023 15:18:56 +0000 (UTC) Date: Wed, 2 Aug 2023 17:18:54 +0200 From: Simon Horman To: "Gustavo A. R. Silva" Message-ID: References: <768db2c3764a490118f6850d24f6e49998494b6c.1690938732.git.gustavoars@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <768db2c3764a490118f6850d24f6e49998494b6c.1690938732.git.gustavoars@kernel.org> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690989538; bh=MpJddWF59Y3r4C5rdMlYJbaG4nJtsvWkijQnPbA5m0M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jKbDOd95vbAuoKLM9gIV+Ydy+T7t+w4aZttd+5ACEgtOVn8oXIQ9aIyq3Zdy9jkox nLfQpbtiRyULUYFp93OcLWKzpTUfWTgZNZpOfjCVAbZ47ccxRwCbXsQ3HZtAlcEF4q Ewv46l78pDi2bLYuxCehVV542hX1VDjUwpobgK0d69Ar4+OyLU0mogxf4slCutbHDg LlZWlZIR/OwONvKJJJ4HX/5GpRxfQs0UeuCyHvj9U1DUzJo+tfyDw0v40Zw8FINGIa mMDCrqYbO2CqB5N5/YCODYb9jXHYECCcdPzn8t37faCcZdKixaaxgwLmmn4FLXg6y2 uenMUm+byM7kQ== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=jKbDOd95 Subject: Re: [Intel-wired-lan] [PATCH 1/4][next] i40e: Replace one-element array with flex-array member in struct i40e_package_header 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: netdev@vger.kernel.org, Jesse Brandeburg , linux-kernel@vger.kernel.org, Eric Dumazet , Tony Nguyen , linux-hardening@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Jakub Kicinski , Paolo Abeni , "David S. Miller" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Tue, Aug 01, 2023 at 11:05:31PM -0600, Gustavo A. R. Silva wrote: > One-element and zero-length arrays are deprecated. So, replace > one-element array in struct i40e_package_header with flexible-array > member. > > The `+ sizeof(u32)` adjustments ensure that there are no differences > in binary output. > > Link: https://github.com/KSPP/linux/issues/335 > Signed-off-by: Gustavo A. R. Silva > --- > drivers/net/ethernet/intel/i40e/i40e_ddp.c | 4 ++-- > drivers/net/ethernet/intel/i40e/i40e_type.h | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_ddp.c b/drivers/net/ethernet/intel/i40e/i40e_ddp.c > index 7e8183762fd9..0db6f5e3cfcc 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_ddp.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_ddp.c > @@ -220,7 +220,7 @@ static bool i40e_ddp_is_pkg_hdr_valid(struct net_device *netdev, > netdev_err(netdev, "Invalid DDP profile - size is bigger than 4G"); > return false; > } > - if (size < (sizeof(struct i40e_package_header) + > + if (size < (sizeof(struct i40e_package_header) + sizeof(u32) + Hi Gustavo, would it make more sense to use struct_size() here? > sizeof(struct i40e_metadata_segment) + sizeof(u32) * 2)) { > netdev_err(netdev, "Invalid DDP profile - size is too small."); > return false; > @@ -281,7 +281,7 @@ int i40e_ddp_load(struct net_device *netdev, const u8 *data, size_t size, > if (!i40e_ddp_is_pkg_hdr_valid(netdev, pkg_hdr, size)) > return -EINVAL; > > - if (size < (sizeof(struct i40e_package_header) + > + if (size < (sizeof(struct i40e_package_header) + sizeof(u32) + > sizeof(struct i40e_metadata_segment) + sizeof(u32) * 2)) { > netdev_err(netdev, "Invalid DDP recipe size."); > return -EINVAL; > diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h > index 388c3d36d96a..c3d5fe12059a 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_type.h > +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h > @@ -1456,7 +1456,7 @@ struct i40e_ddp_version { > struct i40e_package_header { > struct i40e_ddp_version version; > u32 segment_count; > - u32 segment_offset[1]; > + u32 segment_offset[]; > }; > > /* Generic segment header */ > -- > 2.34.1 > > _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan 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 F0C97C41513 for ; Wed, 2 Aug 2023 15:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232729AbjHBPYB (ORCPT ); Wed, 2 Aug 2023 11:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235499AbjHBPXb (ORCPT ); Wed, 2 Aug 2023 11:23:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A68182122; Wed, 2 Aug 2023 08:20:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 53CC4619F4; Wed, 2 Aug 2023 15:18:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5061C433C8; Wed, 2 Aug 2023 15:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690989538; bh=MpJddWF59Y3r4C5rdMlYJbaG4nJtsvWkijQnPbA5m0M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jKbDOd95vbAuoKLM9gIV+Ydy+T7t+w4aZttd+5ACEgtOVn8oXIQ9aIyq3Zdy9jkox nLfQpbtiRyULUYFp93OcLWKzpTUfWTgZNZpOfjCVAbZ47ccxRwCbXsQ3HZtAlcEF4q Ewv46l78pDi2bLYuxCehVV542hX1VDjUwpobgK0d69Ar4+OyLU0mogxf4slCutbHDg LlZWlZIR/OwONvKJJJ4HX/5GpRxfQs0UeuCyHvj9U1DUzJo+tfyDw0v40Zw8FINGIa mMDCrqYbO2CqB5N5/YCODYb9jXHYECCcdPzn8t37faCcZdKixaaxgwLmmn4FLXg6y2 uenMUm+byM7kQ== Date: Wed, 2 Aug 2023 17:18:54 +0200 From: Simon Horman To: "Gustavo A. R. Silva" Cc: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 1/4][next] i40e: Replace one-element array with flex-array member in struct i40e_package_header Message-ID: References: <768db2c3764a490118f6850d24f6e49998494b6c.1690938732.git.gustavoars@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <768db2c3764a490118f6850d24f6e49998494b6c.1690938732.git.gustavoars@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Tue, Aug 01, 2023 at 11:05:31PM -0600, Gustavo A. R. Silva wrote: > One-element and zero-length arrays are deprecated. So, replace > one-element array in struct i40e_package_header with flexible-array > member. > > The `+ sizeof(u32)` adjustments ensure that there are no differences > in binary output. > > Link: https://github.com/KSPP/linux/issues/335 > Signed-off-by: Gustavo A. R. Silva > --- > drivers/net/ethernet/intel/i40e/i40e_ddp.c | 4 ++-- > drivers/net/ethernet/intel/i40e/i40e_type.h | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_ddp.c b/drivers/net/ethernet/intel/i40e/i40e_ddp.c > index 7e8183762fd9..0db6f5e3cfcc 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_ddp.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_ddp.c > @@ -220,7 +220,7 @@ static bool i40e_ddp_is_pkg_hdr_valid(struct net_device *netdev, > netdev_err(netdev, "Invalid DDP profile - size is bigger than 4G"); > return false; > } > - if (size < (sizeof(struct i40e_package_header) + > + if (size < (sizeof(struct i40e_package_header) + sizeof(u32) + Hi Gustavo, would it make more sense to use struct_size() here? > sizeof(struct i40e_metadata_segment) + sizeof(u32) * 2)) { > netdev_err(netdev, "Invalid DDP profile - size is too small."); > return false; > @@ -281,7 +281,7 @@ int i40e_ddp_load(struct net_device *netdev, const u8 *data, size_t size, > if (!i40e_ddp_is_pkg_hdr_valid(netdev, pkg_hdr, size)) > return -EINVAL; > > - if (size < (sizeof(struct i40e_package_header) + > + if (size < (sizeof(struct i40e_package_header) + sizeof(u32) + > sizeof(struct i40e_metadata_segment) + sizeof(u32) * 2)) { > netdev_err(netdev, "Invalid DDP recipe size."); > return -EINVAL; > diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h > index 388c3d36d96a..c3d5fe12059a 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_type.h > +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h > @@ -1456,7 +1456,7 @@ struct i40e_ddp_version { > struct i40e_package_header { > struct i40e_ddp_version version; > u32 segment_count; > - u32 segment_offset[1]; > + u32 segment_offset[]; > }; > > /* Generic segment header */ > -- > 2.34.1 > >