From patchwork Fri May 23 10:50:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4231141 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D5F5CBF90B for ; Fri, 23 May 2014 10:50:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DA382037A for ; Fri, 23 May 2014 10:50:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EDB0B20170 for ; Fri, 23 May 2014 10:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753236AbaEWKuh (ORCPT ); Fri, 23 May 2014 06:50:37 -0400 Received: from mail-qc0-f179.google.com ([209.85.216.179]:42024 "EHLO mail-qc0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752436AbaEWKue (ORCPT ); Fri, 23 May 2014 06:50:34 -0400 Received: by mail-qc0-f179.google.com with SMTP id x3so7748117qcv.38 for ; Fri, 23 May 2014 03:50:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Dj6i73MDO+HFxMSh+SeydxDUI4oSyfwTlDGEpjHIt58=; b=Md7dlzQ3e2vd8jxxzB+BSwi5uqud3gyAc/Zc4YoONNBhrFLf0pTrb4oWTxpmL5+92O 8JJ7bsCNgF4F3bsfrqxORI9ADKAYFnwNPKfvVewyRKqmVHAahjDM7GZ/dTwVacKeqD93 siLU+kF1OETjkWu8SzJpHAOOIhYOI+97j71pCW4xruBnTLwtilIBqvNSqiLITpGdcvNU jJu9IfxbAMrLMaHVdXCwjSLl26VU634phrbExONTvEY9cuI4KttWoJ4uS0bOZgSPSn14 568FiWQd9ajS1LM3juL2RiL6hcxobCHBT870T3tylZ459a9CCAruXa24uDj/0p9dUjpQ W6tQ== X-Gm-Message-State: ALoCoQnMk71oil0uVHB+dFI7rHl5oHNclGHm68KSJjYsutvbgvXtlnsD9qjNQP2w/63jbntQ3OVa X-Received: by 10.224.53.194 with SMTP id n2mr5163644qag.48.1400842233061; Fri, 23 May 2014 03:50:33 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id s60sm1710786qga.30.2014.05.23.03.50.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 May 2014 03:50:31 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Tetsuo Handa Subject: [PATCH] cifs: revalidate mapping prior to satisfying read_iter request with cache=loose Date: Fri, 23 May 2014 06:50:21 -0400 Message-Id: <1400842221-12168-1-git-send-email-jlayton@poochiereds.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <20140513131616.59f41b7a@canb.auug.org.au> References: <20140513131616.59f41b7a@canb.auug.org.au> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Before satisfying a read with cache=loose, we should always check that the pagecache is valid before allowing a read to be satisfied out of it. Reported-by: Tetsuo Handa Signed-off-by: Jeff Layton --- fs/cifs/cifsfs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 2c90d07c0b3a..888398067420 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -725,6 +725,19 @@ out_nls: goto out; } +static ssize_t +cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter) +{ + ssize_t rc; + struct inode *inode = file_inode(iocb->ki_filp); + + rc = cifs_revalidate_mapping(inode); + if (rc) + return rc; + + return generic_file_read_iter(iocb, iter); +} + static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct inode *inode = file_inode(iocb->ki_filp); @@ -881,7 +894,7 @@ const struct inode_operations cifs_symlink_inode_ops = { const struct file_operations cifs_file_ops = { .read = new_sync_read, .write = new_sync_write, - .read_iter = generic_file_read_iter, + .read_iter = cifs_loose_read_iter, .write_iter = cifs_file_write_iter, .open = cifs_open, .release = cifs_close, @@ -939,7 +952,7 @@ const struct file_operations cifs_file_direct_ops = { const struct file_operations cifs_file_nobrl_ops = { .read = new_sync_read, .write = new_sync_write, - .read_iter = generic_file_read_iter, + .read_iter = cifs_loose_read_iter, .write_iter = cifs_file_write_iter, .open = cifs_open, .release = cifs_close,