Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp156748lqo; Wed, 15 May 2024 10:13:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5oa6QfoDiX6QCPpd9R2FEsIv4p+8MW79pBt792L5eqrtgLyTbN51kea2MnFdqCJyHBfG8HydgotLZrpBInpdLr0cTvmJyRCNPD0d7PQ== X-Google-Smtp-Source: AGHT+IF5+8OFTKknzlLZPhaiAmBCAZ7mJzU+zelwxxKWBNgqh0GYKm/UJkzL5x7aRPpxAPsPAxyc X-Received: by 2002:a17:906:5411:b0:a5c:dad0:c464 with SMTP id a640c23a62f3a-a5cdad0c554mr117030566b.6.1715793202583; Wed, 15 May 2024 10:13:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715793202; cv=pass; d=google.com; s=arc-20160816; b=JYuTIXTi40aEqkudiAsLnoa+MMg+xTG0/c0Dafjx2UQMHGIo4UViDg0WMrteVJAPDI XJPaly8lkbfBoEU75ODaYlVHibUI2RjP8oZZFtlApffwETIwsLdZebEurZRsgdGNiQJk PolALDnsmctxVYSidNifyOAZQ21rSWspeRzPviJ/sIFRMtgHaJGIjWf0aAt0hpxXWIK+ innvsCpjFmv62CH3lqkBOlrU2JX8RsIW/As91sTpGDq2ct9SiP2Wg8jZzTQd1gNpRv7a JEMeucChY7iJrd/9/0mYVo8y/s65InqbyQZdVTwm0AdgQRltvbHnD4jdAbrwpRQq1Jg9 twGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=sFdFO/3PseRV0I24tfvAl/Tu3SeNdZ+dYLb3bjXAJu8=; fh=G8ACLWu0JRoytA77QPeLLRT97jgEE8M+GqZEwxPa/bc=; b=bSYYTbbrKt6x2vu09WIS3vkI6cmWSlh0Xys+Oj613hKDhBOyMeHcZL47nS8GB/F4zy YDECIkXT5lKgZITanN0/QD+7xQPDLX5Z5vCCJ1mq9geIVMqa/co70yxknMwWG1WW/jz/ rf/I2cR085EKTnyaI1qg4v3WJRCkESmTPC/TLUhrIB2IbNGuO9Pr0PDaZgvkXgqP0908 9YMqn16E8JnyhbZJKUSHjo/QEczWvU46t7LsY56s3M8vGhlZEu/GZmJ/GQJBq35ezhlz QSqfCkoX/0fFJiszxovRF7WQ8Qa8vdY5K/ErECb2kd23REDpvd8zWR3y9tOpSqIDn//E UsjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QSIZ8j2a; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-180193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5cdfa7acebsi16094766b.708.2024.05.15.10.13.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 10:13:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QSIZ8j2a; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-180193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id B99D51F24F11 for ; Wed, 15 May 2024 17:12:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D96D539FC5; Wed, 15 May 2024 17:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QSIZ8j2a" Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CF184C3CD for ; Wed, 15 May 2024 17:12:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715793155; cv=none; b=gXYx/7cYn2OIlgO40dN3qxqGlPJCm6vGFq/FTmAONozK7y2LqG30o5uCQm9rv21nNEymmlvBtzM0SsBfd4lNlN29qg3G+pCpD1eQYRV+klbGFZY6MlcETPwqOefP4CLZd1QY5MO8cW1hh0VM4qK4xtbtcOz3ofhK6Gu4FYdCMok= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715793155; c=relaxed/simple; bh=sFdFO/3PseRV0I24tfvAl/Tu3SeNdZ+dYLb3bjXAJu8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QWsRfcOTdRbYBOt/Wpm2rd1qyrE2qlgshoE8CZ+Cw4q4hnM8aS+LkbLDw1KxjoshcXwhjzo6tpf07MugOVsGIug1lUOf7f21Z2NMm0WnDWwXXAX9JmzWSNKuWr0nTbKAmH1STV/gbH01Wu5GnrF2jcqxCeKonOYhPuvPbBIofjM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QSIZ8j2a; arc=none smtp.client-ip=209.85.160.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-23f9d07829bso3425451fac.3 for ; Wed, 15 May 2024 10:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715793152; x=1716397952; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sFdFO/3PseRV0I24tfvAl/Tu3SeNdZ+dYLb3bjXAJu8=; b=QSIZ8j2aBzKVx6dFzUgfgxy4FxbPy1RzZSOEF/YtKW5zI2kRPd9V9sXohfMKvvfGnh LIAUgBErOhh9hf3cRKmJ1+CU/v6SuBPWFzseVylOOzQSCUiwEIZ2YAmjbqcr5EGHovNV PglXLUOMIKQXEVZb7WgTrELqyRLZEwPJuH7TBACQb9UMCBcvYp3M9yWB3/vUduOwqVek SMzSFUplHOgX7RvyTB5JlDn9Qt5/1/nElbYNG9wl5GEx/T1Q7xVU37CBEb/+wbPONmV0 g8VLgj3E5xsZuWd+DtjDvl4TEy0pmuMro5lqnnOuOnr+ymxbu1bOuA8lXIz7DYTqj0QX UdQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715793152; x=1716397952; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sFdFO/3PseRV0I24tfvAl/Tu3SeNdZ+dYLb3bjXAJu8=; b=buvEF7EUNWEc3kHl4oz1LmYEM1DkagOFPt1x3eACDMvsR5AEu/tYd85fRPFOZLP+/y O8ENQmWmUUgoB6ZLtjZ4NiQF0DGDcIcvnN3Tw0XN3pUCD9yzKNi0yc1Fxaek1qS+KFcD RDcpuIs3GK+Ehvj+FQPIKfODd8rwuaHNk4RUnDftgVlQofEcvL/LWn2ak9M76crsFqU7 kUZ4nq0xQO3Yqnh5e7i0RzL8CxLGTS1vPULjXRmca4IEO0oseRuRFiJ9iLIHD/QSks/W JLIy2GjWfNgzEWkyEszZAguZaaCeH+JT3cBiTCRS8uaA85hVsu8Elv4zlD5XPIDmhKbH cMTA== X-Forwarded-Encrypted: i=1; AJvYcCVkTzjVxcAHDgAdX/UhkqpPCV3RuoWANUEaqGE79UPvEkkEQUPgnVAM+XCT1Ft/vrbqLndj4ttyRXV6jBtt2iu9CcjXN58dKWoHVetd X-Gm-Message-State: AOJu0Yy6lM192svla7jBlRA8zZYDZUWI/htqqVyRlLbq9P+Cxy/gTX81 1H318GeHcZGVhRjPiz0zc6Jc1pAmEDcFz0rVOgbLsGvDWzgEk9U4wSu6sbk5/vglkawOlCqyjlf Bb7f7ja7hhS9+zG0w5dbch9Lg7L3gCuHWin4p X-Received: by 2002:a05:6870:1690:b0:23c:ee0a:260f with SMTP id 586e51a60fabf-24172a23552mr18594820fac.3.1715793152544; Wed, 15 May 2024 10:12:32 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <202404291502.612E0A10@keescook> <202405081144.D5FCC44A@keescook> <202405081354.B0A8194B3C@keescook> <20240515073636.GY40213@noisy.programming.kicks-ass.net> In-Reply-To: <20240515073636.GY40213@noisy.programming.kicks-ass.net> From: Justin Stitt Date: Wed, 15 May 2024 10:12:20 -0700 Message-ID: Subject: Re: [RFC] Mitigating unexpected arithmetic overflow To: Peter Zijlstra Cc: Linus Torvalds , Kees Cook , Mark Rutland , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Peter, On Wed, May 15, 2024 at 12:36=E2=80=AFAM Peter Zijlstra wrote: > > On Wed, May 08, 2024 at 04:47:25PM -0700, Linus Torvalds wrote: > > For example, the most common case of overflow we've ever had has very > > much been array indexing. Now, sometimes that has actually been actual > > undefined behavior, because it's been overflow in signed variables, > > and those are "easy" to find in the sense that you just say "no, can't > > do that". UBSAN finds them, and that's good. > > We build with -fno-strict-overflow, which implies -fwrapv, which removes > the UB from signed overflow by mandating 2s complement. FWIW, Clang-19 allows -fwrapv and -fsanitize=3Dsigned-integer-overflow to work together [1] And the sanitizer was re-introduced with Commit 557f8c582a9ba8ab ("ubsan: Reintroduce signed overflow sanitizer"). > > With the exception of an UBSAN bug prior to GCC-8, UBSAN will not, and > should not, warn about signed overflow when using either of these flags. [1]: https://clang.llvm.org/docs/ReleaseNotes.html#sanitizers Thanks Justin