From patchwork Tue Mar 4 19:05:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 3765331 Return-Path: X-Original-To: patchwork-linux-nfs@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 E25FFBF13A for ; Tue, 4 Mar 2014 19:05:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13544202EC for ; Tue, 4 Mar 2014 19:05:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43360202A7 for ; Tue, 4 Mar 2014 19:05:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755165AbaCDTFu (ORCPT ); Tue, 4 Mar 2014 14:05:50 -0500 Received: from mail-ie0-f172.google.com ([209.85.223.172]:56726 "EHLO mail-ie0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754958AbaCDTFt (ORCPT ); Tue, 4 Mar 2014 14:05:49 -0500 Received: by mail-ie0-f172.google.com with SMTP id as1so7588092iec.17 for ; Tue, 04 Mar 2014 11:05:49 -0800 (PST) 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=+5IQrbITEm/Oahu3ezlImhDtO4xlK7NVB58f+6lQlcQ=; b=YB+Q3ceOnhDxl6MpImXir+m/7uoAylVwbS6wRMQrFUSDoj9zJz7gYWjFOn+9+PcJcI ZttTN3CW2ewqN8rzcb6xk5cLjRjGVLZj/P1ZtiP8uizjN9t880kz4hzOwqeep5A4+7sS /d0eg+njDCMND0qZE1Sa9oBxNIjBXGPgmFHoCzxwRDm/MucrnD5XvgStxKB/rNaBAKpL VrZMStz0jQ7CzeIZRnhZngA9GrG+aJ1qgr41Y0JSy54AqtPKYBDV+8CrApg4yypIJmLU EobHQ11KsfRfKUSxylT/qaqIRwAOy4V1UXjBZUIt5deeZVt+QAMHJeZhmB4GMcULqYL1 O+Ow== X-Gm-Message-State: ALoCoQlwt+WUzSDB0F8xLyDnTYqHxDDx/3IU75nVu1/l+vjQynMpX/mv6D3DAhxgHTzRJ/Svm2PT X-Received: by 10.50.22.210 with SMTP id g18mr30351086igf.19.1393959949443; Tue, 04 Mar 2014 11:05:49 -0800 (PST) Received: from leira.trondhjem.org.localdomain (c-98-209-19-95.hsd1.mi.comcast.net. [98.209.19.95]) by mx.google.com with ESMTPSA id hs6sm52631478igb.2.2014.03.04.11.05.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Mar 2014 11:05:48 -0800 (PST) From: Trond Myklebust To: Andy Adamson Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 3/3] NFSv4: Fail the truncate() if the lock/open stateid is invalid Date: Tue, 4 Mar 2014 14:05:43 -0500 Message-Id: <1393959943-9919-4-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1393959943-9919-3-git-send-email-trond.myklebust@primarydata.com> References: <1393954269-3974-1-git-send-email-andros@netapp.com> <1393959943-9919-1-git-send-email-trond.myklebust@primarydata.com> <1393959943-9919-2-git-send-email-trond.myklebust@primarydata.com> <1393959943-9919-3-git-send-email-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 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 If the open stateid could not be recovered, or the file locks were lost, then we should fail the truncate() operation altogether. Reported-by: Andy Adamson Link: http://lkml.kernel.org/r/1393954269-3974-1-git-send-email-andros@netapp.com Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 44e088dc357c..daf41182ecfb 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2398,13 +2398,16 @@ static int _nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, if (nfs4_copy_delegation_stateid(&arg.stateid, inode, fmode)) { /* Use that stateid */ - } else if (truncate && state != NULL && nfs4_valid_open_stateid(state)) { + } else if (truncate && state != NULL) { struct nfs_lockowner lockowner = { .l_owner = current->files, .l_pid = current->tgid, }; - nfs4_select_rw_stateid(&arg.stateid, state, FMODE_WRITE, - &lockowner); + if (!nfs4_valid_open_stateid(state)) + return -EBADF; + if (nfs4_select_rw_stateid(&arg.stateid, state, FMODE_WRITE, + &lockowner) < 0) + return -EBADF; } else nfs4_stateid_copy(&arg.stateid, &zero_stateid);