From patchwork Mon Apr 26 21:06:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 12225043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CD08C43461 for ; Mon, 26 Apr 2021 21:06:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ABB6D6052B for ; Mon, 26 Apr 2021 21:06:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABB6D6052B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CD33C6B0036; Mon, 26 Apr 2021 17:06:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C5C3A6B006E; Mon, 26 Apr 2021 17:06:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAE8A6B0070; Mon, 26 Apr 2021 17:06:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 87FCD6B0036 for ; Mon, 26 Apr 2021 17:06:37 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 47078180AD837 for ; Mon, 26 Apr 2021 21:06:37 +0000 (UTC) X-FDA: 78075752034.14.053FC05 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 52E613C4 for ; Mon, 26 Apr 2021 21:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619471196; 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=IoprxGl2uK6k56hNY9CDxe9Gob3U7ejqWda/scDa68M=; b=jJlvXcUJ2j8wvgB9FZsI0Zgjg5bqhk/FFSznEPMxQyTU/wad27T0Ug+sjOTitGpsNgnZ3v mX4O93Rp7D160EeQ8JDMATzPDMV3GmnmwhaKTJhsx8ZO6ILqUHe3IIJfafrzuNAQuuqE+E hqxdgsL1aV6BiYYdVLFeWRjRekl6wG8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-XW_eethqPa-CB163_frKsg-1; Mon, 26 Apr 2021 17:06:32 -0400 X-MC-Unique: XW_eethqPa-CB163_frKsg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3DDA1B18BC1; Mon, 26 Apr 2021 21:06:29 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-20.rdu2.redhat.com [10.10.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BD605D9DE; Mon, 26 Apr 2021 21:06:25 +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 In-Reply-To: <161918446704.3145707.14418606303992174310.stgit@warthog.procyon.org.uk> References: <161918446704.3145707.14418606303992174310.stgit@warthog.procyon.org.uk> To: Matthew Wilcox Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, Alexander Viro , linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, Marc Dionne , Mike Marshall , Linus Torvalds , linux-cachefs@redhat.com, Jeff Layton , Christoph Hellwig , v9fs-developer@lists.sourceforge.net, linux-mm@kvack.org, linux-afs@lists.infradead.org, Dave Wysochanski , Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , linux-kernel@vger.kernel.org Subject: [PATCH] netfs: Miscellaneous fixes MIME-Version: 1.0 Content-ID: <3726523.1619471123.1@warthog.procyon.org.uk> From: David Howells Date: Mon, 26 Apr 2021 22:06:24 +0100 Message-ID: <3726642.1619471184@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 52E613C4 X-Stat-Signature: 5onzhk39pbjhqp5y9qnxfdpi1aign1rg Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619471193-454502 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Fix some miscellaneous things in the new netfs lib[1]: (1) The kerneldoc for netfs_readpage() shouldn't say netfs_page(). (2) netfs_readpage() can get an integer overflow on 32-bit when it multiplies page_index(page) by PAGE_SIZE. It should use page_offset() instead. (3) netfs_write_begin() should also use page_offset() to avoid the same overflow. (4) Use page_mapping() in netfs_write_begin() rather than page->mapping. Reported-by: Matthew Wilcox Signed-off-by: David Howells Link: https://lore.kernel.org/r/161789062190.6155.12711584466338493050.stgit@warthog.procyon.org.uk/ [1] --- fs/netfs/read_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c index 1d3b50c5db6d..568e26352309 100644 --- a/fs/netfs/read_helper.c +++ b/fs/netfs/read_helper.c @@ -933,7 +933,7 @@ void netfs_readahead(struct readahead_control *ractl, EXPORT_SYMBOL(netfs_readahead); /** - * netfs_page - Helper to manage a readpage request + * netfs_readpage - Helper to manage a readpage request * @file: The file to read from * @page: The page to read * @ops: The network filesystem's operations for the helper to use @@ -968,7 +968,7 @@ int netfs_readpage(struct file *file, return -ENOMEM; } rreq->mapping = page_file_mapping(page); - rreq->start = page_index(page) * PAGE_SIZE; + rreq->start = page_offset(page); rreq->len = thp_size(page); if (ops->begin_cache_operation) { @@ -1105,8 +1105,8 @@ int netfs_write_begin(struct file *file, struct address_space *mapping, rreq = netfs_alloc_read_request(ops, netfs_priv, file); if (!rreq) goto error; - rreq->mapping = page->mapping; - rreq->start = page->index * PAGE_SIZE; + rreq->mapping = page_file_mapping(page); + rreq->start = page_offset(page); rreq->len = thp_size(page); rreq->no_unlock_page = page->index; __set_bit(NETFS_RREQ_NO_UNLOCK_PAGE, &rreq->flags);