瀏覽代碼

sunrpc: Fix unaligned access on sparc64

Fix unaligned access in gss_{get,verify}_mic_v2() on sparc64

Signed-off-by: James Ettle <james@ettle.org.uk>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
James Ettle 7 年之前
父節點
當前提交
90a9b1473d
共有 2 個文件被更改,包括 7 次插入2 次删除
  1. 4 1
      net/sunrpc/auth_gss/gss_krb5_seal.c
  2. 3 1
      net/sunrpc/auth_gss/gss_krb5_unseal.c

+ 4 - 1
net/sunrpc/auth_gss/gss_krb5_seal.c

@@ -177,6 +177,7 @@ gss_get_mic_v2(struct krb5_ctx *ctx, struct xdr_buf *text,
 	u64 seq_send;
 	u64 seq_send;
 	u8 *cksumkey;
 	u8 *cksumkey;
 	unsigned int cksum_usage;
 	unsigned int cksum_usage;
+	__be64 seq_send_be64;
 
 
 	dprintk("RPC:       %s\n", __func__);
 	dprintk("RPC:       %s\n", __func__);
 
 
@@ -187,7 +188,9 @@ gss_get_mic_v2(struct krb5_ctx *ctx, struct xdr_buf *text,
 	spin_lock(&krb5_seq_lock);
 	spin_lock(&krb5_seq_lock);
 	seq_send = ctx->seq_send64++;
 	seq_send = ctx->seq_send64++;
 	spin_unlock(&krb5_seq_lock);
 	spin_unlock(&krb5_seq_lock);
-	*((__be64 *)(krb5_hdr + 8)) = cpu_to_be64(seq_send);
+
+	seq_send_be64 = cpu_to_be64(seq_send);
+	memcpy(krb5_hdr + 8, (char *) &seq_send_be64, 8);
 
 
 	if (ctx->initiate) {
 	if (ctx->initiate) {
 		cksumkey = ctx->initiator_sign;
 		cksumkey = ctx->initiator_sign;

+ 3 - 1
net/sunrpc/auth_gss/gss_krb5_unseal.c

@@ -155,10 +155,12 @@ gss_verify_mic_v2(struct krb5_ctx *ctx,
 	u8 flags;
 	u8 flags;
 	int i;
 	int i;
 	unsigned int cksum_usage;
 	unsigned int cksum_usage;
+	__be16 be16_ptr;
 
 
 	dprintk("RPC:       %s\n", __func__);
 	dprintk("RPC:       %s\n", __func__);
 
 
-	if (be16_to_cpu(*((__be16 *)ptr)) != KG2_TOK_MIC)
+	memcpy(&be16_ptr, (char *) ptr, 2);
+	if (be16_to_cpu(be16_ptr) != KG2_TOK_MIC)
 		return GSS_S_DEFECTIVE_TOKEN;
 		return GSS_S_DEFECTIVE_TOKEN;
 
 
 	flags = ptr[2];
 	flags = ptr[2];