Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1905201rdb; Mon, 8 Jan 2024 14:31:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgeDtH7fKandwnmVytOoNonL1nhkQmlCvq3Ys9MDmmpeqZI/IWhZLm5Hsac8TlX5u5rL5G X-Received: by 2002:a17:903:40c8:b0:1d4:c98d:40de with SMTP id t8-20020a17090340c800b001d4c98d40demr2213133pld.71.1704753115970; Mon, 08 Jan 2024 14:31:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704753115; cv=none; d=google.com; s=arc-20160816; b=rj25QXnF8STdiBMBuSWwS3KRMxqF2HaqMza2piJirzkFjEhj2l5Z4pK4cfXc31T1vo pGXH0nVvQGyK5ASY5dLFJGCUjoJ5wNLtKCuAkHSWVMvpTmLQB4pv2p7XRPycOwCdoNg8 P4bOvZy3yie8sehglY6WRWY9zBSZWAMXPC0w6xyRB4SnAB4Uiv2IXeMudY7tO97H4CtC x4aNhw86X764NZMfYE1tXitNbpMzQTcyDrPDtO5ppBoyGUW+32Kc2KlnzOxpq06gVMxU lAfc4mehIxKOmLM9iY2p3E4hVLld2N83ogD0ZSme6w6uAOZ3mR2WNZu2P3BtIlylQMYk jfeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :references:in-reply-to:from:organization:dkim-signature; bh=g3fhJdYhF0Jh8djZ9CbUM5+BZiYxRI9hKlm7wmHneNE=; fh=g+tu93aWyEJs/dPoXvboZFUCEa9PTk36ICdrQIKkLWI=; b=r9aeRiRbdhN497hj+T65MpQKmw929oG8UxF+MdattuRgql9dIpxm5G/lEh+kEuPuuP 03Y+3tpP1IfJsHR3A8QU4eBU6wfOIbXhKHZhUB35qZwJa4kibG1Bk0C7KTpwA/qBqCCr yDTiXX3ZVeXCPZK202qt+FdvpR8ejGMIO/IHYzIUlWKZ1CFt/hk4WURFIv7NhcH5B4iP IJSgDklwheiXjn7Wp/shzGzgvBiNWp6x+YEExW1vDjEYLOEIje8HOc92O+46sleRW+3r CUNk4iwOjN9mf953z1h/BSFqi5OsQocHIAjzEwnMd6zlxXdWJzmhDnQsGvKF9dAOd3WR y/uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OZ2kbWTE; spf=pass (google.com: domain of linux-nfs+bounces-980-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-980-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t17-20020a170902b21100b001d4cbf7d66fsi472542plr.560.2024.01.08.14.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 14:31:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-980-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=@redhat.com header.s=mimecast20190719 header.b=OZ2kbWTE; spf=pass (google.com: domain of linux-nfs+bounces-980-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-980-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 94F4028474B for ; Mon, 8 Jan 2024 22:31:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B45553E1F; Mon, 8 Jan 2024 22:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OZ2kbWTE" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 EBBD9BE4E for ; Mon, 8 Jan 2024 22:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704753100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g3fhJdYhF0Jh8djZ9CbUM5+BZiYxRI9hKlm7wmHneNE=; b=OZ2kbWTEKRjY7eLh/D6Pl/LNC4wp20P+DlQGzXqRRcV3H6fXLsrgkoa/RUhyHLVcdRDt8L Z7d/Kaf2lPh4bRlWiVBboEFPQfIJGUkuWdDSNa1akYM0q2wQ6+DVbrEk/rqFw+y4PgSAMu 3qIkfa5i8zavapoiHZ7MfjUnQ2G5J2U= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-mFt6nnssNiyKD7dLtjUHgg-1; Mon, 08 Jan 2024 17:31:35 -0500 X-MC-Unique: mFt6nnssNiyKD7dLtjUHgg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4CFBE1C29EAA; Mon, 8 Jan 2024 22:31:34 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BECCF1121306; Mon, 8 Jan 2024 22:31:30 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20240107160916.GA129355@kernel.org> References: <20240107160916.GA129355@kernel.org> <20240103145935.384404-1-dhowells@redhat.com> <20240103145935.384404-2-dhowells@redhat.com> To: Simon Horman Cc: dhowells@redhat.com, Christian Brauner , Jeff Layton , Gao Xiang , Dominique Martinet , Steve French , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yiqun Leng , Jia Zhu Subject: Re: [PATCH 1/5] cachefiles: Fix __cachefiles_prepare_write() Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1544729.1704753090.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Mon, 08 Jan 2024 22:31:30 +0000 Message-ID: <1544730.1704753090@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 Simon Horman wrote: > I realise these patches have been accepted, but I have a minor nit: > pos is now unsigned, and so cannot be less than zero. Good point. How about the attached patch. Whilst I would prefer to use unsigned long long to avoid the casts, it might = David --- cachefiles: Fix signed/unsigned mixup In __cachefiles_prepare_write(), the start and pos variables were made unsigned 64-bit so that the casts in the checking could be got rid of - which should be fine since absolute file offsets can't be negative, except that an error code may be obtained from vfs_llseek(), which *would* be negative. This breaks the error check. Fix this for now by reverting pos and start to be signed and putting back the casts. Unfortunately, the error value checks cannot be replaced with IS_ERR_VALUE() as long might be 32-bits. Fixes: 7097c96411d2 ("cachefiles: Fix __cachefiles_prepare_write()") Reported-by: Simon Horman Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202401071152.DbKqMQMu-lkp@in= tel.com/ Signed-off-by: David Howells cc: Gao Xiang cc: Yiqun Leng cc: Jia Zhu cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-erofs@lists.ozlabs.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/cachefiles/io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index 3eec26967437..9a2cb2868e90 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -522,7 +522,7 @@ int __cachefiles_prepare_write(struct cachefiles_objec= t *object, bool no_space_allocated_yet) { struct cachefiles_cache *cache =3D object->volume->cache; - unsigned long long start =3D *_start, pos; + loff_t start =3D *_start, pos; size_t len =3D *_len; int ret; = @@ -556,7 +556,7 @@ int __cachefiles_prepare_write(struct cachefiles_objec= t *object, cachefiles_trace_seek_error); return pos; } - if (pos >=3D start + *_len) + if ((u64)pos >=3D (u64)start + *_len) goto check_space; /* Unallocated region */ = /* We have a block that's at least partially filled - if we're low on @@ -575,7 +575,7 @@ int __cachefiles_prepare_write(struct cachefiles_objec= t *object, cachefiles_trace_seek_error); return pos; } - if (pos >=3D start + *_len) + if ((u64)pos >=3D (u64)start + *_len) return 0; /* Fully allocated */ = /* Partially allocated, but insufficient space: cull. */