Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1652839pxy; Mon, 2 Aug 2021 07:07:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHVvo5QtiyqsWpJVi528s5aEwPdVN2tadJsF5hN0pcinL5CED09OBQyLh02BmtO1zKzstF X-Received: by 2002:a17:906:bc87:: with SMTP id lv7mr15646026ejb.365.1627913276530; Mon, 02 Aug 2021 07:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913276; cv=none; d=google.com; s=arc-20160816; b=ef32bpAuzUvxxX4yJgosld5q1b9Y/y9jCBqxGWuAf+znkkY+JrL0cns4YE7m3aJzOn /mUQ23+3yp3Wt1ZOCuYrC/XvLNprGMU163BTkb3++ONLchDSnVWE9Z4y/DFEedSxtWWA x5e+0BqAquicjLP4rC9BVQBrROlftXu9jz+Zy0GG4RMPcCbATD9WnI7KlbjZ1briZNN5 ZjPdypCHUwmOZiGrLjwHr7UJP9Fl9Nx+xf2EjXfKsZia9tXrU4cxdmcxMVwjle+KqbZb oHJHTTYVQTjyT+hWaVhB5eyPtkRiQ0ybq7WU0sIaemoF7I/i3Ed3i8TNawULu4wOQNuG C7Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9FvW5um9RfpaSXqS025iWeBWTr/J1WmQuRZThtvT2AQ=; b=xAqGkh0BBcEqMEX5Bl9kvy8DaP63j9CPCOrpD4hYKeLWd8CXgTSW6bMFgsRJnhaJUi OREUsrEtX2cRHGeTwoHp60H799xHp0YRrWapnNhVg4NWLoKXcObiiv/8JFZykdA8pU/L HpiVuxBbTIPAYhueiAWbjpyYi+D7etM5hWeKAUlm+R1H3EZ5rUlRE1s0EWFOW5wrAz20 OjJZehdoGbPCU2Dmf+qGE0yNz21DN21ugip3OkLJJTi5fnFajac598ScdHUHAqwYM23/ O9dcwutlv+O4VJ3EN2sBoqJ7HFafVNyW5dSmx6Wy95z+l3G6KyXkXQNe3/O63PbCy1z7 4GEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NE63Gbce; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si12939343eja.232.2021.08.02.07.07.33; Mon, 02 Aug 2021 07:07:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NE63Gbce; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236004AbhHBOEE (ORCPT + 99 others); Mon, 2 Aug 2021 10:04:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:40308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235600AbhHBNzx (ORCPT ); Mon, 2 Aug 2021 09:55:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 19B0361029; Mon, 2 Aug 2021 13:54:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912463; bh=ZV2hSBD6E0EMrljNMWUKPSSrm3XvbDMmhatlErAp7ac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NE63Gbce+xrHfWwGbImFGehd9J60dx6cubImD6+G0xzDJYCudBa1UEO4LzNtHwiE2 Y7w+P8yfMaBSU3U4qhlSxQPTN7deFWEG5UKvTAd8pjGh/H0IzgwayJUZ+Dp0bgwYid lkuLW3rVtQWYTBHE/orPIZfUKPOflgA42apRHp1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Steve French Subject: [PATCH 5.10 63/67] SMB3: fix readpage for large swap cache Date: Mon, 2 Aug 2021 15:45:26 +0200 Message-Id: <20210802134341.204392949@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134339.023067817@linuxfoundation.org> References: <20210802134339.023067817@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve French commit f2a26a3cff27dfa456fef386fe5df56dcb4b47b6 upstream. readpage was calculating the offset of the page incorrectly for the case of large swapcaches. loff_t offset = (loff_t)page->index << PAGE_SHIFT; As pointed out by Matthew Wilcox, this needs to use page_file_offset() to calculate the offset instead. Pages coming from the swap cache have page->index set to their index within the swapcache, not within the backing file. For a sufficiently large swapcache, we could have overlapping values of page->index within the same backing file. Suggested by: Matthew Wilcox (Oracle) Cc: # v5.7+ Reviewed-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -4550,7 +4550,7 @@ read_complete: static int cifs_readpage(struct file *file, struct page *page) { - loff_t offset = (loff_t)page->index << PAGE_SHIFT; + loff_t offset = page_file_offset(page); int rc = -EACCES; unsigned int xid;