Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1660715pxy; Mon, 2 Aug 2021 07:17:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU9zqgpGIsPA8dK9m7Nx5PPMKwJjHWWQ2ElYzoxL2dO4hALx75GLXnjhOpQ/nB7ysqp1sl X-Received: by 2002:a92:6d07:: with SMTP id i7mr1478031ilc.104.1627913860720; Mon, 02 Aug 2021 07:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913860; cv=none; d=google.com; s=arc-20160816; b=sEnR0WotjB8IraDfSumimYa+4inWhHlhy/shrk/kr3Dn6tRka+RaqqFAStFbx+jJbB 3FoPkGwtcqA4QOHnhVFidjuSxcm3wOHMDT48uqw+RJbI28iHfgw7jWEeDTqrbdTKjqTP v01vWJXpJe9XGRMAX543QJlu0txIvhYMg+YJNKLYkemBI3sf08xX6ExiUkO0n8gKkHDR 0IZ6BUFRLkjDqKvbGv/ivSt6HeGI5riWlbozVSbwIKIP+waTOW8I7WA3zqHcviIFVJgE yrng/wmkcZLd6uN33warUalhYKBngP4FO4AZoAgKjgHYndraMDoyavfqy4Z9baW36+5h PgdQ== 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=VPtULQpx2cboTY/s/XUbIvN0AFq+0DNKzB1TGi3zuR4=; b=E6b/Dd72kZ73DquoUkZYTDkTJ6mbgEpC5zEMzf7vG3vo/qFo4mQ+teUS4xzddT5M0R RvPEA5f0fTWbg8u8opmearsvnVFijYZd59Ih5RzdKotMwE7BZENYcA6VvX1DvBfdIOVw omdIvsGTeH3K7HW7JToQ/ic6fnJOaeragJNDvGk2BYoMcqvlSuv5TI1ynnp2pkCF3QAl 2o8WvFHKUUnGzJQ1aS44eAIE842QntSt/BDcGf2nHU9j/ublypAvC5F2PpycU3Iffp5X G0TmM41ZFuwVQBcC4dFlf7y7Xve1waWlcSn3TTUVGiBRhC0Yz4y6v2wGrS09qMCtY/Eo vfyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gkvDr4CF; 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 c15si12195458ioa.59.2021.08.02.07.17.29; Mon, 02 Aug 2021 07:17:40 -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=gkvDr4CF; 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 S237427AbhHBOP4 (ORCPT + 99 others); Mon, 2 Aug 2021 10:15:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:49734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237854AbhHBOFD (ORCPT ); Mon, 2 Aug 2021 10:05:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 904456124C; Mon, 2 Aug 2021 13:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912699; bh=CwkRCANt2YDAhNZ1Yxv2SmEpwFcFZxmCXUlNM8tEypA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gkvDr4CFJZxzcWt4i/4eE9bFaBIrfx2KEdqM2Ip3GvbWtnR9a0U1t30IOBt58LNDF ClR75HDM2lshQCMpiuFC/Mi6JzoL1uzNeCOA7yv7KEdg+HbhJREVOQMJHt30z0OLF7 c2EQ5/rr8SLaWSfLNin4btzBXhAyWm96zK1IMbm8= 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.13 096/104] SMB3: fix readpage for large swap cache Date: Mon, 2 Aug 2021 15:45:33 +0200 Message-Id: <20210802134347.163046996@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134344.028226640@linuxfoundation.org> References: <20210802134344.028226640@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 @@ -4631,7 +4631,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;