From patchwork Fri Feb 21 18:10:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 3699281 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 A9459BF13A for ; Fri, 21 Feb 2014 18:10:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A62E920125 for ; Fri, 21 Feb 2014 18:10:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C0BF20120 for ; Fri, 21 Feb 2014 18:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755769AbaBUSKh (ORCPT ); Fri, 21 Feb 2014 13:10:37 -0500 Received: from mail-oa0-f42.google.com ([209.85.219.42]:48891 "EHLO mail-oa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754253AbaBUSKg (ORCPT ); Fri, 21 Feb 2014 13:10:36 -0500 Received: by mail-oa0-f42.google.com with SMTP id j17so2547991oag.15 for ; Fri, 21 Feb 2014 10:10:36 -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; bh=8WmiErNnbQ+BaUC45jbVRVBqrZzdNI62+hSo1ZhM2oY=; b=T+LgQqcUjEA+yi1x/Jqj4m+sn2aZfO4gbJ6VshNl1+u0Wxp084DPBJh6W2B05RVdR6 RS+vVhP7ASiWGjiHAcy9uoI4gjSyLnUsrdrJ3KsAt0nWSurmy+G8Aoknr54kaLCPnrLz Z2Gx3OxbtAuOkRcuZFCObac/PlrZbFVdoFGEYUgKxKjld2A0AHqcZLcZCWjiEdDumBPd wEmtBj6NS1oLFW8fUQBhWTi55hM5lO6yvYDmN4TVOK1MYX1UkcO5AIdw6E5vFFAnkXcV 1nBpp3zbRLTbJraXl8g4zLD9aE8Rtq5IjZAF9QyuN3OJtjugmugiF0D37DgkUmwdhnCN gvJA== X-Gm-Message-State: ALoCoQnJp085asoUnZ+FIe8aGJ3B6FwvbvbLta5XCN8A8RbKZot0LJuRR80NCViGAbk96GAMMiTe X-Received: by 10.182.53.72 with SMTP id z8mr7192326obo.36.1393006236060; Fri, 21 Feb 2014 10:10:36 -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 hl3sm12008046obb.0.2014.02.21.10.10.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Feb 2014 10:10:35 -0800 (PST) From: Trond Myklebust To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH] NFSd: NFSv4.1 OPEN must use the session-derived client id Date: Fri, 21 Feb 2014 13:10:33 -0500 Message-Id: <1393006233-15366-1-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.8.5.3 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.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 RFC5661 states: The client can set the clientid field to any value and the server MUST ignore it. Instead, the server MUST derive the client ID from the session ID of the SEQUENCE operation of the COMPOUND request Make it so... Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 693e1458e2ca..d23f4cdbc891 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2826,6 +2826,21 @@ static __be32 nfsd4_check_seqid(struct nfsd4_compound_state *cstate, struct nfs4 return nfserr_bad_seqid; } +/* + * RFC5661: OPEN MUST ignore the client-supplied clientid argument and + * substitute the session clientid + */ +static void nfsd41_set_open_clientid(struct nfsd4_compound_state *cstate, + struct nfsd4_open *open) +{ + struct nfs4_client *clp; + + if (!nfsd4_has_session(cstate)) + return; + clp = cstate->session->se_client; + memcpy(&open->op_clientid, &clp->cl_clientid, sizeof(open->op_clientid)); +} + __be32 nfsd4_process_open1(struct nfsd4_compound_state *cstate, struct nfsd4_open *open, struct nfsd_net *nn) @@ -2836,6 +2851,8 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate, struct nfs4_openowner *oo = NULL; __be32 status; + nfsd41_set_open_clientid(cstate, open); + if (STALE_CLIENTID(&open->op_clientid, nn)) return nfserr_stale_clientid; /*