Commit ad5b365c1266b0c9e8e254a3c1cc4ef66bf33cba

Authored by Mans Rullgard
Committed by Trond Myklebust
1 parent 3c8c45dfab

NSM: Fix unaligned accesses in nsm_init_private()

This fixes unaligned accesses in nsm_init_private() when
creating nlm_reboot keys.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff

... ... @@ -16,6 +16,8 @@
16 16 #include <linux/sunrpc/svc.h>
17 17 #include <linux/lockd/lockd.h>
18 18  
  19 +#include <asm/unaligned.h>
  20 +
19 21 #define NLMDBG_FACILITY NLMDBG_MONITOR
20 22 #define NSM_PROGRAM 100024
21 23 #define NSM_VERSION 1
22 24  
... ... @@ -274,10 +276,12 @@
274 276 {
275 277 u64 *p = (u64 *)&nsm->sm_priv.data;
276 278 struct timespec ts;
  279 + s64 ns;
277 280  
278 281 ktime_get_ts(&ts);
279   - *p++ = timespec_to_ns(&ts);
280   - *p = (unsigned long)nsm;
  282 + ns = timespec_to_ns(&ts);
  283 + put_unaligned(ns, p);
  284 + put_unaligned((unsigned long)nsm, p + 1);
281 285 }
282 286  
283 287 static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap,