Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp470134rdb; Tue, 23 Jan 2024 05:28:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOpnrTWcg51mbN2vopHTAJtvTmIWKZsCbq91IX4xhRX0FI7d/Ax8jjZ4mJLdpV+4sL4a2c X-Received: by 2002:aa7:c887:0:b0:55c:6c20:30ee with SMTP id p7-20020aa7c887000000b0055c6c2030eemr923759eds.67.1706016505427; Tue, 23 Jan 2024 05:28:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706016505; cv=pass; d=google.com; s=arc-20160816; b=I8mp3zGZNgJo+CBn1njr9PTtHaGwO7geQBlYW8cJqEFvmHH9RPmi/evEAN01V2KYhs zSvrBqYQKj/b8UTKICIdfVAVQPU9RBJMxm9k5xMHmBXuYDiUqd2DlJeXY7pmLUGR9Jx6 n0fkA68M6fnT5QOjFO1GbHjDfiSBNhptttdFpMAocL87V9/LQXAH2mRDyGBDr1HFviPk naLLstpli8o4aFLhj39ag4yDhf222qjsej4WlNd6ClFUtGbQwFDBQ38kDz9o7pHntFKD xefCCi5DVG1tfxxAd+ClFXOpiDC4+K1QbnpQxXcDjgSegkT8/bkFXc/C5kgAcpc9Vtn7 UNIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=MekZeo04W4l2T6cfSCHs6gxgprEUy7guSaTk64clLUI=; fh=CNXfPFVg7r/tsMhyrAq3s8/qyJwUewd24NoWJnQNdVU=; b=zul20wzLSPS58qSLW7Cchjn9KjkbxrhiFjAuqpOKwoEZvBgys4dBqEfmDibfI03For PXHgpKiy5f3lvxmVyYECW3gBPytqHjTjIKDkmy2uxTuksaGEaP+IWGi19Lzo1INUWDUS C9GMrin2F7X/hThL+PCwv4ids/hAhm3JxA7bUwL/upcu7sDPBLWEZm/cjAEnDC2lSy50 s50PrydbMbkSrhRS+HPuTrQoqzcVAq+eHDOTHR+iDKfTZjPf8rNlGFLVTuWhXnYDHMAG +YOEsjdUyo5iUJuLflBxVTbF4MUpVOtCLraC1h85FqmiHuyIF8L6a3FfTi+oppER1V91 EEkg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iqyKIT1k; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-35376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id fg14-20020a056402548e00b005593aa5dc6dsi9693287edb.241.2024.01.23.05.28.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 05:28:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iqyKIT1k; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-35376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35376-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CA2C61F23793 for ; Tue, 23 Jan 2024 13:26:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C2975FDDA; Tue, 23 Jan 2024 13:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iqyKIT1k" 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 7204D5FDC6; Tue, 23 Jan 2024 13:15:10 +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=1706015711; cv=none; b=Z7kWdMThmQGQRzswc5r7/pCS1o+TukAFOAzrSQT3hEN9L6g78Woz3mZBef02s5P4E3VUqfn50BhbNEryf4zS0l+DqNSvYXMEJDGhD5Aa3aqPGTG9WSmQJNubpq3SdvD1BHiC6L8JvbjKhxsVkhtDq8q2MakhLs8dog7tXXAwnyo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706015711; c=relaxed/simple; bh=g36kRqAa0AgkhntszfW+Li1P753t4sRZLsilj77aicI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=r8DoRGzz7wxVd/FJGyCpiICR8IBI4JlNfdr8+zJZ4QdK1A1YocCDD4hXExsUJGE9mEuBFsigYOOJkWj+R3bAC03ZuZL3U1bz9BunjRU938wH7vZ9aJmKcMJzgHXfTRGmDWGJBhtI1cnhIYGs/5d9hvGnH8w03R/m92Z4TLR91/k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iqyKIT1k; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7416FC43609; Tue, 23 Jan 2024 13:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706015710; bh=g36kRqAa0AgkhntszfW+Li1P753t4sRZLsilj77aicI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=iqyKIT1kfJYPMsJxo9qxT9J0nDYQzxvNmRvsQejyWuYop39MCb1vgQiMaQx8jvMBX AFBPjG0+uswaMuVGpteF5Xl6HNCwp/d+A2WonyvMasNQlMRpfhwJDskEAxXF4uCpJA +5SuEmWieVMdWTB4Ee7NAUE/NzPZuRAzZTEeUem4MX4bauZFqdirBJdb6EPWz+9b8A V0C+wg6MAOet67uIcsTEsoDyvghUlWdbpNA0rijXvhFRq0rs7MBOsVnBHKs9CS1CMz 9mCskjhDEnctieBZa4je2CL+Z16NyDTbgn33FHW+1HHxeCFvyGeU8i9BtyhcI7H2yx tYdIOc6ZLsqLw== Message-ID: <5bfb2175-2470-469b-b3fa-9f14fae08536@kernel.org> Date: Tue, 23 Jan 2024 07:15:07 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 65/82] nios2: Refactor intentional wrap-around test Content-Language: en-US To: Kees Cook , linux-hardening@vger.kernel.org Cc: Jann Horn , Ley Foon Tan , "Gustavo A. R. Silva" , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org References: <20240122235208.work.748-kees@kernel.org> <20240123002814.1396804-65-keescook@chromium.org> From: Dinh Nguyen In-Reply-To: <20240123002814.1396804-65-keescook@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/22/24 18:27, Kees Cook wrote: > 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: Dinh Nguyen > Cc: Jann Horn > Cc: Ley Foon Tan > Signed-off-by: Kees Cook > --- > arch/nios2/kernel/sys_nios2.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > Acked-by: Dinh Nguyen