Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp932153rdd; Wed, 10 Jan 2024 04:06:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBKli5w24w0fAwHi2EnqttpViGVTy2xSNxnU572Ri72byGRbtz6eC6qtkb2ugaG9+RkeJk X-Received: by 2002:a17:90b:4b06:b0:28b:f3fd:38e5 with SMTP id lx6-20020a17090b4b0600b0028bf3fd38e5mr478991pjb.85.1704888374661; Wed, 10 Jan 2024 04:06:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704888374; cv=none; d=google.com; s=arc-20160816; b=Cw5S1H3V+qm/QCqBw4NR9Q4pm6qF09lii0ycTbQam35WjG2AzTc6PWGDDjhLZpanov rXajsB98r2GXf3GF+ofBnNR5rAseHtEpF1CEltOOskVmEK2KMbHxUzCcQUQs6E1FYq4Z RZquZCUgB/98kZ/Q7sKLKJ6cdYXKq/B/NYgWWuMAXI6RsnIQJ6UpbJaEuxuLqj26rSuG FIZW3o3wdAkmNVGlPqjMiH665UdKi97Q30X1NmcRdmDGKAsZPJ8lza2nVY41xuLs5wgT xKAbMLnl+JwoB+IBbSFs+No7XBZwfMrzR6hF/VpdZ34fuuUuQGjnj/m00HfIAk6rm1Tf a8IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=l8cKztzv2ZktLOe0dzMuixqOyjC0S8dozIynxhbNLCA=; fh=JnlVeDXKAtk0NOdBBrSMZwYciOOmCeYfB3kTcn7SgXE=; b=qyng9elPX4IasDYIxYndRyhs7mdX3TkoEafIdBXZuLpqT0cSk9u/7F+13pxwrd3a9E 48yPH2XNU/Y+fI0/9kEM/BBEq+iJKPnlH3j5VdH/4a5g8Ot6/J0+lgRjY9UGjNLFkmcN 2QG6aZB71uLnth8NkMOkB2In2pEXkUK5tqSABSJtxQq/OzijQjieTTv5amuIHyz3jP++ bDD7s6izpvMeD4crx8iyycZdVgo2z3G36kOHkafjIcMwXv5b+TVmpYVFJljhEDtUr4dV ngFVp1u3s4Gjlg2+sX8Ao3JikTo6aOuD9ThYuryP1KpUS1JPer4icceXCJN1QIW6ewUu /+pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=PJtUFaYl; spf=pass (google.com: domain of linux-nfs+bounces-1009-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1009-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.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 x6-20020a17090a8a8600b0028d0327922dsi1232069pjn.78.2024.01.10.04.06.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 04:06:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1009-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=@bytedance.com header.s=google header.b=PJtUFaYl; spf=pass (google.com: domain of linux-nfs+bounces-1009-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1009-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.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 DF85F28AAB7 for ; Wed, 10 Jan 2024 12:06:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3074481D2; Wed, 10 Jan 2024 12:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="PJtUFaYl" X-Original-To: linux-nfs@vger.kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 9D9C747F72 for ; Wed, 10 Jan 2024 12:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6d9af1f52bcso1953078b3a.3 for ; Wed, 10 Jan 2024 04:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1704888363; x=1705493163; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=l8cKztzv2ZktLOe0dzMuixqOyjC0S8dozIynxhbNLCA=; b=PJtUFaYlvrO5pZ/l4ETd5F/BPGWcdK9syqEBKz7ARCHtTxn3QP/aujLMCw3/Dejj/r abT6WdbwqedaIU90uhQbNbR0zGVsaEOavXLAe+teunPX13SkyMbgWujpBdSEWWg1uMV2 A4ja+jyQdgycjg7qmn65D3XBbG8529pbOsdlFAWzhXAmePHu6cdBkx3mTIGz5p9aTASC Oi7GTnY5REMW+srPlJ2buiPKuL3+smB+duhsJv4ocXGfOa1h5FC16XBeOwO9iJ6XJ8ce a8a+yY1XLWZc4/wXe8QzNtDp7iWFGuf9/+yLHMm/vdpT/IfP/ukSEqxdX2iVHWqsz/Ho CzIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704888363; x=1705493163; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=l8cKztzv2ZktLOe0dzMuixqOyjC0S8dozIynxhbNLCA=; b=k1R1DvCnvbBneMnSjTROnNwOyIuDDZOP/sqiOr1b5Om9+MzNmuTzkgNsJx7ZNHgfSX CL76V5PF+PZ1SgcXbCVxcp/E0398vf4LtSmw1sEw33r5ETmgQrUz1xvW1torJL4FWAeN VNtry536btD2yEKMKGaYJTKXzGx9Nyuu3LaHmdOeWtE2Smi2eklucbNBz7LpkDhZoatn bJHJ7DUwOGfba7XpnPrVcm8MNCZ+CkHnQ8PNIzopR699UV6/Xd+4ylqeWUvZupxYy45o F8CJ6PxYsd8xO3EXaqNdhR/dk+5tpErVxEYYZqe19bx55bF8luQzOCqji4eD1VDxfQJJ d8mw== X-Gm-Message-State: AOJu0YxhAnRr6uxH+5gtfPXz/yz5sQXJ93qnYgdfqEfYM/XNZRrYOqu6 vk5NQAoid9HSq8DyfyYKaD9JVQqEsfq+lQ== X-Received: by 2002:a05:6a00:3204:b0:6da:63a5:3f32 with SMTP id bm4-20020a056a00320400b006da63a53f32mr612723pfb.66.1704888362874; Wed, 10 Jan 2024 04:06:02 -0800 (PST) Received: from [10.255.187.86] ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id i128-20020a625486000000b006d99056c4edsm3470845pfb.187.2024.01.10.04.05.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Jan 2024 04:06:02 -0800 (PST) Message-ID: Date: Wed, 10 Jan 2024 20:05:50 +0800 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [External] [PATCH 5/6] cachefiles: Fix signed/unsigned mixup To: David Howells , Christian Brauner , Jeff Layton , Gao Xiang , Dominique Martinet Cc: 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 , zhujia.zj@bytedance.com References: <20240109112029.1572463-1-dhowells@redhat.com> <20240109112029.1572463-6-dhowells@redhat.com> From: Jia Zhu In-Reply-To: <20240109112029.1572463-6-dhowells@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Tested-by: Jia Zhu 在 2024/1/9 19:20, David Howells 写道: > 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. */ >