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 23C9CC0015E for ; Mon, 24 Jul 2023 11:11:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbjGXLLa (ORCPT ); Mon, 24 Jul 2023 07:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbjGXLL3 (ORCPT ); Mon, 24 Jul 2023 07:11:29 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F4031D8; Mon, 24 Jul 2023 04:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690197089; x=1721733089; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=tZ+Mn45U9cntff8ECmc6tXrlWTvi0j6loy/gyXruB4Y=; b=eVNbP1csUdohmHKt+JqlYhux2pe790iY8u9rKgTeC7bnf10DX3EoNKOq zKMFpAkZZ5eEbNR7l+yGznkYgq2REHeMD3UZ25OASe/5TIrM4sYP4n4Bl cYMm7J6A5vEyZfcOkyPN1HVIhzSbddK6fGOIOUGcZDUGdNixL5mS6cb1O xWNBlWQvmQ0nm1h3TtnOeCLf1KZGtLpm4EEhqu34IJK0MqIRDNL4K50eq BdKyq+K9HGoTCVPoRf11cojzYNrXaEPuGj3MGEJN0QOMBQOd8ZzLO0u7M IBaM6K8W9xo/hFcPOS/Pj7f4Q9DMp8LRMYVtmrAv8WYKFYgC2L1bNR/04 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="371011576" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="371011576" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 04:11:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="869037552" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga001.fm.intel.com with ESMTP; 24 Jul 2023 04:11:27 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qNtTI-00A6JR-2l; Mon, 24 Jul 2023 14:11:24 +0300 Date: Mon, 24 Jul 2023 14:11:24 +0300 From: Andy Shevchenko To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Kees Cook , Nuno Sa Subject: Re: [PATCH v3 2/4] iio: core: Add opaque_struct_size() helper and use it Message-ID: References: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> <20230724110204.46285-3-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230724110204.46285-3-andriy.shevchenko@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Mon, Jul 24, 2023 at 02:02:02PM +0300, Andy Shevchenko wrote: > Introduce opaque_struct_size() helper, which may be moved > to overflow.h in the future, and use it in the IIO core. > > Potential users could be (among possible others): > > __spi_alloc_controller() in drivers/spi/spi.c > alloc_netdev_mqs in net/core/dev.c ... > +#define opaque_struct_size(p, a, s) size_add(ALIGN(sizeof(*(p)), (a)), (s)) This actually might need something like __safe_aling() which takes care about possible overflow. Whatever, I want to hear Kees on this. -- With Best Regards, Andy Shevchenko