Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp358690lqh; Sat, 4 May 2024 04:27:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgJbK7aCeA53NvloBysFWcM6ZSlN+maijBq5AY7kGUvX0HuG54u4pUarhsFcuWmVcvGGJVifF9w87WaasHOVy/zhwdVZAlbLH6AJQt1g== X-Google-Smtp-Source: AGHT+IHRR62L/qwh4w6reN+bo6JQBjC0tTFSpneCPE7Yos+juFE3OMHqSuswD4/trAUBUAPtLHX/ X-Received: by 2002:a50:ab1a:0:b0:572:a16f:29b with SMTP id s26-20020a50ab1a000000b00572a16f029bmr2907207edc.16.1714822074278; Sat, 04 May 2024 04:27:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714822074; cv=pass; d=google.com; s=arc-20160816; b=F1sXGdnUm/HvLf9vznmGCkqoO5BrV2fuW+6WZZ/OxY0njbjY//AfFd4fdb1ldXAvBT FMkxtxZveqJKAbvrzOflfEzR6x6kdiLUqsnIOYYIr4gMxUwdCP0tc2S0WgZqLROmjWOj X7x2PxEfLXcqJBxo/sMBaxPKdDd24mVXmsoFERt3nFf+0R2XG4aA+WiTfbGNp614VXW8 yDRfGgW0fdZWGhhNRUzDvtAyXi6/Be9+pqw1MGco3pEGNoA6gkIgMYYP/STd7kMy6NC1 g7ep4gp2OT88VOjxSd8Wjb4rOI6Hw+cn/4qvbC2l2Cr8RTEGCb7KP5cpiEUeK6fOKA7U W9GQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=5Pmu0YEcGf7H38ntSIh2K6f/volabjADstC17jZkDWU=; fh=ynNHp5nd7F/vBzmsEA4Riq/3mM6lYTn9Jw04x0CKRik=; b=mAy5puYYekhoVuSIFhHiULEJH619gV0b1yuAdN5xzK1FtOf3aFRN71XgnDdBpZWqmX QpmGiwgdm8yjNABOP+X2MzNDlHxW8DN7fFWxhRQbYLuvkW4LbS9iCn+fB7iJQiSDF4BZ fLbGwOdBXsD7XJ8+o1f+c6ZnnQNpXHYABtszHJnWot9M/L4zNBqg46Byzd/DJ889YaXR 93ekOxlx0S8rMTP8iQDgBU+jto+UG297OTY/pIxkx5kPMDBa2W/ykeflEQeSPJD4nsuP xsEPaVotWzwy5Ej74bB0bxSrNrpzfkfKpMOF4CyDh0gr9qbY2yWMQqtnXx4KzN6ZSfOh Dsuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=prEqzzzh; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-168604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 t22-20020a50ab56000000b00572aca8cc0dsi2635978edc.234.2024.05.04.04.27.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 04:27:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168604-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=@linaro.org header.s=google header.b=prEqzzzh; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-168604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 061231F213C9 for ; Sat, 4 May 2024 11:27:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 704671CD23; Sat, 4 May 2024 11:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="prEqzzzh" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 33CD410A16 for ; Sat, 4 May 2024 11:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714822064; cv=none; b=U3lZjiUA5W9BlYJaIuiIig5nMDCxT/AjQO16n12K/Ci9F05VxnEVc4Pwl3TOgZ1u5eZB7k8hKvr9+ZOXo/Or5LZls52NZC6A29ZpYRVNgSGz+e6iSZwQuKGkQS3insSutcO7hFRTTrdA/9KOE0tuVjlRW1tiuvoPxQZViKCKMc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714822064; c=relaxed/simple; bh=mG1J1A2jIPnJf3tOoKB1yMswAzjzXb2TIar27Fc09n4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=LU8Bsj+839qT1jpRMjXJJkNfCh8cp74EoOWpvy6obXmgib4CwxEcUxF4pMg4pxAkcQcboh+48MOC5RU+xMod+jmMe4t8XSRkE1rKcc1khEEz0sxIHVy5+XhkLRs2/DyEbMnTJQC2XAkZJ49eeRlIMH4GO0UExSd6vxGajTxylTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=prEqzzzh; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-51ae2e37a87so597534e87.2 for ; Sat, 04 May 2024 04:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714822061; x=1715426861; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=5Pmu0YEcGf7H38ntSIh2K6f/volabjADstC17jZkDWU=; b=prEqzzzh0PG+atud1WccLtx4yM4oQ5rlOtPxOzeoTPtfIHmRU3QOYfBR6pc2qZdfyY v0cs+dJCN2cdrFTwYrKCRFlQMSNaj75VwVcYHX50qAUypWnZ/MjVdv4CDBg0XBwDa6PP 8i/ILVY5IJPLMmvs8TbmPCbiC2qgoQi5lleYbHcJoLThbCUxOJN7wWZovhtsVIV9G+A8 0dKf56jW/qSZgWa5xA07aCSyQ+GV0b/y/JLAlNeg1dCmNveIATC9u48lb8m+igF9bBdS IU9JejvTlBM9xShWT/cX6Vx4dIMAQCkD5GE9YGAxYDQXZbpmKVoRilgbbkIAFCYfthQZ OoIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714822061; x=1715426861; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5Pmu0YEcGf7H38ntSIh2K6f/volabjADstC17jZkDWU=; b=prFZ9/Uau3dZ7+9+2mSCo8ZQ/GAkYho99wROahm18QA3O08zv40QjH+icpYFy9kT4V Y0pplRGx5BOdQAMI1uD+0PvhTq+jsnAZ2iFBXAMLp6NBvccT2SotAqQCn1O5qhmdaQEf w6lv2OfnFY45fh4V1qD0KkoUbsa3Z/3Pdv6wXGYUxOPe2QHL+EA5yQKnt7ET0tOsjWVc AiAB9P7U/IAkR+jM6GpAJyy+lIXKnvoIVMM5BBDwLWAO4TUrSJIXXP7+oEeKlsrpeXCH hIgEfMHJRi1oWUexunlEigdBiQ96afxro1pMCeZ4hJ7+QIV/SgzBRk9zQVI0ODilpq3V OOcA== X-Forwarded-Encrypted: i=1; AJvYcCUE4sv7hDQTS3b2k216r1nDS69YzA8a4L3YC5m8Z0rqK2xXkotRwCA2YK5yOwfU8CQ3uwgF+o4jkBTr0cbQMIcoiir+ltTtLa7bD6Qf X-Gm-Message-State: AOJu0Ywrbr1Nr2tyLrQAbOgXpFq0SDdHqdXHe6lDaA3nsllmKr5Hm6p2 D8OxpWLeUYp1nRQTnMlP+pB05fh32tPfdXnBWfyMdE0FfPPxBNxFL1ME5lMlENY= X-Received: by 2002:a05:6512:1390:b0:518:e69b:25a2 with SMTP id fc16-20020a056512139000b00518e69b25a2mr4357763lfb.45.1714822060160; Sat, 04 May 2024 04:27:40 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id dd22-20020a0560001e9600b0034d829982c5sm6052982wrb.5.2024.05.04.04.27.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 04:27:39 -0700 (PDT) Date: Sat, 4 May 2024 14:27:36 +0300 From: Dan Carpenter To: "Darrick J. Wong" Cc: Chandan Babu R , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] xfs: check for negatives in xfs_exchange_range_checks() Message-ID: <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 X-Mailer: git-send-email haha only kidding 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; + size1 = i_size_read(inode1); size2 = i_size_read(inode2); -- 2.43.0