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 smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 6A415C77B7C for ; Wed, 24 May 2023 03:54:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CCE49606F2; Wed, 24 May 2023 03:54:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CCE49606F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1684900442; bh=VlL+yuamC0K/q6WFJ5XeA8uHIMf3TclTTWy45R9jeAM=; h=Date:From:To:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=UqUaDSZkxbLzIy40n940MqaSTty79Dsm8rF2MzR+UuOsnbs69SeG0AcMpRN61J+j6 A+P0VDmZG17qToQ+HKCJmIsinL5ZwwESDSHek9haVyDu4QmIHVmZzZR6RqTTwoIKe6 1jatyGxgq/r7htIv5++GqqjX7GmiawAcD11TlWt58WzlNqLDoryCy6YHM5/j6jd/i7 9djPFoB6QTK43Xmz/3e2Stscb/sXSBp40ZpJYDjsYiSAyCbGPij4s2S6swrQc5Q2bE c6NN9Re+TFT0PqWCXuWPbH/orcZtBTySC+UQbZmisMyYY73sY74Og6QOXXd32jzwT8 JsJN4KNaIMubw== 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 CvlgEsEi1uDY; Wed, 24 May 2023 03:54:02 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id D7A3660BB2; Wed, 24 May 2023 03:54:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D7A3660BB2 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id B7AEC1BF3C5 for ; Wed, 24 May 2023 03:53:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8EB834245F for ; Wed, 24 May 2023 03:53:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8EB834245F 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 bkUH1cLCaAnl for ; Wed, 24 May 2023 03:53:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9C6A042068 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by smtp4.osuosl.org (Postfix) with ESMTPS id 9C6A042068 for ; Wed, 24 May 2023 03:53:58 +0000 (UTC) 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 D568863866; Wed, 24 May 2023 03:53:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD908C433D2; Wed, 24 May 2023 03:53:55 +0000 (UTC) Date: Tue, 23 May 2023 20:53:54 -0700 From: Jakub Kicinski To: Kees Cook Message-ID: <20230523205354.06b147c6@kernel.org> In-Reply-To: <20230522211810.never.421-kees@kernel.org> References: <20230522211810.never.421-kees@kernel.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684900437; bh=4f1gt/BCfbLHog09/Xsin0iYouAloZtBkhPaw5h+3Uk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VTjRau/bNOfmdJ33zPP9fzppLzalj2n66xWeUM8et/U2kDIXenWJlws9ke/J63cua 7h8nbEpBrHk+3kbBwK4hYrTG0TJuuA4Y8nyVrZV34Feh/wVZUCXe9pHkiL5GrZpTPb 1pUq0WoLiV4z1hh/q8nIAUP6Q7nvRsPe6zxlxMbem5vTDjKC2IBSsISEX6TycDAT+K E11xrcZaYzPDD+AvVcAUfQueTdIeTLMtPcPMx7rpOceZRwETWUuo1o7AcoLQuOypBm fbpREO7W2cFcnLHLSfIPlJAIvbGWiK22cduJxuIMSKGEpMfWr2jO0/7hSlREuEGrtM 7Bq4VihlXfeWA== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=VTjRau/b Subject: Re: [Intel-wired-lan] [PATCH] overflow: Add struct_size_t() helper 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: "Darrick J. Wong" , Daniel Latypov , storagedev@microchip.com, linux-nvme@lists.infradead.org, James Smart , Guo Xuenan , Eric Dumazet , Tony Nguyen , linux-hardening@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , linux-scsi@vger.kernel.org, Jesse Brandeburg , Kashyap Desai , Christoph Hellwig , intel-wired-lan@lists.osuosl.org, Paolo Abeni , "James E.J. Bottomley" , Gwan-gyeong Mun , Dave Chinner , Keith Busch , HighPoint Linux Team , megaraidlinux.pdl@broadcom.com, Jens Axboe , "Martin K. Petersen" , Shivasharan S , netdev@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, Sumit Saxena , Tales Aparecida , Don Brace , "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 Mon, 22 May 2023 14:18:13 -0700 Kees Cook wrote: > diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.h b/drivers/net/ethernet/intel/ice/ice_ddp.h > index 37eadb3d27a8..41acfe26df1c 100644 > --- a/drivers/net/ethernet/intel/ice/ice_ddp.h > +++ b/drivers/net/ethernet/intel/ice/ice_ddp.h > @@ -185,7 +185,7 @@ struct ice_buf_hdr { > > #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) \ > ((ICE_PKG_BUF_SIZE - \ > - struct_size((struct ice_buf_hdr *)0, section_entry, 1) - (hd_sz)) / \ > + struct_size_t(struct ice_buf_hdr, section_entry, 1) - (hd_sz)) / \ > (ent_sz)) > > /* ice package section IDs */ > @@ -297,7 +297,7 @@ struct ice_label_section { > }; > > #define ICE_MAX_LABELS_IN_BUF \ > - ICE_MAX_ENTRIES_IN_BUF(struct_size((struct ice_label_section *)0, \ > + ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_label_section, \ > label, 1) - \ > sizeof(struct ice_label), \ > sizeof(struct ice_label)) > @@ -352,7 +352,7 @@ struct ice_boost_tcam_section { > }; > > #define ICE_MAX_BST_TCAMS_IN_BUF \ > - ICE_MAX_ENTRIES_IN_BUF(struct_size((struct ice_boost_tcam_section *)0, \ > + ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_boost_tcam_section, \ > tcam, 1) - \ > sizeof(struct ice_boost_tcam_entry), \ > sizeof(struct ice_boost_tcam_entry)) > @@ -372,8 +372,7 @@ struct ice_marker_ptype_tcam_section { > }; > > #define ICE_MAX_MARKER_PTYPE_TCAMS_IN_BUF \ > - ICE_MAX_ENTRIES_IN_BUF( \ > - struct_size((struct ice_marker_ptype_tcam_section *)0, tcam, \ > + ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_marker_ptype_tcam_section, tcam, \ > 1) - \ > sizeof(struct ice_marker_ptype_tcam_entry), \ > sizeof(struct ice_marker_ptype_tcam_entry)) Acked-by: Jakub Kicinski but Intel ICE folks please speak up if this has a high chance of conflicts, I think I've seen some ICE DDP patches flying around :( _______________________________________________ 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 33E69C7EE23 for ; Wed, 24 May 2023 03:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239401AbjEXDyC (ORCPT ); Tue, 23 May 2023 23:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239404AbjEXDyA (ORCPT ); Tue, 23 May 2023 23:54:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A740196; Tue, 23 May 2023 20:53:58 -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 DC7D563870; Wed, 24 May 2023 03:53:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD908C433D2; Wed, 24 May 2023 03:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684900437; bh=4f1gt/BCfbLHog09/Xsin0iYouAloZtBkhPaw5h+3Uk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VTjRau/bNOfmdJ33zPP9fzppLzalj2n66xWeUM8et/U2kDIXenWJlws9ke/J63cua 7h8nbEpBrHk+3kbBwK4hYrTG0TJuuA4Y8nyVrZV34Feh/wVZUCXe9pHkiL5GrZpTPb 1pUq0WoLiV4z1hh/q8nIAUP6Q7nvRsPe6zxlxMbem5vTDjKC2IBSsISEX6TycDAT+K E11xrcZaYzPDD+AvVcAUfQueTdIeTLMtPcPMx7rpOceZRwETWUuo1o7AcoLQuOypBm fbpREO7W2cFcnLHLSfIPlJAIvbGWiK22cduJxuIMSKGEpMfWr2jO0/7hSlREuEGrtM 7Bq4VihlXfeWA== Date: Tue, 23 May 2023 20:53:54 -0700 From: Jakub Kicinski To: Kees Cook Cc: Jesse Brandeburg , Christoph Hellwig , Tony Nguyen , "David S. Miller" , Eric Dumazet , Paolo Abeni , James Smart , Keith Busch , Jens Axboe , Sagi Grimberg , HighPoint Linux Team , "James E.J. Bottomley" , "Martin K. Petersen" , Kashyap Desai , Sumit Saxena , Shivasharan S , Don Brace , "Darrick J. Wong" , Dave Chinner , Guo Xuenan , Gwan-gyeong Mun , Nick Desaulniers , Daniel Latypov , kernel test robot , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, storagedev@microchip.com, linux-xfs@vger.kernel.org, linux-hardening@vger.kernel.org, Christoph Hellwig , Tales Aparecida , linux-kernel@vger.kernel.org Subject: Re: [PATCH] overflow: Add struct_size_t() helper Message-ID: <20230523205354.06b147c6@kernel.org> In-Reply-To: <20230522211810.never.421-kees@kernel.org> References: <20230522211810.never.421-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Mon, 22 May 2023 14:18:13 -0700 Kees Cook wrote: > diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.h b/drivers/net/ethernet/intel/ice/ice_ddp.h > index 37eadb3d27a8..41acfe26df1c 100644 > --- a/drivers/net/ethernet/intel/ice/ice_ddp.h > +++ b/drivers/net/ethernet/intel/ice/ice_ddp.h > @@ -185,7 +185,7 @@ struct ice_buf_hdr { > > #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) \ > ((ICE_PKG_BUF_SIZE - \ > - struct_size((struct ice_buf_hdr *)0, section_entry, 1) - (hd_sz)) / \ > + struct_size_t(struct ice_buf_hdr, section_entry, 1) - (hd_sz)) / \ > (ent_sz)) > > /* ice package section IDs */ > @@ -297,7 +297,7 @@ struct ice_label_section { > }; > > #define ICE_MAX_LABELS_IN_BUF \ > - ICE_MAX_ENTRIES_IN_BUF(struct_size((struct ice_label_section *)0, \ > + ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_label_section, \ > label, 1) - \ > sizeof(struct ice_label), \ > sizeof(struct ice_label)) > @@ -352,7 +352,7 @@ struct ice_boost_tcam_section { > }; > > #define ICE_MAX_BST_TCAMS_IN_BUF \ > - ICE_MAX_ENTRIES_IN_BUF(struct_size((struct ice_boost_tcam_section *)0, \ > + ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_boost_tcam_section, \ > tcam, 1) - \ > sizeof(struct ice_boost_tcam_entry), \ > sizeof(struct ice_boost_tcam_entry)) > @@ -372,8 +372,7 @@ struct ice_marker_ptype_tcam_section { > }; > > #define ICE_MAX_MARKER_PTYPE_TCAMS_IN_BUF \ > - ICE_MAX_ENTRIES_IN_BUF( \ > - struct_size((struct ice_marker_ptype_tcam_section *)0, tcam, \ > + ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_marker_ptype_tcam_section, tcam, \ > 1) - \ > sizeof(struct ice_marker_ptype_tcam_entry), \ > sizeof(struct ice_marker_ptype_tcam_entry)) Acked-by: Jakub Kicinski but Intel ICE folks please speak up if this has a high chance of conflicts, I think I've seen some ICE DDP patches flying around :(