Return-Path: Received: from mout.kundenserver.de ([212.227.126.135]:54050 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751786AbdLBX2S (ORCPT ); Sat, 2 Dec 2017 18:28:18 -0500 To: linux-nfs@vger.kernel.org Cc: sparclinux@vger.kernel.org From: James Ettle Subject: Unaligned access in gss_{get,verify}_mic_v2() on sparc64 Message-ID: <55549068-2605-7f71-ccef-c102d6fd69ab@ettle.org.uk> Date: Sat, 2 Dec 2017 23:28:18 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Sender: linux-nfs-owner@vger.kernel.org List-ID: Hello, I've been using nfs4 with krb5 on sparc64 with kernel 4.13 and 4.14 and seeing a lot of messages like: sparky kernel: [ 105.262927] Kernel unaligned access at TPC[10afb234] gss_get_mic_kerberos+0xd4/0x360 [rpcsec_gss_krb5] I've traced this down to gss_get_mic_v2() in gss_krb5_seal.c. I think the suspicious line is: *((__be64 *)(krb5_hdr + 8)) = cpu_to_be64(seq_send); krb5_hdr is void*, but comes from a u16 so won't generally have __be64 alignment. As an experiment I added local variable __be64 seq_send_be64; and replaced the cpu_to_be64 line with: seq_send_be64 = cpu_to_be64(seq_send); memcpy(krb5_hdr + 8, (char *) &seq_send_be64, 8); There's another one in gss_verify_mic_v2() in gss_krb5_unseal.c. Here there's a line if (be16_to_cpu(*((__be16 *)ptr)) != KG2_TOK_MIC) but ptr is a u8*. For this I added local variable __be16 data_be16; and replaced the above if() with memcpy((void *) &data_be16, (char *) ptr, 2); if (be16_to_cpu(data_be16) != KG2_TOK_MIC) I've not seen any misalignment complaints yet with this. I apologise for not sending this in the form of a patch, but this is only a sketch solution. I'm not a kernel hacker and I'm sure someone else will make a proper job of it! Thanks, James.