Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2357166lqo; Mon, 13 May 2024 16:30:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFyy0FF2EZJKYCV3aC/QbpKRcWHvgQWk7r11fox/wE6HVOZ0Y1Ak2LZ75kmbnmUaofX2doGzzGC+eRDyXWaQ/SQnLJmoR5MYNYZC/LJg== X-Google-Smtp-Source: AGHT+IHAxIqum2op9JaYUZGVqCiVVrKg+lqEkQREf/MdqPxAtZkromPB92QXFaK22ZBZhF6OQa39 X-Received: by 2002:a17:906:408f:b0:a59:b491:5d79 with SMTP id a640c23a62f3a-a5a2d585a7fmr698575866b.24.1715643008576; Mon, 13 May 2024 16:30:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715643008; cv=pass; d=google.com; s=arc-20160816; b=HE9YIStefgcytHxq/f63OCO//xMiTpvxKauRglYQEVZ8B/4E+7VhxVT2aLbI+bARrk hhJOwNE+ofY4+id+nQQNPhXhcvbC/y8rKhF4ECXAqkb3eZBAkmohXTFBgsDsPKTp0+C+ jBMxHgcv376pyoZVjxT78K9lllDA9vQzvLxGfG8ME28pYFvqkhLJjy8TyoZiJbXXQbcO Im4yUfLSndk8yxbYUhakLRd9LZmiWUtEFAkwb5NlTX2idk7lxLgk0SMa1LTt/Afi9xoJ aoNC1H8kvFqieGkmudDd0mr2umK8dUlBUpJC9Q4nJPnFCbjBianWWN6G8E64GOHEku+W +x8A== 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=E1EiMHldIKpnCXznyOw68lbbiSInf8wRIhCrNgk+6Oc=; fh=SzUZW1TAQPSqkoHwJKK9IAnAR51O2hQMn6jgV0EJq98=; b=OKC5ebol3tgMUZDDZj79T3xNLfvt/mgCGWvR55D5Norvygbio1s/3fqBnC2m+yqoal bRwXi9tq0kB8ARfnP7PGdfsSFGJOv1tOCuY5rmRYRZIdzXOb7InfHcPBDC3LwB7WYez8 dAH5wY91dSmuA8rlOYxwlvGs3gpRIo2oBj+GJ0caFQwv/4IEyGQ6jHzfvc+mWCpTAFWB LYmSy/uNs+PzAu4npmMqsYrdA8pb1zyzVGqh00EggbB8leDqJW4vTaGjqOqxXzZvpIN2 dmkqPYNtHhmDdcg2gUvq/2WOWPcxhweFJ9y2Erm35K53VcI4FQxIoGoqQu4b9JcmWbsF 5Ayw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E+9qOxFo; 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-178177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178177-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c041f9si549176966b.891.2024.05.13.16.30.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 16:30:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E+9qOxFo; 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-178177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178177-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 501EF1F21B85 for ; Mon, 13 May 2024 23:30:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9B2585920; Mon, 13 May 2024 23:29:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="E+9qOxFo" Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 C58C185622 for ; Mon, 13 May 2024 23:29:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715642999; cv=none; b=dpZNLi93pNL3zAgRr+TVespzVM9GkLwzKTwfwwN0yzQC/SPOSTn/iTRYhfvXTfEL6M+GKa0uv5dLSF/d5WsjvHxR5sAx+ZWMeZZL+wIv+za//7nbW3xkVQ7Mok4HNWJMwsh9wAxeGiBZPmNjWhbp5E2+ty/6FNEQTe4IKLnGCxk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715642999; c=relaxed/simple; bh=dH2Gh/VfvRAwRMCapomFJKaaLGs4S106axXfgAQnxwk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LcI7r6NOe3uGD5friYTZdz8/D7f2OTG1u51Tep0Mo2o3AaEyUy+9mq8AK0KAT5q7wy7kmPGVNKLJDBhtVXm6/vcd0vWEZIXUrMOBvZlJv5rlVrlxOSwZRZvjynpEs+6r3Na3URkrAzQw0IcmDQRDq/C0o/vM+I1R1jsmHSRT/Lw= 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=E+9qOxFo; arc=none smtp.client-ip=209.85.214.171 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-f171.google.com with SMTP id d9443c01a7336-1ec69e3dbcfso38312275ad.0 for ; Mon, 13 May 2024 16:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715642997; x=1716247797; 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=E1EiMHldIKpnCXznyOw68lbbiSInf8wRIhCrNgk+6Oc=; b=E+9qOxFob13JIPIC5cT6NMCA2B4ps+qDxxWCfilA7S4BosMJXZysKJQRzHPAhkm6kQ IsDZOw+qy9yXTRrE9gCQv/ZBP/HhNkIDrb+7ggPXTgHLZ+yZy8bOgp0eiXbo2ogJQbVI 9utsRakgMwoYQhiHPW+GUEmHHs2GddTP48p1w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715642997; x=1716247797; 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=E1EiMHldIKpnCXznyOw68lbbiSInf8wRIhCrNgk+6Oc=; b=cfGTFsSUj1tzhrQUoKAiXKly6D3GX1uhFg5+mKnkDc5qUeTqWwPCHmF8SWqu340KXp QESnZjmCdrI0jJt8D1Cwkt9ECzRPyWPKLlUrccVgOIY2ySAbC2GCcx3xJ8NZo2L4eWPN 2rbkZX8K6HyIAotlZRjsatAcOOX8ehqNsJG2y8XTlyeueT1HBCIdSUN5Y0r1YFHSiaJK W/MuEWh/Yp5L5JHuWk4iGbZQ3DjM/Cehk5y5gUNO/4BtUuUBMe9gCLhdRCIB9/viHfrg oDqTM1ueNfclcovX0u+UIz4yWuYGkUu5dZRdO2nJmG6lMgIEEqr4qh9t7HyuNzgLlkNy v1zQ== X-Forwarded-Encrypted: i=1; AJvYcCVGMX+jYhv22WoK75oYrVPAFT26EqJ61CuhFkPt1JX0pIoRcGQYb/pju16PXXvCl/E5AmfpjwIWrwiKzau0w+KP4vsZdpvBnUctphqj X-Gm-Message-State: AOJu0Yy9dfethSDQYx2m+iP5Gzo9brMDEYgNKEhlrDiJL6HEwAvVISwC rDihuqefStJ8MnoLcmDNuE9CSfRwfmoTkKW2/nVrAYFwQjx+ZKU4XTusWSDq+w== X-Received: by 2002:a17:902:f60a:b0:1ea:a87f:bd2c with SMTP id d9443c01a7336-1ef4405a80cmr134147885ad.68.1715642996861; Mon, 13 May 2024 16:29:56 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf30c09sm84557115ad.130.2024.05.13.16.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 16:29:56 -0700 (PDT) Date: Mon, 13 May 2024 16:29:55 -0700 From: Kees Cook To: Justin Stitt Cc: Alexander Viro , Christian Brauner , Jan Kara , 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 v2] fs: fix unintentional arithmetic wraparound in offset calculation Message-ID: <202405131629.9C315328C1@keescook> References: <20240509-b4-sio-read_write-v2-1-018fc1e63392@google.com> <202405131251.6FD48B6A8@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 Mon, May 13, 2024 at 10:06:59PM +0000, Justin Stitt wrote: > On Mon, May 13, 2024 at 01:01:57PM -0700, Kees Cook wrote: > > On Thu, May 09, 2024 at 11:42:07PM +0000, Justin Stitt wrote: > > > fs/read_write.c | 18 +++++++++++------- > > > fs/remap_range.c | 12 ++++++------ > > > 2 files changed, 17 insertions(+), 13 deletions(-) > > > > > > diff --git a/fs/read_write.c b/fs/read_write.c > > > index d4c036e82b6c..d116e6e3eb3d 100644 > > > --- a/fs/read_write.c > > > +++ b/fs/read_write.c > > > @@ -88,7 +88,7 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence, > > > { > > > switch (whence) { > > > case SEEK_END: > > > - offset += eof; > > > + offset = min(offset, maxsize - eof) + eof; > > > > This seems effectively unchanged compared to v1? > > > > https://lore.kernel.org/all/CAFhGd8qbUYXmgiFuLGQ7dWXFUtZacvT82wD4jSS-xNTvtzXKGQ@mail.gmail.com/ > > > > Right, please note the timestamps of Jan's review of v1 and when I sent > v2. Essentially, I sent v2 before Jan's review of v1 and as such v2 does > not fix the problem pointed out by Jan (the behavior of seek is > technically different for VERY LARGE offsets). Oh! Heh. I was tricked by versioning! ;) -- Kees Cook