Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp194070lqo; Thu, 9 May 2024 17:49:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVu/ktimxrqTBOxreSgAYHOOvFD3xvtbEju3enqTiw63CRYLgj6pegE1mgF6KkWIN600G+vZJzIpIHygpuWkOocVfmrw7s0Ruge0pb3UA== X-Google-Smtp-Source: AGHT+IGaasb6bTjW1hq63+4gl7sYog7ORoyRLNdHHWZiVt+gr7cpcaUQin2DJD6S+lKLj2xFSar6 X-Received: by 2002:a05:6214:4342:b0:6a0:c162:2944 with SMTP id 6a1803df08f44-6a16819e83fmr11859696d6.29.1715302168060; Thu, 09 May 2024 17:49:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715302168; cv=pass; d=google.com; s=arc-20160816; b=0hhW52QNL4D3fUQniwg51oLpWwqXCzDvVnYrfA/C6Dc+8n27/iM/ToltWE2XC8cHXj SMdRWhl66XcUMdxG3neXReiPGmWyaZZDScisqNZoDIZKc1J04AEgiKjj6fpQmAbY9kyk +bvcPdZ1q6z++BTqUEFbQNOB1P0n87CtqMHf4N2CeFIw5c/2UIpgfPlS1btPyFo1USmz AztJvCCHxCP4VO2bL07GEX5U+eAWeAbUk42cUodgyT+RRyJswdD1E5R/xNcZYoF/ISRO vweqXwDlcAZhGHtNkWcl5iducWEcR6MA8tP51k6hYDD0mr855iMRf//e/Us9wTn+ssxa PJtw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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=fJHHsV9OVYCdiIXyI2ulel4nF4HT9OKeM/HlpsXG0Gw=; fh=rVaxhcuFXLlAgeiN57QjWaNNP4MqBeg/iAPeZMBm6Gg=; b=ufB6XgLwh3Pi4T2CWqHppNhGog+hUQbWaSnTabqorr/gWlvg9LXnJeom1GmkYy8xRI 0nOUWHgJKcPcdm1cIiEix0zKCvOpl6uC8X5t9MIlcCOMt+QPHAjRs1G24OoYLkpM9so4 j9MqmEcOt8yrQSONnw9IiIVpdGAlP0/Q4B7YlBDzydDwOBA4EH1+lMnVcoyIAsUhKu3H xmCocIe6xINd9x2gezg4ZuUK8rz+VrWXPoHM8DIqc5y1UJLFBUrkgCXzw+wyFFWmno/T /4AXABjjJYtEJjyXM058lmV9/V8Y8PSD2ojNaJ+q98dMrp2fmxFCeWN11hUX/Mo/1ga1 AESw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=T3WiZ4yo; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-175182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f2eea5asi25218126d6.454.2024.05.09.17.49.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 17:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175182-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; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=T3WiZ4yo; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-175182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk 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 C3EE01C2179F for ; Fri, 10 May 2024 00:49:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03AF35235; Fri, 10 May 2024 00:49:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="T3WiZ4yo" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 278967F; Fri, 10 May 2024 00:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715302156; cv=none; b=T4jrYTXAt0u+N7dxjW2b9b4xNpgWfLRJTK859h1J1FAxfX65Ped7r5cHU0MPxCkUzBSGFeEJqXYbYofH2Twekrhqj3sgJCAZQZfbO33/KFjLXB10sdPo40Zd4NaCG6qJHPM4nsqe30XKuASFZWUGwJcYPy0+Abb+L7pG83t6jMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715302156; c=relaxed/simple; bh=qYhCSYTs+qCd0PpT/L634psqhkgm3QsohLmZ2vDK6WY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RApezEPMt14SRJaWroxl8MAMqA1c4/gkRCuJg+2VpK8Or5N9yqYHF0UP9YcZ9+QjIT+7DV3UO4NJ999acJB3gEuZdWljswC3ukoS59tJQ3SCZNhgcm2jNCPgZmIRZr9XIO6RViCp6kU4xsr5+uaj5GOF+GR10TFDcNO91fXwWLI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=T3WiZ4yo; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=fJHHsV9OVYCdiIXyI2ulel4nF4HT9OKeM/HlpsXG0Gw=; b=T3WiZ4yoTea+vAJZNjsd0wzHq9 9STf//iLal1+tt75yZwzT+7q2LWK4trDJGyeQmhOS1dxvVini8GlYKTz+td9pl5SaeML7g787dLex 4FqveDpVNvQbmTRidJvfONiFCR168ZHbLeoI7AGqUF7JTZGWp+W+yrYU3RiY0PL+wlMDAvOzqu9ui YBJP9GsjbZyPo2UCB90ITMBvp0UVHBgK47wdODadZFDdMuQTPpg8P/WSnH5T5pEpSkZfepyNcbuD1 93ZRSsoE7j6YSOJt6XR2VNBjG15BBh1iNd57HPyat0RPidSPGXiaObnmZyAX+USMG/e2xNU0NXPF/ jLe1APfQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1s5ERe-001tr2-0H; Fri, 10 May 2024 00:49:06 +0000 Date: Fri, 10 May 2024 01:49:06 +0100 From: Al Viro To: Justin Stitt Cc: 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] libfs: fix accidental overflow in offset calculation Message-ID: <20240510004906.GU2118490@ZenIV> References: <20240510-b4-sio-libfs-v1-1-e747affb1da7@google.com> 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: <20240510-b4-sio-libfs-v1-1-e747affb1da7@google.com> Sender: Al Viro On Fri, May 10, 2024 at 12:35:51AM +0000, Justin Stitt wrote: > @@ -147,7 +147,9 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) > struct dentry *dentry = file->f_path.dentry; > switch (whence) { > case 1: > - offset += file->f_pos; > + /* cannot represent offset with loff_t */ > + if (check_add_overflow(offset, file->f_pos, &offset)) > + return -EOVERFLOW; Instead of -EINVAL it correctly returns in such cases? Why?