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 582BDC7EE2F for ; Wed, 24 May 2023 03:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239397AbjEXDyC (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-xfs@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 :(