From patchwork Wed Apr 30 13:31:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4093921 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 C4214BFF02 for ; Wed, 30 Apr 2014 13:32:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB97E20148 for ; Wed, 30 Apr 2014 13:32:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7FF4202B8 for ; Wed, 30 Apr 2014 13:32:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933733AbaD3NcD (ORCPT ); Wed, 30 Apr 2014 09:32:03 -0400 Received: from mail-qg0-f44.google.com ([209.85.192.44]:61627 "EHLO mail-qg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933706AbaD3NcC (ORCPT ); Wed, 30 Apr 2014 09:32:02 -0400 Received: by mail-qg0-f44.google.com with SMTP id i50so420635qgf.3 for ; Wed, 30 Apr 2014 06:32:01 -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=R8SYhbk3m2nfasmQeD4SrZFvhtn7Lq2GjbgU3GOx9KM=; b=NquGeSAYdBr92NJBR7m4ebgq4rYqxGlwh1s4PmLs5KYH+/IfrDN0pP6KSpR3tczy7d 3urtaydJIKSOqzHyaT9fQ5+49DW+ug8/2wRekim0MazaDkaz9bpwcX30IUbxXjFVx4qn E3HIL80hz35Hk2bu+/WNenV67igH5S5Jll3Km3ebDP+4J3yzdZNOyUDPFwwhXvTY/QE9 LjbZt7WdalHtg7Y40NkKDY8v7ddqb+tiplvUxskDcZiuCCn7cvXpjntWIbJJkt2Yyyp+ kourygTQwZAxuJgSjJZypi/0iXZr+QD6WcJmsXVr/Zo6+rrN75xZp+Q1VtGagan5fRhU IlAQ== X-Gm-Message-State: ALoCoQnow5yK9sK60SB4YMxk5fopUAqH1a7yfM4J8NpzmMPjjBR8lb3IaYVrVHlgbjqJ9wOEMs/7 X-Received: by 10.140.80.229 with SMTP id c92mr4773340qgd.79.1398864720861; Wed, 30 Apr 2014 06:32:00 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id n105sm30733850qgd.7.2014.04.30.06.31.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Apr 2014 06:32:00 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Tetsuo Handa Subject: [PATCH v2 4/4] cifs: revalidate mapping prior to satisfying aio_read request Date: Wed, 30 Apr 2014 09:31:48 -0400 Message-Id: <1398864708-18185-5-git-send-email-jlayton@poochiereds.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1398864708-18185-1-git-send-email-jlayton@poochiereds.net> References: <1398864708-18185-1-git-send-email-jlayton@poochiereds.net> 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 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 3ef0299ed43e..6d3626ba4464 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -729,6 +729,20 @@ out_nls: goto out; } +static ssize_t +cifs_loose_aio_read(struct kiocb *iocb, const struct iovec *iov, + unsigned long nr_segs, loff_t pos) +{ + int rc; + struct inode *inode = file_inode(iocb->ki_filp); + + rc = cifs_revalidate_mapping(inode); + if (rc) + return rc; + + return generic_file_aio_read(iocb, iov, nr_segs, pos); +} + static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { @@ -886,7 +900,7 @@ const struct inode_operations cifs_symlink_inode_ops = { const struct file_operations cifs_file_ops = { .read = do_sync_read, .write = do_sync_write, - .aio_read = generic_file_aio_read, + .aio_read = cifs_loose_aio_read, .aio_write = cifs_file_aio_write, .open = cifs_open, .release = cifs_close, @@ -944,7 +958,7 @@ const struct file_operations cifs_file_direct_ops = { const struct file_operations cifs_file_nobrl_ops = { .read = do_sync_read, .write = do_sync_write, - .aio_read = generic_file_aio_read, + .aio_read = cifs_loose_aio_read, .aio_write = cifs_file_aio_write, .open = cifs_open, .release = cifs_close,