Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1205923lqo; Fri, 17 May 2024 14:24:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgdu+EmlGTmMVysO643dR87FfG+t19CLfyZVjWQTOhrD7lLhcqQHTin8t+9KoMC2uxECV+SE+vZy8J9AN68qp4CYRgSbpAXchtIOVIGw== X-Google-Smtp-Source: AGHT+IHDOYk2gxg/LO8/uqNAIyTrrHR9NhCQLPZKqXFZMTUzQrtzisJ8DNNofWY/irmtgzSN6m93 X-Received: by 2002:ac8:7f0a:0:b0:43b:af4:f2f2 with SMTP id d75a77b69052e-43dfdac2467mr232599991cf.14.1715981072806; Fri, 17 May 2024 14:24:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715981072; cv=pass; d=google.com; s=arc-20160816; b=rN4oq2Pc/U0y4wniaGAbnc0tgk3p6lV5+zfJ6lfhsh7nFO+bnp/7TvP7ZBPXwdYSTw DVM+RQ4sqSayXziYIO7ps/AdMy1cRZ1Kk1/O6no3vPPVi7RIzUmjbGJQnN97bQgDm2CQ MyxXAgGfeMd05lZNc36tNlAsDEnSNXn0FgNsK6S3alQfI3dmCu5bxuJ6cEeBkZKHp6SS fjUpOXQk04JXROl1jv2bbpJVfuIpkV3dUm45r7A7tgvBNfnJ/+sNj43DR3jLxTAFIBIq fLOcuITtZBQrgnLBk1vfsUcVqJGrGDkUBXfffu1PN4Fype+YSxgWPKs8iEgEr6yYZhsz DO9g== 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=nZePBSOIoDFc3SJ8gpxBa7DmK4+hYpUiZT8OtqItIpw=; fh=fLTkaL6QMnbrzePn2Q/aqlFYfLTK3pGPFNZ0koA/mUQ=; b=fRR+Lud1QH5QUVJCsrNfE/pbexJ8TbQQS0ZToSCADM/0VpspdD+cJ8ZAW4VOXGvJKZ FRNpTfLDM+nBEpiIsRdo9FaNMSupaIzSX0Th6NnOPWqQFvqHkIbDxVJ1pfBFgt9xcUiR uadkydxQFinC/X4/EF8kMIPTKbBoCCTq68P8RQBsDpiQXv3Vww6PL767u/8G1ARkOJKt orV+YC5zYQRZbm+0RAkXtlZOLDcdUOW5NRAw6uWZFunuglccQRH8NDyHOjMg/8a8wtwT DBsA2CdR3wg7NGeHzEtr4OTcHK4kNrd16fMQeamWBv0Azl6FIdunX+HHdbrLeSaJa11g 42zQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=V6VNs9MG; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-182636-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182636-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e2ccbef1csi24930431cf.608.2024.05.17.14.24.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 14:24:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182636-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=V6VNs9MG; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-182636-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182636-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 8A3031C212BD for ; Fri, 17 May 2024 21:24:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 278C21411E8; Fri, 17 May 2024 21:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="V6VNs9MG" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 040AB1DFE1 for ; Fri, 17 May 2024 21:24:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715981061; cv=none; b=a/18U5fkIcUH9m7cxn4NoihGE7prCIYjftdltK7RjTlaWiHTEEScPh4qGSZL0fZ7BnP8ckYXMS3ZnP3ocE9htfU4zEBjUjtSE1gPBWqCveEsv7WDBCaAYoAJkVfiDEN6eyl9xEHaBhS60KtL0KUp70v/Poj+pvm3cp1cQmXcBpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715981061; c=relaxed/simple; bh=IfJYkc42KzwKWgTt9YCXYbwQ78/cdkAW+9n0nYrQkT0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=I+tFycqZlaD5ClhBeDdoOKrl2Pq3MFNBT7yV1XRaZ1nrKw3vZcjVkwFCo63oiYv2LNIIBNz8mkJ+GQoSC6MSwxyL9SUoaUWHDuMcAAqVJZv2Nn6PbdHgqo/DkvyAzylIz5t/kYADOSShoj9P3/7mnsT2YKwStQYZAncG0oj8QXY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=V6VNs9MG; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1ee954e0aa6so23077085ad.3 for ; Fri, 17 May 2024 14:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715981059; x=1716585859; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=nZePBSOIoDFc3SJ8gpxBa7DmK4+hYpUiZT8OtqItIpw=; b=V6VNs9MGHBDRDRF5/nhVHVDUsUgKERAAIz3nPJExq336hvd0OSlfcw3STpcM0wO+ys TfHDlBFSdArqjPr8ur9ElSFq2KpF5JlnLl74Aike7zMX1etlakJTCklkAcTiQ/BQZbKV mKrjqyeBeXKvjPT3dHEM04PCge5ek8bKMxVck= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715981059; x=1716585859; 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=nZePBSOIoDFc3SJ8gpxBa7DmK4+hYpUiZT8OtqItIpw=; b=NcAN3y8l39mOjEy2VzsrLeG26TLSE7nSqaF3YjLjqFLFGmPtNcFa/OjBCcTHKsjG+4 umJL2JOVMaJyOxosWNw1gyZZphrmkOzzHRDmzpUQdtRY4LLh9+Eiy/SMlFtjWKdlFRkb jAbrUi5jvaQ13F7PsJxJddI7TWdJ1BBBhXresFHUSaS1H4L5XrkjGootqP3zgq12ZI6J Gc/kalbaPTap+TNsY03z7NndMxWB9DncW8YF/Qn6ZQzW1On/KbIeoz3e4jN5AGVDAj20 KceLM9U245xhQFZnCuOdVPWjxYtxi4NUN7EjBwU1+dgZ1OEoCUv2LJiN1Bz1gc/EY4O7 lwRQ== X-Forwarded-Encrypted: i=1; AJvYcCVZk2W6FybaaaJ9Py6OUkznmHjl7dOrgQw5hCTMztD3zy6BNEgSa9YPQXSE+j9VL8ar3oomWOhq6s9LJBqRVJI+Br0H/bi5TXepxZIY X-Gm-Message-State: AOJu0Ywzn83OSbLGAbYcJGv9erdW5Gax+mh09I9YlWn5uEtb0HYGL7UZ bBX+yPIiBNj/mg5yblQDyM2xiwdYp04atvIscpXHu9ef9hdssvAVN1mB8jMgwg== X-Received: by 2002:a05:6a00:9290:b0:6f3:e6e0:d9f3 with SMTP id d2e1a72fcca58-6f4e0385654mr24139207b3a.31.1715981059389; Fri, 17 May 2024 14:24:19 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2a817cbsm15080510b3a.58.2024.05.17.14.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 14:24:18 -0700 (PDT) Date: Fri, 17 May 2024 14:24:17 -0700 From: Kees Cook To: Al Viro Cc: Matthew Wilcox , Justin Stitt , Christian Brauner , Jan Kara , Nick Desaulniers , Nathan Chancellor , Bill Wendling , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH v3] fs: fix unintentional arithmetic wraparound in offset calculation Message-ID: <202405171417.B290C50A@keescook> References: <20240517-b4-sio-read_write-v3-1-f180df0a19e6@google.com> <20240517012647.GN2118490@ZenIV> 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: <20240517012647.GN2118490@ZenIV> On Fri, May 17, 2024 at 02:26:47AM +0100, Al Viro wrote: > On Fri, May 17, 2024 at 02:13:22AM +0100, Matthew Wilcox wrote: > > On Fri, May 17, 2024 at 12:29:06AM +0000, Justin Stitt wrote: > > > When running syzkaller with the newly reintroduced signed integer > > > overflow sanitizer we encounter this report: > > > > why do you keep saying it's unintentional? it's clearly intended. > > Because they are short on actual bugs to be found by their tooling > and attempt to inflate the sound/noise rate; therefore, every time "short on bugs"? We're trying to drive it to zero. I would *love* to be short on bugs. See my reply[1] to Ted. > when overflow _IS_ handled correctly, it must have been an accident - > we couldn't have possibly done the analysis correctly. And if somebody > insists that they _are_ capable of basic math, they must be dishonest. > So... "unintentional" it's going to be. As Justin said, this is a poor choice in wording. In other cases I've tried to describe this as making changes so that intent is unambiguous (to both a human and a compiler). > Math is hard, mmkay? > > Al, more than slightly annoyed by that aspect of the entire thing... I'm sorry about that. None of this is a commentary on code correctness; we're just trying to refactor things so that the compiler can help us catch the _unintended_ overflows. This one is _intended_, so here we are to find a palatable way to leave the behavior unchanged while gaining compiler coverage. -Kees [1] https://lore.kernel.org/linux-hardening/202405171329.019F2F566C@keescook/ -- Kees Cook