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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 23644C5478C for ; Wed, 28 Feb 2024 21:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6aq0dirCi9Xyq09m4yWcNe/AYwNLSwQM/I8LPnij33I=; b=JN9lQxduaGDcH5 t2VtJF11/HwSrx/376/a3PsWo6nC7GBe677iriR+MVzcNaR3Ta5vltCwA/9quF/A6dEs14chDuGj1 RnhMJRd9QbcpZol2moaFn1LnS/2uFv7Yxs74a7VVBFCptssXDf6gMy4MtCKiVtmfWKVq3M7nm3khD MlArq7ryn5MV7JWIEUG8oPQ+mftqK8tiwYg1fvrn6+5ujvHHZqB0KSFFUPL1EnFwEJlGz3yZAvt1x us5Wshlj03dCHYL7jju0DajcD8/Er85UL7wO/S7DGOxdI3+ahOWawZAeKJvJmYImaMM3+9Nax7KYv JZObgmkGzMuL9nett90A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfRpv-0000000B2oa-1LsO; Wed, 28 Feb 2024 21:51:35 +0000 Received: from mgamail.intel.com ([192.198.163.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfRps-0000000B2nr-28gX for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2024 21:51:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709157092; x=1740693092; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=cTXPciNmp57QN/LMHOfsPfOz4graJiRWh79HJ0KYXuk=; b=JPrZouiYiSy9UMXPDcWq7D/5LcZTuVm4MUJQfBNm1iJsGSvV1ysQVIEb UQUqBCBj2Miv4MnWUq81p0+Uc3DtJQPeDLGGKzaMnYtju9Hkt9xex8vC7 39VbJdO461Qra/f3jh+y7QyP9f0BSuODsYgSC/W4GLC/lwEIEqqk9A9lf Ba5vD9+GJT04+zjnVnk0POq8eo//+83el0b4iH14HOq0TPzWYiVve+dug KS7UOeVvvUCU6+lCsiP8gQa4LDt7Bame6vMyH7hgbvqqCPFSqAw853QSB q8VifOzwyU2WmNiwO3LqVVrBOeCLxeYWY171ewa4YJWDZSgZlLlotH6/4 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="7373185" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7373185" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:51:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="913962180" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="913962180" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:51:27 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rfRpk-00000008VoK-0C32; Wed, 28 Feb 2024 23:51:24 +0200 Date: Wed, 28 Feb 2024 23:51:23 +0200 From: Andy Shevchenko To: Kees Cook Cc: Vinod Koul , Linus Walleij , Jonathan Cameron , Mark Brown , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-spi@vger.kernel.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Gustavo A. R. Silva" Subject: Re: [PATCH v4 2/8] overflow: Add struct_size_with_data() and struct_data_pointer() helpers Message-ID: References: <20240228204919.3680786-1-andriy.shevchenko@linux.intel.com> <20240228204919.3680786-3-andriy.shevchenko@linux.intel.com> <202402281334.876DC89@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202402281334.876DC89@keescook> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_135132_650895_1673D1EB X-CRM114-Status: GOOD ( 14.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Feb 28, 2024 at 01:37:36PM -0800, Kees Cook wrote: > On Wed, Feb 28, 2024 at 10:41:32PM +0200, Andy Shevchenko wrote: ... > > +#define struct_data_pointer(p, a) PTR_ALIGN((void *)((p) + 1), (a)) > > I'm not super excited about propagating the "p + 1" code pattern to find > things after an allocation. This leads to the compiler either being > blind to accesses beyond an allocation, or being too conservative about > accesses beyond an object. Instead of these helpers I would much prefer > that data structures that use this code pattern be converted to using > trailing flexible arrays, at which point the compiler is in a much > better position to reason about sizes. There is nothing about flexible arrays in this. Maybe you have been confused by my choice for name of the macros. In that case I also can argue that current struct_size() is a good one. (something like struct_size_with_flex_array() can be more specific) -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel