linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@primarydata.com>
To: trond.myklebust@primarydata.com
Cc: bfields@fieldses.org, hch@infradead.org, linux-nfs@vger.kernel.org
Subject: [PATCH v2 3/5] sunrpc: clean up sparse endianness warnings in gss_krb5_seal.c
Date: Wed, 16 Jul 2014 06:52:20 -0400	[thread overview]
Message-ID: <1405507942-12256-4-git-send-email-jlayton@primarydata.com> (raw)
In-Reply-To: <1405507942-12256-1-git-send-email-jlayton@primarydata.com>

Use u16 pointer in setup_token and setup_token_v2. None of the fields
are actually handled as __be16, so this simplifies the code a bit. Also
get rid of some unneeded pointer increments.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
---
 net/sunrpc/auth_gss/gss_krb5_seal.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c
index 62ae3273186c..42768e5c3994 100644
--- a/net/sunrpc/auth_gss/gss_krb5_seal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
@@ -70,31 +70,37 @@
 
 DEFINE_SPINLOCK(krb5_seq_lock);
 
-static char *
+static void *
 setup_token(struct krb5_ctx *ctx, struct xdr_netobj *token)
 {
-	__be16 *ptr, *krb5_hdr;
+	u16 *ptr;
+	void *krb5_hdr;
 	int body_size = GSS_KRB5_TOK_HDR_LEN + ctx->gk5e->cksumlength;
 
 	token->len = g_token_size(&ctx->mech_used, body_size);
 
-	ptr = (__be16 *)token->data;
+	ptr = (u16 *)token->data;
 	g_make_token_header(&ctx->mech_used, body_size, (unsigned char **)&ptr);
 
 	/* ptr now at start of header described in rfc 1964, section 1.2.1: */
 	krb5_hdr = ptr;
 	*ptr++ = KG_TOK_MIC_MSG;
-	*ptr++ = cpu_to_le16(ctx->gk5e->signalg);
+	/*
+	 * signalg is stored as if it were converted from LE to host endian, even
+	 * though it's an opaque pair of bytes according to the RFC.
+	 */
+	*ptr++ = (__force u16)cpu_to_le16(ctx->gk5e->signalg);
 	*ptr++ = SEAL_ALG_NONE;
-	*ptr++ = 0xffff;
+	*ptr = 0xffff;
 
-	return (char *)krb5_hdr;
+	return krb5_hdr;
 }
 
 static void *
 setup_token_v2(struct krb5_ctx *ctx, struct xdr_netobj *token)
 {
-	__be16 *ptr, *krb5_hdr;
+	u16 *ptr;
+	void *krb5_hdr;
 	u8 *p, flags = 0x00;
 
 	if ((ctx->flags & KRB5_CTX_FLAG_INITIATOR) == 0)
@@ -104,15 +110,15 @@ setup_token_v2(struct krb5_ctx *ctx, struct xdr_netobj *token)
 
 	/* Per rfc 4121, sec 4.2.6.1, there is no header,
 	 * just start the token */
-	krb5_hdr = ptr = (__be16 *)token->data;
+	krb5_hdr = ptr = (u16 *)token->data;
 
 	*ptr++ = KG2_TOK_MIC;
 	p = (u8 *)ptr;
 	*p++ = flags;
 	*p++ = 0xff;
-	ptr = (__be16 *)p;
-	*ptr++ = 0xffff;
+	ptr = (u16 *)p;
 	*ptr++ = 0xffff;
+	*ptr = 0xffff;
 
 	token->len = GSS_KRB5_TOK_HDR_LEN + ctx->gk5e->cksumlength;
 	return krb5_hdr;
@@ -181,7 +187,7 @@ gss_get_mic_v2(struct krb5_ctx *ctx, struct xdr_buf *text,
 	spin_lock(&krb5_seq_lock);
 	seq_send = ctx->seq_send64++;
 	spin_unlock(&krb5_seq_lock);
-	*((u64 *)(krb5_hdr + 8)) = cpu_to_be64(seq_send);
+	*((__be64 *)(krb5_hdr + 8)) = cpu_to_be64(seq_send);
 
 	if (ctx->initiate) {
 		cksumkey = ctx->initiator_sign;
-- 
1.9.3


  parent reply	other threads:[~2014-07-16 10:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14  1:57 [PATCH 0/7] sunrpc: sparse warning cleanups Jeff Layton
2014-07-14  1:57 ` [PATCH 1/7] sunrpc: remove __rcu annotation from struct gss_cl_ctx->gc_gss_ctx Jeff Layton
2014-07-14 14:23   ` Arnd Bergmann
2014-07-14 15:02     ` Jeff Layton
2014-07-14 15:29       ` Arnd Bergmann
2014-07-14  1:57 ` [PATCH 2/7] sunrpc: fix RCU handling of gc_ctx field Jeff Layton
2014-07-14  1:57 ` [PATCH 3/7] sunrpc: clean up endianness warnings in setup_token Jeff Layton
2014-07-15 17:08   ` Christoph Hellwig
2014-07-15 17:32     ` Jeff Layton
2014-07-14  1:57 ` [PATCH 4/7] sunrpc: xdr_get_next_encode_buffer can be static Jeff Layton
2014-07-15 17:02   ` Christoph Hellwig
2014-07-15 17:17     ` Jeff Layton
2014-07-14  1:57 ` [PATCH 5/7] sunrpc: clean up sparse endianness warnings in gss_krb5_seal.c Jeff Layton
2014-07-15 17:03   ` Christoph Hellwig
2014-07-14  1:57 ` [PATCH 6/7] sunrpc: clean up sparse endianness warnings in gss_krb5_wrap.c Jeff Layton
2014-07-15 17:04   ` Christoph Hellwig
2014-07-15 17:36     ` Jeff Layton
2014-07-16  8:13       ` Christoph Hellwig
2014-07-14  1:57 ` [PATCH 7/7] sunrpc: remove "ec" argument from encrypt_v2 operation Jeff Layton
2014-07-15 17:05   ` Christoph Hellwig
2014-07-15 17:33     ` Jeff Layton
2014-07-16 10:52 ` [PATCH v2 0/5] sunrpc: sparse warning cleanups Jeff Layton
2014-07-16 10:52   ` [PATCH v2 1/5] sunrpc: remove __rcu annotation from struct gss_cl_ctx->gc_gss_ctx Jeff Layton
2014-07-16 10:52   ` [PATCH v2 2/5] sunrpc: fix RCU handling of gc_ctx field Jeff Layton
2014-07-16 10:52   ` Jeff Layton [this message]
2014-07-16 10:52   ` [PATCH v2 4/5] sunrpc: clean up sparse endianness warnings in gss_krb5_wrap.c Jeff Layton
2014-07-16 10:52   ` [PATCH v2 5/5] sunrpc: remove "ec" argument from encrypt_v2 operation Jeff Layton
2014-07-30 17:56   ` [PATCH v2 0/5] sunrpc: sparse warning cleanups Jeff Layton

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=1405507942-12256-4-git-send-email-jlayton@primarydata.com \
    --to=jlayton@primarydata.com \
    --cc=bfields@fieldses.org \
    --cc=hch@infradead.org \
    --cc=linux-nfs@vger.kernel.org \
    --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).