Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp182813lqo; Tue, 7 May 2024 17:04:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTE+7FSgqdwXYp8V6ZDYN8jHf4vhRR63gRTBzdLnHvtz8o7DCX/lg42PMfvmNAl4r6UJloih3H1iOlCnMmyEN9R4ARqRscwVi1X/aX0A== X-Google-Smtp-Source: AGHT+IHP6FxkeTI6nhUSKkvlhrny/biZ34WduBtYrHOu2KBrejW6jRL7MJKv42wvznTgVS4iiGIQ X-Received: by 2002:a05:622a:3c7:b0:43a:8248:26f with SMTP id d75a77b69052e-43dbed1e4e2mr13968761cf.27.1715126648600; Tue, 07 May 2024 17:04:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715126648; cv=pass; d=google.com; s=arc-20160816; b=FBItd86NRxlHlY+49QRpvg2sKnJe5XmSL4LCRw6H6srwLWYweSqkt7LQf4okT2uWEA Eqk8RLuHigDO2wCeujZjofo4J39Sm3QEGV3JHNNas3NMTC2a2WbSr0jNvzpKPOx4X2bP oIjwIh9CgqgesbjYaEmik/knc9laGy0z7zvBB5EqcCr/pbBrVmg6OkaVpiEWU0jG0mjs y+2lW94TocFxly0a6kkGbNwbCgi4+CnRJ9uqW7rvLeeYeRiKFt41TEqpANZKLH4xxMzJ o+G001lmdKwqW6tQUzYC3eCsEZlb7JzSuATJxLzes8kqkAern9VdXl9gP85yPuCxmYyq jYYg== 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=BDT+ZMXGd7sS2qzXYE6sxyhDVyMwjt8xsaX3QUSLnbQ=; fh=Iua2Ti6rHKeRW+7v8oWnvCRA87tGm5Fgr/eiTJH64rI=; b=mphOVJ5okjCrgXY/5V097dlqL2afyOASy9bJAjz2fYSad4+WNvexDtUuA7D2Kguc8L Iiwn4+PfFrCnHiwWFn/DmXbFun9qYDWieaNENf5iGZ0uiXdjavQbI5Oy5EbHcX3NtCaL 5sFyMAekq9f1mtJm2F0DjGXZ/lRTAZZfV1Ko3iq2qBaHtjBqwLtj8dNIeZf75gqoxMuk AhMiKgQr1C+o+GsB58yDM4ZtguWn/+YbRtvW/hl9DOyoANbpulhDxjduPw6klN6ZPSJg WI3jhkfictqfJvEiv2hvVTk0Poo29BwPP00X+ke3uWCmyZqio1+TJnCM2apYn2lXtugw WcQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iy9+eVeA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172521-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 o4-20020a05622a008400b0043af7faad59si12586889qtw.159.2024.05.07.17.04.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 17:04:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172521-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=@kernel.org header.s=k20201202 header.b=Iy9+eVeA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172521-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 C4F191C2308C for ; Wed, 8 May 2024 00:04:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB07C1311A8; Tue, 7 May 2024 23:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Iy9+eVeA" 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 EA63785954; Tue, 7 May 2024 23:33:40 +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=1715124821; cv=none; b=pjVcWSFTuKCuQPIHd0V3a6Oj1MOYXIxngAwG/m32HbmvwCKJ7Kt5xR4OaBbSXnN8gDnvGUckpcsQdEQFBH20MthCQB8lGhzLPpV7Q8WcsfM2OdEb6s8zlo4ZKpNl+JIzb6r6LzLrMRuICMvsq4attK0RBWnuPlH6x9W/x/z5Spg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715124821; c=relaxed/simple; bh=PclPuy1ZqHey3h95txPW76r0ZRBiORIW7rQ8fV8cKq4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Pba67XTh1QgGg/kG0txqawNpLLkjigQj5WnIM+QTjOcDtRd8cGCJh9CeVDaPz0spNkFPDoBJlnm+xlZaRbfG575RKN+BWTpMfi6JVSBRdTFFDLIlLfyOZ3nXzRqEj8mv/4jMd3NcF0ZfoC5ho2n630qeozWF5++QBKdLMm6w9NM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iy9+eVeA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69685C2BBFC; Tue, 7 May 2024 23:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715124820; bh=PclPuy1ZqHey3h95txPW76r0ZRBiORIW7rQ8fV8cKq4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Iy9+eVeAx1Bycgiv30bsEt7gyMfNeBX/yunTmm9lmprmh2zVaIyVuH/FM3+bDhrqy ve8JjpyYLJEay1yibV4sOUdwd+5qB5uALBoYLtx7Dw3Z/Z+Qz2PMg0hKWkhq5RndJA coh6PFzJYoM3vRb8GQoVPIVE9ldjfS1HKilhlWUid78WoHVchRlB1iVfMc9Cc7ZgEn Zt8dVcUJ0V1C7+AJ9Six6wGuFM1Y/sd04mD2LmW4oicDAo+JVlEO/GpLrEkXZUdDos VTA5UsWp1+tCSOjcmUX47WDDZ8be86cn+CMvPo1Jb/XuKq1ug6xD0B4zUEj5uhv9Gx koEO9nccC73dA== Date: Tue, 7 May 2024 16:33:39 -0700 From: "Darrick J. Wong" To: Dan Carpenter Cc: 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: <20240507233339.GY360919@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: <0e7def98-1479-4f3a-a69a-5f4d09e12fa8@moroto.mountain> 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! Not a fan of this ^^^^^^^^ > > 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; but this looks right to me. If you actually test your changes, then Reviewed-by: Darrick J. Wong --D > + > size1 = i_size_read(inode1); > size2 = i_size_read(inode2); > > -- > 2.43.0 > >