Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp259381rdd; Tue, 9 Jan 2024 03:23:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVB4PENgmHaoB7nMd0EXp07eAfhPi8YfptoLwHQEn0uXWqqmnJTNXKKUQrgQYAgwqKgm/V X-Received: by 2002:a05:6870:9345:b0:204:c37:85bf with SMTP id j5-20020a056870934500b002040c3785bfmr6414929oak.74.1704799426737; Tue, 09 Jan 2024 03:23:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704799426; cv=none; d=google.com; s=arc-20160816; b=iEm8nYbx8g70JSiaKHB8yQZn3ie/cGEzNnqZifRl4oiHw1weaqszCsnwXykUU8vjHN vKOgRDaot9joWaXMaRBBVn5JaOvv+vkquIEDYTeSz1MfakFpZLQ41Iy4FXpS5TE9oJn7 2TlfFa29h6TMhYe1QLlk51RUPWNM5nk2dHwBpFkHvT3W57+SYmnG14/3kjbj+fUdlKno r2kphj9mByPQrIM+SXzffcwzTIZPEoCllkXDt3J4B1r+0gV5Ohdd0Uhn5EBLZpWZMu/b bQInayeoR1uKYzelDfWrBP+AWEc399k3Cc+tr1CkMRD8Ct32c+he9zUKMvURjuHfIXrp 9PRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Z0xNWJpdRPanEuZiAQenKRA87zeZrifRwyW7XU8kxYA=; fh=rqpPS96O0g2fQmn7KhcIs+VloH2LssYDKKWvCBPtAeo=; b=MgaCdS/mhGreiEX9jkRhoWR89TLKixadcfMBWRgqvVNPeRniXRTZegW0vn4XA6Q71D DIwVc2TqfmSxmOu8hA97a34lbMNtIEnmt/sQZMxxk8uvtua4rJTa+/4TxcuWApPcXOA3 SYIuS0BoxZo/n7+bo/Mvct4cAlq/H46l0LJM+hLgeDuba6hOpOvS+rAu4m0HXYUgzqNB 6sjabTolVbQvQedkIaXG/4yIWUXCJmwTbZTuviACK94lG4xCJiUx8C1r3/ejQrRSu9S8 uUEnAEPGrypZgc12CoNxwEDWjViQaWyjE5Q79Ywe+ZvxqtF5RPhm4YHhx0e894LW2qoH WdKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aenuw9aH; spf=pass (google.com: domain of linux-kernel+bounces-20761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20761-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b22-20020a63eb56000000b005c6faf0a669si1245332pgk.285.2024.01.09.03.23.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 03:23:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aenuw9aH; spf=pass (google.com: domain of linux-kernel+bounces-20761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20761-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 25BAB28750B for ; Tue, 9 Jan 2024 11:23:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 921BD39FD1; Tue, 9 Jan 2024 11:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aenuw9aH" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 5A9E539AF5 for ; Tue, 9 Jan 2024 11:21:08 +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=1704799267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z0xNWJpdRPanEuZiAQenKRA87zeZrifRwyW7XU8kxYA=; b=aenuw9aHRQL27VHKd8TZIUSzbuPzLvSAP9TxWUqXC8oonOoFJfjVmemuzi47tyWRK+FHh4 Aez8xm0OjtWMefvNnRfEsTLtKLFWIXCz6hEHPNVAX8dwZgsfpW6XKfYiCuzF9zalX3UEen nJV7R85qms2x4mFwd1ttema+GEAaoh4= 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-581-EPXp23K5MHONs8COTGeLaw-1; Tue, 09 Jan 2024 06:20:58 -0500 X-MC-Unique: EPXp23K5MHONs8COTGeLaw-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 357C31C06505; Tue, 9 Jan 2024 11:20:57 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id C71151121306; Tue, 9 Jan 2024 11:20:53 +0000 (UTC) From: David Howells To: Christian Brauner , Jeff Layton , Gao Xiang , Dominique Martinet Cc: David Howells , 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, Simon Horman , kernel test robot , Yiqun Leng , Jia Zhu Subject: [PATCH 5/6] cachefiles: Fix signed/unsigned mixup Date: Tue, 9 Jan 2024 11:20:22 +0000 Message-ID: <20240109112029.1572463-6-dhowells@redhat.com> In-Reply-To: <20240109112029.1572463-1-dhowells@redhat.com> References: <20240109112029.1572463-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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@intel.com/ Signed-off-by: David Howells Reviewed-by: Simon Horman 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_object *object, bool no_space_allocated_yet) { struct cachefiles_cache *cache = object->volume->cache; - unsigned long long start = *_start, pos; + loff_t start = *_start, pos; size_t len = *_len; int ret; @@ -556,7 +556,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object, cachefiles_trace_seek_error); return pos; } - if (pos >= start + *_len) + if ((u64)pos >= (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_object *object, cachefiles_trace_seek_error); return pos; } - if (pos >= start + *_len) + if ((u64)pos >= (u64)start + *_len) return 0; /* Fully allocated */ /* Partially allocated, but insufficient space: cull. */