Skip to contentSkip to conversation

NSM: Fix unaligned accesses in nsm_init_private()

PATCH In review Mans Rullgard 2 participants 2 messages Mar 28, 2009 – Mar 30, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NSM: Fix unaligned accesses in nsm_init_private()

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

---
 fs/lockd/mon.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
fs/lockd/mon.c +6 -2
index 5e2c4d5..6d5d4a4 100644
@@ -16,6 +16,8 @@
 #include <linux/sunrpc/svc.h>
 #include <linux/lockd/lockd.h>
 
+#include <asm/unaligned.h>
+
 #define NLMDBG_FACILITY		NLMDBG_MONITOR
 #define NSM_PROGRAM		100024
 #define NSM_VERSION		1
@@ -274,10 +276,12 @@ static void nsm_init_private(struct nsm_handle *nsm)
 {
 	u64 *p = (u64 *)&nsm->sm_priv.data;
 	struct timespec ts;
+	s64 ns;
 
 	ktime_get_ts(&ts);
-	*p++ = timespec_to_ns(&ts);
-	*p = (unsigned long)nsm;
+	ns = timespec_to_ns(&ts);
+	put_unaligned(ns, p);
+	put_unaligned((unsigned long)nsm, p + 1);
 }
 
 static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap,
Signature · 1 line
1.6.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Mans Rullgard

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

Did a little testing on x86 as well.

Quoted 33 lines

---
fs/lockd/mon.c | 8 ++++++--

1 files changed, 6 insertions(+), 2 deletions(-)
fs/lockd/mon.c +6 -2
index 5e2c4d5..6d5d4a4 100644
@@ -16,6 +16,8 @@
 #include <linux/sunrpc/svc.h>
 #include <linux/lockd/lockd.h>
 
+#include <asm/unaligned.h>
+
 #define NLMDBG_FACILITY		NLMDBG_MONITOR
 #define NSM_PROGRAM		100024
 #define NSM_VERSION		1
@@ -274,10 +276,12 @@ static void nsm_init_private(struct nsm_handle  
 *nsm)
 {
 	u64 *p = (u64 *)&nsm->sm_priv.data;
 	struct timespec ts;
+	s64 ns;
 
 	ktime_get_ts(&ts);
-	*p++ = timespec_to_ns(&ts);
-	*p = (unsigned long)nsm;
+	ns = timespec_to_ns(&ts);
+	put_unaligned(ns, p);
+	put_unaligned((unsigned long)nsm, p + 1);
 }
 
Quoted 8 lines

static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap,

Signature · 6 lines
1.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com