Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp330055lqh; Mon, 6 May 2024 23:33:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWS0gx4ZKNlFjKIpJmBLdr6o25S/6oY99+K0jQCUeq4uFfW79ej7C87QrI1mBNAA3aGCZiLtvywHatQVRZCB5vCC6oxG2XppMrDKWdk6g== X-Google-Smtp-Source: AGHT+IEeLVBD6n5zLv94Aa+NUl+ngv36OeC+QdWub1mBA+4BfjhhNse3cofecsG33opOg+m/AMEJ X-Received: by 2002:a17:902:ac98:b0:1ea:274:756e with SMTP id h24-20020a170902ac9800b001ea0274756emr12555756plr.21.1715063636887; Mon, 06 May 2024 23:33:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715063636; cv=pass; d=google.com; s=arc-20160816; b=0L+vJ+feFakQrYMgo5Rz1tIroQWFNJnOCjiJ0nIshSc0+FtKdxGgK364Dtz7hGjxEa JkdzTj3EMHh9v+1SQ0U41MyIDMWhV+S2yUWa5tzAgHuYm15YuVL89sWJV56EiE8Nlgo9 5c2Wge/4DJuj34UpFCPkeMqn6lI7g1krgkU5rBy5alDQYZS165Eb9YCDPMvSt0LhAx+S 2zsS64WDTStSx+SfSCHKfKkswOUYip911BdNqyTXLiX54XLZZ1L68J3pAIYlJUrn3SE9 GllHCb/K9zz+HO74MbV5WpVaMMkfo0EA/1akLKR3QEHKeNaKjpNcMGWcaFgaMR3Qoj/q k1pA== 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=/ZceNyQkkA5SipGRuhtz98PdxDwJKZgpzV7BnccqbLw=; fh=oG8qRNohekZ5qk/lUya65deGD3c/PdSS1dkajaBSGZI=; b=OpgsVHpY8hFKMwFkBUsealsrm3zXCbPN/T8nEPPlnVskfllu8mKHJU9sF37754m02b 5lxKT/f1btegyhiG54Dreaspzl0xC7BeHraHIzabhzjXunRPJh0LGzbexkACZIel4+jv ei0peBaZuAgtD2FEh1k8ERSJfbx97iZ2DqSn8Z6Z05iWW+LRX6sjt31B+YvW324WfOl5 YwZm8URjqNOeyimIPPDFpOexIBJVwn52E9AF/3kZ8Z73pjy11igMuHh148JgSQYrWOkT 9xMzjASnnxHt4x/MUKCNm61tvB2SlEKSkP7KOgd/vUS6FDgozaLfIuS6VfFTt8Sy7pZf jHQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OjgkM5tp; 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-170757-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170757-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j6-20020a170902c08600b001e875a4ffa1si9393935pld.323.2024.05.06.23.33.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 23:33:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170757-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=@linaro.org header.s=google header.b=OjgkM5tp; 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-170757-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170757-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 56ACA282942 for ; Tue, 7 May 2024 06:33:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D73DB77A03; Tue, 7 May 2024 06:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OjgkM5tp" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 8E988374F9 for ; Tue, 7 May 2024 06:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715063629; cv=none; b=MjnX819rR03sc4plKPHBh/Ps6YYUYKruzZHdDt9Fg2Kt32lJUlBqWDQ2VLbf9fc5F0wUdXcs8yEbvccOemPVemtzpl8DY+tHG6rumGbO0ZrptTYN55ZVUGJSQI6A7D53/Zi4enaSoiqN2EoFtYJro+twI/EoghI0MYvq7wgWe1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715063629; c=relaxed/simple; bh=2tSt1cPD/UO58Gs2DE4g6wcOYjTWKRl2MUhi4dKWd7M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hdghBGTJNp5Sk/eCZaepbfMJKibblBFtcWH3BqaJmQsIiHevpZNzYhpfgLaMl4emremg5KuqaQrQZs64eZXGfzCYP745l3Cm+LHg1q81VPE0FjJfGLZmRvQxLqbeAvPE6veh98pck50CknYIypcrSI0fSeNCCOXy0FFs8qcI/C8= 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=OjgkM5tp; arc=none smtp.client-ip=209.85.128.51 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-wm1-f51.google.com with SMTP id 5b1f17b1804b1-41ba1ba55e9so22491815e9.3 for ; Mon, 06 May 2024 23:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715063626; x=1715668426; 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=/ZceNyQkkA5SipGRuhtz98PdxDwJKZgpzV7BnccqbLw=; b=OjgkM5tp8Sb98BxeStvjA1jNxQD8OT7lnEL7jIZqyM2qZUV1DG+ibeEXdtMAp2V3oc 5ovF3MUk0MGVVTzOmNdM1xHD+L61pYLZL3S3RGcxENUpsVM+EjuiGK9YL2q2bKezi9mZ zvWrvmRGezMINa90ihWKC1rSjU7eYXo1CxZ0uhLlOd+eI6IHvOX3wfMKNved9nxnOe6u RjqTwmislUTKSCKyuFQK9AkOCWTa3UrjK8qFxipMu6qiD8drijjOJleCYboD5EsSN9Nt B+En6Y+hPIbHLXsMOZu8tfOK3wc9/Gt5Hq64fwc9HCrmZ6Y5FKGi/jHisV9uD2E7lbTE UGbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715063626; x=1715668426; 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=/ZceNyQkkA5SipGRuhtz98PdxDwJKZgpzV7BnccqbLw=; b=OrxXfXz3f+1my4moNzpsvrJd2VxYovBwzKXelhLme+sIAxzP50Yp0z5GXN6Vkb81fa SpetRDcyJA7WK/PSZTsqB+Za2vOUurqDMV/wM//OVWmHaw3rDcd+IrKCWIhlB9n4qgcm VPHXu5+ypP/4I93FwsHCsDxFdeDSzXLZSzhlZYP1q3H6wiQ0UTA3i6xacI9kRFJVSNWW dv8aIsImzuQzJDUcqe+6D04GHa8IpP8KQ0JXyXIoyrUogDidLPFO1JmzAdyHi6IRQnqJ IeZ+AyXGXtMIYOyJcrgUhdPXpGAq3ItmhJss77bSOQgsKuNkbg5OpvOL3ncOlUVNPOLR FdqQ== X-Forwarded-Encrypted: i=1; AJvYcCWTHvsaeR2/p9NDZXkIjYk4CSjtKo+Zy0r5v6AM+IXcCJZgUZ25JnwQjKCbcOM7ZucadeufFz1aeuZ6VZUXeESdG2Bq0iFDzm5sVGRt X-Gm-Message-State: AOJu0Yyu9hEh34xVw0ZySs4veDCGyk508T8qFos2UoaOG+l1Vu9xKIsL IBEsoK9D2CAsRv2l7B5GuVi/mbdWZJ0FrSlhyY6MW4g/ZlQExMg62r6xKqXCmWc= X-Received: by 2002:a05:600c:19d2:b0:419:f241:632f with SMTP id u18-20020a05600c19d200b00419f241632fmr9996714wmq.31.1715063625822; Mon, 06 May 2024 23:33:45 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id z18-20020adff752000000b0034e19861891sm12163393wrp.33.2024.05.06.23.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 23:33:45 -0700 (PDT) Date: Tue, 7 May 2024 09:33:40 +0300 From: Dan Carpenter To: Christoph Hellwig Cc: "Darrick J. Wong" , 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: 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 Mon, May 06, 2024 at 11:06:17PM -0700, Christoph Hellwig 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") > > In this commit file1_offset and file2_offset are u64. They used to > be u64 in the initial submission, but we changed that as part of the > review process. I've just checked again, and I think it was loff_t in that commit. There are two related structs, the one that's userspace API and the one that's internal. The userspace API is u64 but internally it's loff_t. fs/xfs/libxfs/xfs_fs.h 818 struct xfs_exchange_range { 819 __s32 file1_fd; 820 __u32 pad; /* must be zeroes */ 821 __u64 file1_offset; /* file1 offset, bytes */ 822 __u64 file2_offset; /* file2 offset, bytes */ 823 __u64 length; /* bytes to exchange */ 824 825 __u64 flags; /* see XFS_EXCHANGE_RANGE_* below */ 826 }; fs/xfs/xfs_exchrange.h 16 struct xfs_exchrange { 17 struct file *file1; 18 struct file *file2; 19 20 loff_t file1_offset; 21 loff_t file2_offset; 22 u64 length; 23 24 u64 flags; /* XFS_EXCHANGE_RANGE flags */ 25 }; regards, dan carpenter