Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2275627rdb; Sun, 11 Feb 2024 21:38:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgPkhI9TIh+3UO356/D0eKsNU2InwNhXlukk3czehWZxQmUO/1+I4rRXdDOCvfY1TXxHur X-Received: by 2002:a17:90a:d504:b0:293:d50c:b704 with SMTP id t4-20020a17090ad50400b00293d50cb704mr2474261pju.19.1707716335209; Sun, 11 Feb 2024 21:38:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707716335; cv=pass; d=google.com; s=arc-20160816; b=rIOIr6fdYm0H5bk3s7NtnOQ9t7RwWErS3K5DeUGCmgmNMKgtp3+W680daZ7u3FvT/f P197sz8wqAiQ93yVQxPat+nhsssSyQEzyudWIkpamXv1HFKqcMZo/39Bsb1KbMX2UU2B n7ndkJlfK6gJPoImL9M9svH8SEF8A4gAAorE4Z0qdDvh/+krIU9la2qECKAd5qoiTfri PFVKwsc40urXYu2z+c9apS76vOW/Ftx2UC0oSNyzJUjfTebdYvCd8HM+bVY/nWW2+VlI 3KuikWG/UjsAlie9d4Butb0fd4oqpfcCu29EDQiYxnXH0MOcqRoIb8jfuAelIAFxhM2N OS5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=WlznTFxLp/HqFR/zHSqL++eDGzo1KkY/I6UV1Hx6DCk=; fh=eKPfYSxa2/bBPWFUOvBKDBBgE4nruEIPKlKcFt2Fz/o=; b=AhuQVp9rAVr+5CVqOtfkDPgKh2A2cdKmzYlOXdDAdybKZ9BGi/cT76PLpxl+1AjjJb iOIqQe6MCjT32OiHFZxp5JJ8YimLJ0HsvBsflVM5f5YYmCpaF4Y00mLEJ5PkxrByPlH7 mJ02W9W8Pdk9rKcHfamHs0EMmGz1+BJItdl8KK1DhUYvaE/Zjy8INyBUHcSJzoRQsnEj JSD+TvHNu0UeBfFwJg8bM3emAmWRcJTHptyzVpvg8Ch2fIFF/OaCv5z70qWKxnE/F9BO rPQti1dE2zyPo4MluVk26pkbYv05bQqRCWs5FANMLlPPFs6KLNWXvwaEm0ptJPyCEQWb 95Xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=UMfTjBFW; arc=pass (i=1 spf=pass spfdomain=ellerman.id.au dkim=pass dkdomain=ellerman.id.au); spf=pass (google.com: domain of linux-kernel+bounces-61108-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61108-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUuYOkuWlku76JgFlAnDmBcVjebkuFHmmusuM1BRK8Z5G458T9U9/salw0A9fNqg0Lx4bkWcTIjDKjesK3d6xnFiX2hVhtxYWPAknS27A== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id dj8-20020a17090ad2c800b0029704c6e223si5860564pjb.113.2024.02.11.21.38.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 21:38:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61108-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=@ellerman.id.au header.s=201909 header.b=UMfTjBFW; arc=pass (i=1 spf=pass spfdomain=ellerman.id.au dkim=pass dkdomain=ellerman.id.au); spf=pass (google.com: domain of linux-kernel+bounces-61108-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61108-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 C3452283B7C for ; Mon, 12 Feb 2024 05:38:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EF716FBE; Mon, 12 Feb 2024 05:38:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="UMfTjBFW" Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (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 25BFB63D1; Mon, 12 Feb 2024 05:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=150.107.74.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707716328; cv=none; b=uI1Y+KdZDiVJTiu6u403f+Bl7oz+jopJE2aZpZEK3Cv9DxyrLcRJ/ZKrgkDa23hF8hzoGVtZ4Cunwcte0qwoyBHbKZwdo/l5u5EOkrx94KMNrgwW8NwhA26rWqdLKjpNkQE4KQp7ix0zUCFTxxJAkXvoBQ2ZEKsxbxKwhXOP6rw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707716328; c=relaxed/simple; bh=aYRQrR078wUpY+e7Eyetoj2fffaA5I00zmjESLa/c/s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=XJR3HVDIm90/7Oo7z2o45iEKvPPUr5A8xcpCXtV0THNiWh9BobbkHPhLfrqfxISGI/r5G4iwoi5w8qcNyJBv//O3jqm6h96BRpOTuTKQMzCA5r262DU+y4o5X4Ng+f9kKX4N39DCgzWV9BH6XIIUBIb7gVvHfQPga2RWJEvDkC8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au; spf=pass smtp.mailfrom=ellerman.id.au; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b=UMfTjBFW; arc=none smtp.client-ip=150.107.74.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ellerman.id.au DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1707716323; bh=WlznTFxLp/HqFR/zHSqL++eDGzo1KkY/I6UV1Hx6DCk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UMfTjBFWpNqTOIZvz6QcIVM3SE6n+B41vf/0Kvn85Pw7GDCUwInzDu6DTsJgwCaVy IMs4YMFg48fl9X+9RJUYaqR25O4+do2ND9cJpe41Y96p+hskf4xgEdJgFzBGjnMkrM XwSc3MT89EHjIjFFkDb9GmTOkaRWzDj9X8jy9+yCBwBUfgwQNFLYO5o6+oaChYUTyd 16sI7XC8aQ/58Z/ZAT0jqwMYhxKx2GYl0ue66fznbLpoIJkree2ooJSxmatRgve7ed nIbJPhvT1dXw7cKUOtD+ZGOd64lJlyD73eUMxmeqBWfNp/hm98fGs7DDvpkZlW2dSM aiOq9Dzyo85xQ== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4TYCtV1D1Kz4wyj; Mon, 12 Feb 2024 16:38:42 +1100 (AEDT) From: Michael Ellerman To: Kees Cook , linux-hardening@vger.kernel.org Cc: Kees Cook , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Mahesh Salgaonkar , Vasant Hegde , dingsenjie , linuxppc-dev@lists.ozlabs.org, "Gustavo A. R. Silva" , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org Subject: Re: [PATCH 60/82] powerpc: Refactor intentional wrap-around test In-Reply-To: <20240123002814.1396804-60-keescook@chromium.org> References: <20240122235208.work.748-kees@kernel.org> <20240123002814.1396804-60-keescook@chromium.org> Date: Mon, 12 Feb 2024 16:38:41 +1100 Message-ID: <87zfw66y3i.fsf@mail.lhotse> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Kees Cook writes: > In an effort to separate intentional arithmetic wrap-around from > unexpected wrap-around, we need to refactor places that depend on this > kind of math. One of the most common code patterns of this is: > > VAR + value < VAR > > Notably, this is considered "undefined behavior" for signed and pointer > types, which the kernel works around by using the -fno-strict-overflow > option in the build[1] (which used to just be -fwrapv). Regardless, we > want to get the kernel source to the position where we can meaningfully > instrument arithmetic wrap-around conditions and catch them when they > are unexpected, regardless of whether they are signed[2], unsigned[3], > or pointer[4] types. > > Refactor open-coded wrap-around addition test to use add_would_overflow(). > This paves the way to enabling the wrap-around sanitizers in the future. > > Link: https://git.kernel.org/linus/68df3755e383e6fecf2354a67b08f92f18536594 [1] > Link: https://github.com/KSPP/linux/issues/26 [2] > Link: https://github.com/KSPP/linux/issues/27 [3] > Link: https://github.com/KSPP/linux/issues/344 [4] > Cc: Michael Ellerman > Cc: Nicholas Piggin > Cc: Christophe Leroy > Cc: "Aneesh Kumar K.V" > Cc: "Naveen N. Rao" > Cc: Mahesh Salgaonkar > Cc: Vasant Hegde > Cc: dingsenjie > Cc: linuxppc-dev@lists.ozlabs.org > Cc: Aneesh Kumar K.V > Cc: Naveen N. Rao > Signed-off-by: Kees Cook > --- > arch/powerpc/platforms/powernv/opal-prd.c | 2 +- > arch/powerpc/xmon/xmon.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) Acked-by: Michael Ellerman (powerpc) cheers