Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3147502lqo; Wed, 15 May 2024 00:36:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXigmLvdDyLDkNW+VbJ6Rxs/Dokw2OdmXjg0+4vLDQLpcfVsPx9lCm157Qk6ARZ8qQW0JKbgeSRVV4j3whz+xrn0qg3rxz1NpzkRhe10A== X-Google-Smtp-Source: AGHT+IF7/npMjorv5qIvj4JCTNkP2p2DuB/Ad7VqYL0etIV/zvnLoJLwVoi7sNefnbqXmtlXN4/i X-Received: by 2002:a05:6a20:d70b:b0:1af:d6dc:86b9 with SMTP id adf61e73a8af0-1afde1faeb8mr14802794637.53.1715758611347; Wed, 15 May 2024 00:36:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715758611; cv=pass; d=google.com; s=arc-20160816; b=vw3OtdtBY6wk4a/y7/wxmc0uknP6jDbagmjMr1JrNJtncA1fnCg+fiRJJsqwVlyJoD p3UAC4n26mt2pLW8+OYIp/6J7oPX2aceilKk2lfgfTG696X733qJFl75gt50SMxqRAgt wub/ABHGwi3E08qA1yyg/eiEW6YpYgY24JcbfENYUZKxNqhUnY7vEwlxFDXTTx7yWvsB NjWKb7kTr/aUOkxflqa87Dx7S9CMi2GkYT2YmMzVWBWRM65afHjod2otPqekOhCbzwsY gYt5L/pkHudsqYFUvBktwprZIPDaVnhyzNAZ8dLuAO1JmhQXMXRLzdvJLRgflA3Iutvy l9fg== 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=CefRu0Bn3G1FBcGR9MMrJgXqv9Ap5Ha9Zc0YkoqMsUE=; fh=kQ7HhUFwhb9nqukW1qynT86Dxj+S2/7AsT4MaSauL4M=; b=tM1DyktH5wvddFCETVFYOpMISJkMfsQKvL1QAE10pC5V1wjxvoSZ+JYm/YUsEU5dvc vyU3IOyxG2ENO2NvFtyhb/0k7erQ+mam6dyWterMe3fx3UUnjDVymxouryuGkjHtctlU dZtLv6cdvZIZZ6THFeOYlW79XnfUJff9ZT2okr05xyrk8yfZfZhbGGk7iyl7TU2TeG82 k1PJMIFIUli1ylpgsOblp1Pj/Yy71BjyBgFN4n/eWwDfLucEn0DbfyILn3807Y0PgbDi pL24RtLGOOANzOw4gGyr5ha/jW1W3n6ETwLWxtMsdB4kYXaz2fvJA7QuOr46hg2DBHKG NuRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="bkD/YtNE"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-179587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179587-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6340b2a0d14si13694118a12.246.2024.05.15.00.36.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 00:36:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="bkD/YtNE"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-179587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179587-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 45CE6281A8B for ; Wed, 15 May 2024 07:36:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E76E44C67; Wed, 15 May 2024 07:36:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="bkD/YtNE" 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 6183A5661; Wed, 15 May 2024 07:36:43 +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=1715758605; cv=none; b=FkRwCaJ85ygQfKeDoQz+BnLG6C6/slZNsROLNQjBo0UszZ+HH9HE9WXl1VvuPgGU72gfHWoeuI6nYi2PDs45x01reXabfNjT3v43HnIPnuZtxNSpC+rhruExVbZXFZai3kvCf676dGWwoXK/9bcn/sga/JgT+h4M1zqd0fdlLrU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715758605; c=relaxed/simple; bh=CefRu0Bn3G1FBcGR9MMrJgXqv9Ap5Ha9Zc0YkoqMsUE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iIVV5eC4yP8OTzeN4ObsPPq18Fkuagi71vIv/o9YTZm1VnpkIG2GYMZ+Uj3dxlAr5bD7aY5h05C1BU+meEPkKJ5BzJbTIuJdlCMrC35RzCdIMcJGk/weFWXoJCazz63MvK35KlX93o3wKET1I6eGff3wnAYa/KBZPT3m5kwKzaQ= 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=bkD/YtNE; 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=CefRu0Bn3G1FBcGR9MMrJgXqv9Ap5Ha9Zc0YkoqMsUE=; b=bkD/YtNEYdQRG1Ym54cU6b+Wk3 /00CQhXbI8+/nXZM83gY+riXCUgBmyDhIRyNKzRo+pGuy5mJjHjgZ8nmq5m4esoVj6oibp+HAgZU4 RTQgb6RNZJYr23Xh6UM7uMCw2eb4tmIoDZD2BC7Iz0pp/Y8WHniefEv2fUXMoH7WiPznGz57Yx/Vh W1vANy6uaWgMgYY5oOXBJyFifXNk7psgYoqk4eLIqeLRyk+d56sxx2VRkG15Q3CNW/K9ScsbYB5R4 k6BtyRFCM9vpJ7/2SzG+K6Apa3qka+PpztVrh2LCYxfU1dLgmJzbjbhl5Vkl1ZTaAeSuck/TdzmW/ qkk8MwhQ==; 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 1s79Bl-0000000A3Wl-0dEO; Wed, 15 May 2024 07:36:38 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 7178730068B; Wed, 15 May 2024 09:36:36 +0200 (CEST) Date: Wed, 15 May 2024 09:36:36 +0200 From: Peter Zijlstra To: 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 Message-ID: <20240515073636.GY40213@noisy.programming.kicks-ass.net> References: <202404291502.612E0A10@keescook> <202405081144.D5FCC44A@keescook> <202405081354.B0A8194B3C@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: 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. 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.