Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp114799rbe; Wed, 28 Feb 2024 14:08:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX4kouMQrNSyW12Iyau2cg8yo5kOgesQu66Ol5IZm8Zu50+TzaKDw6962rEzbfUteTaCjN98pAwefj/E1TykjD48PGyGAPLjlXVa9iDRA== X-Google-Smtp-Source: AGHT+IGH1JYEZQtEoziwc48wRo10OG3fa3mbtU1gXhgJu8KFST0cbZNdRX7bCcJqzsWRG98iiI/v X-Received: by 2002:a17:90a:1bc8:b0:299:1bf1:7543 with SMTP id r8-20020a17090a1bc800b002991bf17543mr466749pjr.6.1709158122157; Wed, 28 Feb 2024 14:08:42 -0800 (PST) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id li13-20020a17090b48cd00b002972e2132eesi99167pjb.64.2024.02.28.14.08.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 14:08:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=e6BSONfd; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-85744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5416EB24D07 for ; Wed, 28 Feb 2024 21:51:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7B2172909; Wed, 28 Feb 2024 21:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel.com header.i=@intel.com header.b="e6BSONfd" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CC595E09F; Wed, 28 Feb 2024 21:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709157095; cv=none; b=AZTaZAGLt3UlODfOSdEj0lRQtRan1xPue7idnOXJmt1055u3RG98nbO+Y41ZJKS6t1Hk4U/vSBDg6D3pLukk2eOkzpLxnOWbFX5UMbfalG/WglU6NSz+ogNJNboaZRwSsXxDTf1y8CrTpnMjnr7Dzb+iembGy+DrIEEwmhRNqZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709157095; c=relaxed/simple; bh=cTXPciNmp57QN/LMHOfsPfOz4graJiRWh79HJ0KYXuk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n09AcRZNN1sc2OvwFmUtuOgp/L0FahxgK8vR4pMODe5QUamFTnPe+hFTCzFeG80CEvFlnAPmzC7iZYCxaDYkzAtgOxgyo265vyT+yj6eXsQm+DRip8AMZ9mjszBdGIE+f4OOCbRiNlCaTO60E4iBY2uu+ZbEIJmu97ocNFdYYmE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=e6BSONfd; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709157093; x=1740693093; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=cTXPciNmp57QN/LMHOfsPfOz4graJiRWh79HJ0KYXuk=; b=e6BSONfdONVOSvm4MAPjg8bB0h05vwmBA9KcI30G5fTyf43XvRvrF/hN CTVEQe8XQtJ9jSqzfCF+1/zRvOI5ng2+P57KxiOFbDcmldBTmDtEsHwEm nfGCo2xhkb6/KLAF22njjyFJv19nkI8zxT0wzqu1Pa7x29yZWZNpycWrD JWT/4gwA9d341aoAAkr3vh1lFTWv5UQ4RKrAgBY5x8cssaLWUkICQvR71 ljhjGDFttMDC7SknI1UeidPEWR2giR3HSxBTf+liUfoMXC0ZtaEaGQ+oD At+n6vT9yV+GoLdJClnQSv1yukbaBNmAorvHjYsnXOnYT8Gwt+kCvurBF g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="7373182" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7373182" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202402281334.876DC89@keescook> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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