Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1207173rdb; Tue, 30 Jan 2024 10:58:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVkkUyXW0KLoiIlOPVr95MwU5yEbPIVhL66zKcXB1+qWx+kw6b+6Ej13UywOPFYh9Z24jV X-Received: by 2002:ac8:7f93:0:b0:42a:3aca:3715 with SMTP id z19-20020ac87f93000000b0042a3aca3715mr2640276qtj.39.1706641131949; Tue, 30 Jan 2024 10:58:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706641131; cv=pass; d=google.com; s=arc-20160816; b=cJEg4dyXiu59bBLNYhd5V2n3J8La2gWORsUGA6c9jUO4z6aunFrvEV5K5L1GUt1E9C 1s/a3Mqjreo4fQVA9CMUq8ZMS3o5+bd6EFZD5dwI1X4zp+fsZf1+ZT0twm/pklrzn9Lc QVVvFQIc3XDH2qrEkT2cEHSZhAFvFyuPldsIo2jL6rWiO3fuvwW6KUUbXdwXeiiBnZND yKpdTFk1ZiLaignXwEg/GqqSqVy/vaoWhH4ewwOrJ3J7FcU2M4C662hF8zQril5AfSe9 sscHEgAoO7iiE6cyoPTOgEByrE8wKpvp7s7NecBFESgConTWB8SV8gSGV9zPdyGFjpSd VWLw== 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; bh=sQQdl1Z7hWzrJNQVbHBRvsLI1/jbn0qd6qXGr4XoIGk=; fh=9C6fGYcQMSl8wWwwS+cLLNuDqUOhVYOXywPRc5Gaero=; b=CIyfGRBwwJ306FpwTzXuHP6X5EmkZiu2Vx7zhMd8plg1rvUGnnZ4VKrBswNWqfnqVq /u6/aBtqzkGIISB2oRv/7sIAI1sDoBDGq6tUAlsSVFVp84pV2Y6OohcLiBLsG3x0bwk2 G5TPWQoC/pU6ynyA/z5fiYn8vMyF6Jy5Rm8tVLDlYiVK1/0Jl8i7kPf1dElO6hU1FCq/ zE64VIwx7V1wiRyfOo7S96EDBCFu3tOUXdx3zv8Qyzn+79dadZz5RL7WEdrZxMQG0x62 AYoOkJClgv63OKZNYVf/hdEqNFgXTmUgKsXpGLMeyUcjdzc+filrS5oaEq/+Rd79SdTA dcVQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-45152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45152-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 r19-20020ac85c93000000b0042a635c6a25si10462683qta.734.2024.01.30.10.58.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:58:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45152-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; arc=pass (i=1 spf=pass spfdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-45152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45152-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 939721C21BAB for ; Tue, 30 Jan 2024 18:58:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4ABA67994D; Tue, 30 Jan 2024 18:58:43 +0000 (UTC) Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (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 24B637993D for ; Tue, 30 Jan 2024 18:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706641122; cv=none; b=kRPXOKbexg8CpCAYhzxvUcnJZmTRGkkaWcp4gyn3Rf6xCzwur3X6CkLrPX2UUG019TK94PE5TM2gEFUhmRQm2cJbgDp9CVbEPf0f23yvt90CI11spXofh2+SPlqaTOBl1Bx90Md9IAohvTglX6ol1S4UouwHKDrE0+uPceQn/M0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706641122; c=relaxed/simple; bh=feOlOVjVoDFlYhJijI29hyyTBq3VHkJbnIkbQHkWo+M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bOIOpdav2sWj0GSXYVFZ5pkx7608QHEGirS3+Hfv00p830jk2jHZGbDA9bhU+5G03xAjl0egP1eIFKFuXsJZTX+PrSN9mkxipMEyuC2NTuGZj7Ft/6I4sh70Tnda5Lh8acG+aPE7B49K5jt9oHDJaaWFyxmbnXsD+tIAWUNQWKg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=redhat.com; arc=none smtp.client-ip=209.85.219.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-680b1335af6so1008266d6.1 for ; Tue, 30 Jan 2024 10:58:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706641120; x=1707245920; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sQQdl1Z7hWzrJNQVbHBRvsLI1/jbn0qd6qXGr4XoIGk=; b=Maw7q42p+L6eYhX1t7W13S8ijRbr1eaR5tju3Uq8I6XQXpzmP0JDyQTQdUphsPYbJd yFbk3y3HbN/4I60obNgtiluphtcAgXcypdEqdVhXCOr6xIM/bZJcrnsW3S2s3OtQHgfP vN4taaTXjESJHNMfX9ytLjRpabxpWt7n8amVNXlHPGQAA9gGaTGPJcg9YQMCtB3Qxf// kFbCQzEZabSDetGL1XTM93tj/0eHCPS1Wlg3v/FzHoobF9XxhXxt0VEw4YCSlAkO8qQn w1bkZtnQTPozT5swT/OSFLwvT6kY+1XZAwOquKVDgEE684Aj8Luv/itTG9Y6R4RvhpIg TUHg== X-Gm-Message-State: AOJu0YyyiIU8HxstTxHXaH9dtdNWZXHgv33dE1R36LzCuzWxBgrjnz5/ q0SpHQzFS5i0njQpIW/vxuTJ83ha/u25SKTcCjjVku2pOpPzXLsdoSQm2q4ZPA== X-Received: by 2002:ad4:4353:0:b0:68c:4b59:d4ee with SMTP id q19-20020ad44353000000b0068c4b59d4eemr1868859qvs.21.1706641120069; Tue, 30 Jan 2024 10:58:40 -0800 (PST) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id or32-20020a05621446a000b0068189e9d3a3sm4322738qvb.112.2024.01.30.10.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:58:39 -0800 (PST) Date: Tue, 30 Jan 2024 13:58:38 -0500 From: Mike Snitzer To: Kees Cook Cc: linux-hardening@vger.kernel.org, Alasdair Kergon , Mikulas Patocka , dm-devel@lists.linux.dev, "Gustavo A. R. Silva" , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org Subject: Re: [PATCH 47/82] dm verity: Refactor intentional wrap-around test Message-ID: References: <20240122235208.work.748-kees@kernel.org> <20240123002814.1396804-47-keescook@chromium.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=us-ascii Content-Disposition: inline In-Reply-To: <20240123002814.1396804-47-keescook@chromium.org> On Mon, Jan 22 2024 at 7:27P -0500, 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: Alasdair Kergon > Cc: Mike Snitzer > Cc: Mikulas Patocka > Cc: dm-devel@lists.linux.dev > Signed-off-by: Kees Cook Please change subject to: "dm: Refactor intentional wrap-around test in a few targets" Reviewed-by: Mike Snitzer