Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp288708lqo; Thu, 16 May 2024 06:31:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDTkmCjaflBMRkW5VQD/4HnvvQf8DuCnyf19XD8qPWPnurjck9XrzJ2sPTPiy6X8TPYq+LIWOIYYYGuxbamkAo9hBFGVN/MFSfPuBNzw== X-Google-Smtp-Source: AGHT+IHEoDTkAq7+P50Xg9zxhGRqDtqFiM3ePbJWg35v5AfKf/Ud0kCF+gnMDafm8hsZyF1AkN6U X-Received: by 2002:a05:6358:4301:b0:192:ba37:f9f1 with SMTP id e5c5f4694b2df-193bb3fc89amr2286059555d.5.1715866290876; Thu, 16 May 2024 06:31:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715866290; cv=pass; d=google.com; s=arc-20160816; b=LQVRWrK15NaDp6cqrHyQZE/sdYq6mfeE+jbtG8PDbQ5grGKY/k4BwyOu/40R+AkdU5 ZYDIAhwCuj1xDnXc+xguzqsBmxt85vQSSEWmXG7DMKQKoEQD9xe/hw7KKhlhbR0qSpWo SgUpuFdGkWxcNL9kpgtCLYxevcrbs9uJLIMOmF6fS3xl3bZdk56RL9Z1B/o9gt7AAr8q VxCAkeqssgMtBCCaKey7AWj6j56GOzrSsuhtesSOs1QwAAo4FqrL4zh5GQZrnfh1fYhf veyFKTNLO5TQup0UxCvSFI9yduIptza+v3dF80qlzztLC0L1l2WFigtIBVH2dTdzfiLb QB6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:references:in-reply-to :user-agent:subject:cc:to:from:date:dkim-signature; bh=z8BnU2Is6DFB6KVcEKYw3pqMsABrzURYamS+ST69Qk0=; fh=IxTuRFC+h0aaOlpndK1eTjC3NAqmTDw3QCsU4hQ2DxE=; b=uJgIPmDg3xiPV2HJg2GEOiq0c/tfD9nxGs4YJOGozkNenoyji8B87Jq49/RF3zq6ey tOkEFqUg43o7Ah6KnAYogQh8N0zlJ8ud02PKOL/zMw7cRdrov2e0BIzG6YdWgVytD68w 8crPc1u7g2dVZCQe0crm+HjNpB/gsBOWa8MLn/G28AHYzEPJotcwGbSKRExVjiXB4ifk csQWlw2US+DUQPumEOd+COf/IVFyYmj06vXTgqSfkfadbF3yRUPk+MV0nMvSQQXW4c1l NJtB55Pq2miGqfB5fPpoMG7aLc9F8FgCNK3EC7HNqtW4mkyWDq6QfQ9YIMkCZmSIjr2u Z8ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="PHwLq/uJ"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-181119-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181119-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df5670a12si9220951cf.250.2024.05.16.06.31.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 06:31:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181119-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="PHwLq/uJ"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-181119-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181119-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 814271C2116A for ; Thu, 16 May 2024 13:31:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6504E14D443; Thu, 16 May 2024 13:30:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PHwLq/uJ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8149D14D2B3; Thu, 16 May 2024 13:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715866234; cv=none; b=LEaYEBiLTQDQAnvXm0En2QFJKnLvvTm/zBfN4pT6LtHJ6Y/8wBiZt7UJ/T/id0LwelL5P1Fq7o/jgiqSVNRx7IFxi0Qy5pC9CMAgAB6Drk23ZoA72ACxcuczGHuuDM4JezDWAQWbtAlwR2SiY4qdxUmBj7Uv+zKjju8jxR62PtM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715866234; c=relaxed/simple; bh=z8BnU2Is6DFB6KVcEKYw3pqMsABrzURYamS+ST69Qk0=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=ZItztftFVjxn/tMp3b9hZ4xEZnJP6wcl1Ji6HLngBKcVXGIHM2Q+JFNDwqunP44JLWwPd8hKahrUfpNYzSmbPa9ONg1oB6/ASUf2be5kXEIAS6Ennk32nUtD75E99y4jmv+OKysHAdGEyr7pVbyq+FyQxoTHIX+PUMwialGI+eQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PHwLq/uJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4131C113CC; Thu, 16 May 2024 13:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715866234; bh=z8BnU2Is6DFB6KVcEKYw3pqMsABrzURYamS+ST69Qk0=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=PHwLq/uJvoN0fU1gNykdMOT0phruqPrBSqb5l+yRgMUgegRuGl0R4RVb/VQNKldo1 mkkrYXbLB3d90j6KBRyAiuzhzE+wD7cwQViOMeIvc+RIHQoh4CRKYXTMeLoYtm5TD9 AOsZ4N23KBJIcUFYJtlyZfelrFo5K+/PtJG4THL+kze4j1SPTxfaW0h0xnSKkq198s JYKbDN/WqRLEdSEmlq8TnWU+BozS/3PKiVf7mdKMicq/hW3emTwXiRawbH4XAQIAjK Wc+YRgcTtWW2ykVjX2w7Pi/kOPaTnAIK+pItqhkJTz04bWGClvurKfg/r4q6DEohA1 CxGmVALL3FaTg== Date: Thu, 16 May 2024 06:30:32 -0700 From: Kees Cook To: Peter Zijlstra , Linus Torvalds CC: Kees Cook , Justin Stitt , Mark Rutland , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [RFC] Mitigating unexpected arithmetic overflow User-Agent: K-9 Mail for Android In-Reply-To: <20240515073636.GY40213@noisy.programming.kicks-ass.net> References: <202404291502.612E0A10@keescook> <202405081144.D5FCC44A@keescook> <202405081354.B0A8194B3C@keescook> <20240515073636.GY40213@noisy.programming.kicks-ass.net> Message-ID: <25882715-FE44-44C0-BB9B-57F2E7D1F0F9@kernel.org> 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=utf-8 Content-Transfer-Encoding: quoted-printable On May 15, 2024 12:36:36 AM PDT, Peter Zijlstra w= rote: >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=2E Now, sometimes that has actually been actua= l >> 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"=2E UBSAN finds them, and that's good=2E > >We build with -fno-strict-overflow, which implies -fwrapv, which removes >the UB from signed overflow by mandating 2s complement=2E I am a broken record=2E :) This is _not_ about undefined behavior=2E This is about finding a way to make the intent of C authors unambiguous=2E= That overflow wraps is well defined=2E It is not always _desired_=2E C has= no way to distinguish between the two cases=2E -Kees --=20 Kees Cook