Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp231495lqo; Tue, 7 May 2024 19:26:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfM4DysG5bGJ7H6wYYDoIWrNhOnDsdBbT0VywazDWo0L8azwKf3QO6i7wYctoi5hn+ZhxeLxA6UV0uLN6AC01ZzGiLw6ErC2BBy6nXjw== X-Google-Smtp-Source: AGHT+IHcv+HC3FNRMj/qF1dnB667J5mZjZAEuXSI0CRKliqUprTx2wdcjgKRZJvz65Aw0EG/XwCR X-Received: by 2002:a05:6358:65a8:b0:190:47ea:71af with SMTP id e5c5f4694b2df-192d2c2980amr176737355d.10.1715135203380; Tue, 07 May 2024 19:26:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715135203; cv=pass; d=google.com; s=arc-20160816; b=FUE3S+k2XSuiECxPf4yxFOmKET8MN9Bexme3usmgWPn3TvGo8Da7tb6t0xfaR7Vo5x jAbLwDaM5OacBrntjCJHRXypPIEtSYFwYApUihWg5aclSP2QgbPhuvMlfvqO/ot/Zgcs bvlGBtqHbXKUYuTOU5PKo2cUTXUHAZhWfiEfYnJhJ3+rjlCIcOofm8NHVvC3ouPiBSpH NoRui9jFcLOuLkwX+tWJFafUqPjESfSU6Uqn6G8dF11hAigybcbilkj6BgBFfcW9aUlv f0xFyyoTTJc1xiGO8wKBfCP60EQceKZstUNL6vyYOsXXzIWqPuWP3DHdPbhMHNfHe+os B8ig== 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=NVQn8FCJNu/q/zyxmyFJqZeFeLs4T6PNqpKVzxlwdOQ=; fh=AHEU8Ye/cIABuHqRMRZKHoYB2kMWKIIqwXRRnJyWbkk=; b=GlGacp4C5FJyXGP3oWsGi15yDxk4FxfEF2UpO/h7dBB5rGekCXMO9BcDinz5dRQhum zVGTt7MdT1V+2U/eD7WKLKbW20+P0T6UDGx7bo4WIOplHEwrasFgR1B8CIS/e/Nl/sZT q9hhz931rU2qiD6hMMFiA4d9Dz7CwD9im25KmnXccJnL44cQyuj83yQIj4WxLxIQ97gN oavG8rBgR+O/roWGBGz43hKGTTC2/gWJX3jzvzVP3yLo4mc6lIpVL+UQquvob43zfWwt 4SbMk00VPuPKjoQk0Bd6gjCsF11CCzgNT2tM7t/5ArxZ8+6gq1dLoxcP2/AoB1Sxr+34 tHig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iCYEKP4Y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y125-20020a636483000000b0061ba9dba93bsi10426597pgb.27.2024.05.07.19.26.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 19:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iCYEKP4Y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172625-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7440B2818DC for ; Wed, 8 May 2024 02:26:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95CC5BE7F; Wed, 8 May 2024 02:26:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iCYEKP4Y" 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 B57B22563; Wed, 8 May 2024 02:26:32 +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=1715135192; cv=none; b=e/nhHVeh1Dh72tJTiOgUoULopxDZFNaKm5DaIo8M987j2yWSc8xsWMNBvTXBfvIEZ8RJ9X7sdtGhDhxyJJcWbUPhlDksG52ug4Bfjd5sEkK84W9kOLWrwuHOBk4SccerG3IbfC/u3vF3iDrmCcqDaIdfOo0em3uxHQfPYEfNyBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715135192; c=relaxed/simple; bh=gQBDHlJVjn9IyeGe/AMBB67ceGlqQXb/p8wQRVumnQg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XbZltV+kvkVmvubBuf1da+fNDIz+VebITDhOumzFCCNbCuJT+p+zBsVTysV1Lnp5C45mZMhP1F7/fvmzL3zLTKzTrLABKTngj6zAbH3IVg1VjjwaOnrfg0+JDp5RQYLfmrSp84AyDeqyMOZneOUd/fr7IeAymJa2xtl55oTNZfI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iCYEKP4Y; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C627C2BBFC; Wed, 8 May 2024 02:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715135192; bh=gQBDHlJVjn9IyeGe/AMBB67ceGlqQXb/p8wQRVumnQg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iCYEKP4Y46BnvDzYK0hkbvNOSYpuVwJuXnNVAgtsNfMwNr0Nbu1zZ2lgViUzZwE3k qTdUcf+Il5IPruDUmVvuvxzO8PHki8fWPsMFIk8pOlKYvqCE0ZLmw6UIGIK6fQUC49 GKdaTyuuCswsKHhqORs5EMQi0++o9wqjNUdMHURuncKNhwDbSb2clxfONybevdcpEl gXGz27boGIWIturmt+7w4CuHY2zaPQiDFp9mSf7vAgvi+MhXEHQ3PBRy9OGYE6kldU 8XU4AH8REH8RT1lapYgwLgUbW8EoJd7jwAodysljoALXEZ/eIxCa5rlLgf0IkP7lt9 3Hxa2q4woEqAg== Date: Tue, 7 May 2024 19:26:31 -0700 From: "Darrick J. Wong" To: Dave Chinner Cc: Dan Carpenter , Chandan Babu R , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] xfs: check for negatives in xfs_exchange_range_checks() Message-ID: <20240508022631.GF2049409@frogsfrogsfrogs> References: <0e7def98-1479-4f3a-a69a-5f4d09e12fa8@moroto.mountain> 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 Wed, May 08, 2024 at 11:29:15AM +1000, Dave Chinner wrote: > On Sat, May 04, 2024 at 02:27:36PM +0300, Dan Carpenter wrote: > > The fxr->file1_offset and fxr->file2_offset variables come from the user > > in xfs_ioc_exchange_range(). They are size loff_t which is an s64. > > Check the they aren't negative. > > > > Fixes: 9a64d9b3109d ("xfs: introduce new file range exchange ioctl") > > Signed-off-by: Dan Carpenter > > --- > > From static analysis. Untested. Sorry! > > > > fs/xfs/xfs_exchrange.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/fs/xfs/xfs_exchrange.c b/fs/xfs/xfs_exchrange.c > > index c8a655c92c92..3465e152d928 100644 > > --- a/fs/xfs/xfs_exchrange.c > > +++ b/fs/xfs/xfs_exchrange.c > > @@ -337,6 +337,9 @@ xfs_exchange_range_checks( > > if (IS_SWAPFILE(inode1) || IS_SWAPFILE(inode2)) > > return -ETXTBSY; > > > > + if (fxr->file1_offset < 0 || fxr->file2_offset < 0) > > + return -EINVAL; > > Aren't the operational offset/lengths already checked for underflow > and overflow via xfs_exchange_range_verify_area()? Oh, yeah, they are. I was just thinking surely I wrote some tests to pass in garbage offsets and bounce back out... --D > -Dave. > -- > Dave Chinner > david@fromorbit.com