Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1005235lqm; Thu, 2 May 2024 02:18:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVJrLEYe01w4U9jNYzEXL5ntlZMLUd6dlFknEmRHnRPjVBjcc0OfZ5QZFy5QKHSAT7Rz2nZs/27Bh4WCgH/0Jq8h+E06ZaZ+0XM9/JWA== X-Google-Smtp-Source: AGHT+IEKLeePr8iSpw6Y0BaOB9Wrda58qIdszV1UUR/invk3U0A19nEL+zNaTuZk27K3IrQU8SPv X-Received: by 2002:a17:90a:1fca:b0:2b0:7f15:9155 with SMTP id z10-20020a17090a1fca00b002b07f159155mr4986352pjz.31.1714641533623; Thu, 02 May 2024 02:18:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714641533; cv=pass; d=google.com; s=arc-20160816; b=nZI7xLCErqbNQk0/a3IZxBpH5pZjseOcYlLh7srsDdgllSAEW6WD2fddezLzHF5Qp2 eedYqMkHktsMfMTryprby5IxoczA6Jcd+tk92mNl9ykFwS8h0DLWYFQHvo5RVm0l/gAN ws1225KieXiPYtX4mAUMvbvsVlMOTh4oNNBjGqBjBGm2azdGotUicZB8DSoDhsbYES/b IBRaMySZPmOeIRZlEh2eht4hhlGNs1/76RqX/cbjazlP2VV9u7mPG5a6h/kpnTlg1uzk 4ZFpE7G5IsIedwAPKKb+XJcLpIXit8ZzH3jCbUqU2YzDBd1lAj1aU/ShkDJcEi8llWrD 4VTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YTpMwMX+qpj6Q/bcMYzijVjSwnah9GpAyoqUNT5p8FE=; fh=4ehiMhUiZrK/925pPBCRBJb+OfRxrCPCMtXTYinrxJQ=; b=sX9qWUqvlJ6TiPIc0st/j262qdXqktlbzNSNC5cXA9p4hk8DmSi9BK8kvyDAzIRCZr GP789dS3RUvmgUYqvalmjgXDdfIs+eXr/XFHMMj8gWuhKq6tOaEMoJ83Md4hkCCaM5sL Gtb7ZtomaX2CqJIkVpahfrd+fip1OaVsJFgMHxmJCTq1hYSJxlR+zia9AwdERFmoWeUY 57/TjeSrzBR26m8IE20kjU/c4nOkGBVAPbKdId8F99pLgS+bk6s9XpwL+Bqc6aw/IIoU bdJsxTyzKaMqXKKBBRd0N+dqmiVnksNd0OnO3ZivTqlhJ0QPKmiNnVoVLcE5l6GP57mC lG1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uFQggjpZ; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-166194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166194-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n24-20020a17090ac69800b002a509652f35si683899pjt.131.2024.05.02.02.18.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 02:18:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uFQggjpZ; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-166194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166194-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 43EAF283891 for ; Thu, 2 May 2024 09:18:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0425753816; Thu, 2 May 2024 09:18:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="uFQggjpZ" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 C118153365; Thu, 2 May 2024 09:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714641528; cv=none; b=Fe0G4Yb93A6THyOKFHjUCqlirgkFB5puMmGFmRZ0VWrLsHBpooSAj+gYuWEsVSY6Z6zhruSyZrDZx3ycQkNcam/QTQT9T1JpKFzPekT4augF16rRp/G3qYPpJe/qzC7VXGIqiJEBj4uXaRC+E2weqblZoKJHZgrKww4HkJbhVX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714641528; c=relaxed/simple; bh=I7p1RdtGOFI//Ur2G0I4lDz0SGt6YQnyFeR6Ar+LrsQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=i+DmB0mjyxiK5Q75t8hdL1SGqQcswyJZpoLHulqC0wCrYBU2yAw65wGHy2o1+zx/5x+FSR5DiJ00HCY0f6XxgJ8vQznISp5cdJ9rs0sXmc6c3TfFNBmcYVywopIbx1nX2KTJBmSO6t5jFrIaZYy6+jJUx0XKRW74n0JPcKXwL/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=uFQggjpZ; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YTpMwMX+qpj6Q/bcMYzijVjSwnah9GpAyoqUNT5p8FE=; b=uFQggjpZFaHyRheUPJ/kajtRrJ camcEqM/4pLauiKQOWKzIw1iT5fbw+MXhwWL7BezQNa+6f0RMP8EzuUV6yU+jjvBAaVXgIb6/AFUs 9F/68m45s3ecnvnIooOwxg0lCZlVFXCxxHlvTBwGUTCSEYHyXfEn5s8L1F+MOn33vVtyw4Y9R9cdg ybPOuzhOxVG8t+8/c8JyM5lNw2TwVa0G0SUuMbJsk9LfFS3kWh2Cs0ffjoMbfS0QBqhpagjg6MZp0 5pKlVxu5Xw8HW5TniqLT+UuUUjWqs3JEH7cu1Yfnc0Fp5miS1M+N3a3uVPsxxMIIaJlRpQuiNr1Wk AH/wktrQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2SaL-00000001Kdw-2O0D; Thu, 02 May 2024 09:18:37 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 3B94A30057A; Thu, 2 May 2024 11:18:37 +0200 (CEST) Date: Thu, 2 May 2024 11:18:37 +0200 From: Peter Zijlstra To: Kees Cook Cc: Erick Archer , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , "Gustavo A. R. Silva" , Justin Stitt , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] perf/ring_buffer: Prefer struct_size over open coded arithmetic Message-ID: <20240502091837.GA30852@noisy.programming.kicks-ass.net> References: <20240430091504.GC40213@noisy.programming.kicks-ass.net> <202405011317.AF41B94B@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: <202405011317.AF41B94B@keescook> On Wed, May 01, 2024 at 01:21:42PM -0700, Kees Cook wrote: > On Tue, Apr 30, 2024 at 11:15:04AM +0200, Peter Zijlstra wrote: > > On Mon, Apr 29, 2024 at 07:40:58PM +0200, Erick Archer wrote: > > > This is an effort to get rid of all multiplications from allocation > > > functions in order to prevent integer overflows [1][2]. > > > > So personally I detest struct_size() because I can never remember wtf it > > does, whereas the code it replaces is simple and straight forward :/ > > Sure, new APIs can involved a learning curve. If we can all handle > container_of(), we can deal with struct_size(). :) containre_of() is actually *much* shorter than typing it all out. Which is a benefit. struct_size() not so much. That's just obfuscation for obfuscation's sake.