Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4832690ybl; Wed, 22 Jan 2020 05:34:30 -0800 (PST) X-Google-Smtp-Source: APXvYqwP7mD5RZQ2t+Vb8OgnP2wPqadwz+SLH6HqlvoEuGCYjDp4uaUgJ8qtbY6l/E/JAUAT2P1S X-Received: by 2002:a9d:53c4:: with SMTP id i4mr7812966oth.48.1579700070674; Wed, 22 Jan 2020 05:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579700070; cv=none; d=google.com; s=arc-20160816; b=sc8g0SCi6mEHF5zu5WNICCuXkzZGQYEQUAUfz5XruVnByQhNyfllGDS5dnYnaIaNQ2 64DN5lSMbKJMWPPaauF6BhFjpHGgwKUNlsBYfvBpzgmrhP6y/JHy6HEjAMnnmH/+eg3A +aPdGaFRogSsCnp2fNB6MQeh/c2f1Lgy2YraSZfbDt25nkWH4V5ukyt5bWEB7kNO0K+C h5ilaps0p2KRzRQFfZnrb+AmaabkFXrfq/IKRpkkAgjnWOKnhwvydBkzVpdgv7x7qlek HJpwj9VIVKclFH9Jjg9sDHIebEzAxgvaz93mgWr/RYLasaRF2t4y1JbfllLbXKlAlRtd nIOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=in5TsEmwfPWPzujFdXSP6VDbW5bXQROB1R9m7g108Qw=; b=U+tBDq98AFS36WlxIq7vEJqgCfdXgYY+BUV3fgdJvCYzrB3oxTOkRcWtmHQdLsd2tD w50kqTnjdAR725h4I2VA7wkO8Zm2MdNoQ0HMXlQ26TjSIB5MA23IyRU/J0sfe3BLoodY 9AnTNPB34MW0WoIF6RvJq8rMx9E28sc9i6HRLQvwTcS8cYfcHuuHsbE55/kEugmivOeW ph1ccSYOug2fG1x60cCRYiX9F25dRwcVdCgY/zrtVyI0B7gGj3oyK9i1YpmGWa9KkKJm Xj14RO2YhecyxVvSZToMZUxvKjGQrldS4l3ZPfHU30J45TqL/39Bi8rUuA04cdzK7YlY iKoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1l4bAKZn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w24si19250287oic.260.2020.01.22.05.34.18; Wed, 22 Jan 2020 05:34:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1l4bAKZn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729262AbgAVNSV (ORCPT + 99 others); Wed, 22 Jan 2020 08:18:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:33976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729190AbgAVNSS (ORCPT ); Wed, 22 Jan 2020 08:18:18 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75CA72467A; Wed, 22 Jan 2020 13:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699098; bh=3JLCLRkSYS0RorDnWGU+Xzdr3ilyL6KOkC6l7RNd9RE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1l4bAKZnDlyT1MumWqD1H242C7YINzrLjJqeJhEkJ5E5XZBWL4l5VYdbD8IcXYusf GIbrfPqv4PWIEmN8WAIBoEil+CfF5kv45gSdME3JevfeGgG0nNzMKxgWyJTj9MQC1Z qDEXfpWGkZR2viZWLmyABtNP0ZKK6oB1C0UyLTuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ondrej Holy , Miklos Szeredi Subject: [PATCH 5.4 032/222] fuse: fix fuse_send_readpages() in the syncronous read case Date: Wed, 22 Jan 2020 10:26:58 +0100 Message-Id: <20200122092835.775601334@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi commit 7df1e988c723a066754090b22d047c3225342152 upstream. Buffered read in fuse normally goes via: -> generic_file_buffered_read() -> fuse_readpages() -> fuse_send_readpages() ->fuse_simple_request() [called since v5.4] In the case of a read request, fuse_simple_request() will return a non-negative bytecount on success or a negative error value. A positive bytecount was taken to be an error and the PG_error flag set on the page. This resulted in generic_file_buffered_read() falling back to ->readpage(), which would repeat the read request and succeed. Because of the repeated read succeeding the bug was not detected with regression tests or other use cases. The FTP module in GVFS however fails the second read due to the non-seekable nature of FTP downloads. Fix by checking and ignoring positive return value from fuse_simple_request(). Reported-by: Ondrej Holy Link: https://gitlab.gnome.org/GNOME/gvfs/issues/441 Fixes: 134831e36bbd ("fuse: convert readpages to simple api") Cc: # v5.4 Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -882,6 +882,7 @@ static void fuse_send_readpages(struct f struct fuse_args_pages *ap = &ia->ap; loff_t pos = page_offset(ap->pages[0]); size_t count = ap->num_pages << PAGE_SHIFT; + ssize_t res; int err; ap->args.out_pages = true; @@ -896,7 +897,8 @@ static void fuse_send_readpages(struct f if (!err) return; } else { - err = fuse_simple_request(fc, &ap->args); + res = fuse_simple_request(fc, &ap->args); + err = res < 0 ? res : 0; } fuse_readpages_end(fc, &ap->args, err); }