linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kinglong Mee <kinglongmee@gmail.com>
To: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	tigran.mkrtchyan@desy.de, kinglongmee@gmail.com
Subject: [PATCH] NFS: Decode security label as an array
Date: Thu, 30 Jul 2015 22:22:24 +0800	[thread overview]
Message-ID: <55BA3320.8050502@gmail.com> (raw)
In-Reply-To: <55BA130C.1050604@gmail.com>

According at,
https://tools.ietf.org/html/draft-ietf-nfsv4-minorversion2-38#section-12.2.4

"The FATTR4_SEC_LABEL contains an array of two components with the
 first component being an LFS."

So, the security label returned from server should be stored in an array.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/nfs/nfs4xdr.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 558cd65d..d8a35d2 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4114,17 +4114,21 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,
 	if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U)))
 		return -EIO;
 	if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) {
-		p = xdr_inline_decode(xdr, 4);
+		uint32_t dummy;
+
+		p = xdr_inline_decode(xdr, 16);
 		if (unlikely(!p))
 			goto out_overflow;
-		lfs = be32_to_cpup(p++);
-		p = xdr_inline_decode(xdr, 4);
-		if (unlikely(!p))
+
+		dummy = be32_to_cpup(p++);
+		if (dummy != 1) {
+			printk(KERN_WARNING "%s: More than one labels (%u)!",
+				__func__, dummy);
 			goto out_overflow;
+		}
+
+		lfs = be32_to_cpup(p++);
 		pi = be32_to_cpup(p++);
-		p = xdr_inline_decode(xdr, 4);
-		if (unlikely(!p))
-			goto out_overflow;
 		len = be32_to_cpup(p++);
 		p = xdr_inline_decode(xdr, len);
 		if (unlikely(!p))
-- 
2.4.3


  parent reply	other threads:[~2015-07-30 14:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28 11:46 [PATCH 3/4] 4.1 xdrdef: Fix bad define of sec_label4 Kinglong Mee
2015-07-29 19:37 ` J. Bruce Fields
2015-07-30 12:05   ` Kinglong Mee
2015-07-30 12:13     ` [PATCH v2] 4.1 xdrdef: Update nfs4.x to the latest dot-x-38.txt Kinglong Mee
2015-08-18 19:27       ` J. Bruce Fields
2015-07-30 14:22     ` [PATCH] NFSD: Encode security label as an array Kinglong Mee
2015-07-30 14:22     ` Kinglong Mee [this message]
2015-07-30 15:48     ` [PATCH 3/4] 4.1 xdrdef: Fix bad define of sec_label4 J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55BA3320.8050502@gmail.com \
    --to=kinglongmee@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tigran.mkrtchyan@desy.de \
    --cc=trond.myklebust@primarydata.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).