From peterjeremy@optushome.com.au  Tue Dec 12 18:19:05 2006
Return-Path: <peterjeremy@optushome.com.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 4634D16A47C
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Dec 2006 18:19:05 +0000 (UTC)
	(envelope-from peterjeremy@optushome.com.au)
Received: from mail19.syd.optusnet.com.au (mail19.syd.optusnet.com.au [211.29.132.200])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2566344075
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Dec 2006 18:06:30 +0000 (GMT)
	(envelope-from peterjeremy@optushome.com.au)
Received: from turion.vk2pj.dyndns.org (c58-107-94-118.belrs4.nsw.optusnet.com.au [58.107.94.118])
	by mail19.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id kBCI7b7g030122
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 13 Dec 2006 05:07:38 +1100
Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1])
	by turion.vk2pj.dyndns.org (8.13.8/8.13.8) with ESMTP id kBCI7b1r003511;
	Wed, 13 Dec 2006 05:07:37 +1100 (EST)
	(envelope-from peter@turion.vk2pj.dyndns.org)
Received: (from peter@localhost)
	by turion.vk2pj.dyndns.org (8.13.8/8.13.8/Submit) id kBCI7bmv003510;
	Wed, 13 Dec 2006 05:07:37 +1100 (EST)
	(envelope-from peter)
Message-Id: <200612121807.kBCI7bmv003510@turion.vk2pj.dyndns.org>
Date: Wed, 13 Dec 2006 05:07:37 +1100 (EST)
From: Peter Jeremy <peter@rulingia.com>
Reply-To:
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] Pointer incorrectly cast to ulong
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         106646
>Category:       kern
>Synopsis:       [nfs] [patch] Pointer incorrectly cast to ulong
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 12 18:20:02 GMT 2006
>Closed-Date:    
>Last-Modified:  Sun Sep 02 17:05:33 UTC 2012
>Originator:     Peter Jeremy
>Release:        FreeBSD 6.2-PRERELEASE amd64
>Organization:
n/a
>Environment:
System: FreeBSD turion.vk2pj.dyndns.org 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #23: Fri Oct 27 09:36:46 EST 2006 root@turion.vk2pj.dyndns.org:/usr/obj/usr/src/sys/turion amd64

The problem also appears in the latest 7-current source

>Description:
	sys/nfs/nfs_common.h defines a macro nfsm_aligned()
	to test if a particular address is sufficiently aligned
	for the architecture.  It does this by casting the address
	to u_long.  For portability, it should cast to intptr_t.

	The existing code will fail on an architecture with strict
	alignment where sizeof(void *) > sizeof(u_long)

>How-To-Repeat:
	Code inspection
>Fix:

	The following (untested) patch should work
Index: sys/nfs/nfs_common.h
===================================================================
RCS file: /usr/ncvs/src/sys/nfs/nfs_common.h,v
retrieving revision 1.38
diff -u -r1.38 nfs_common.h
--- sys/nfs/nfs_common.h	14 Jul 2005 20:08:26 -0000	1.38
+++ sys/nfs/nfs_common.h	12 Dec 2006 18:02:19 -0000
@@ -130,7 +130,7 @@
 #ifdef __NO_STRICT_ALIGNMENT
 #define nfsm_aligned(p, t)	1
 #else
-#define nfsm_aligned(p, t)	((((u_long)(p)) & (sizeof(t) - 1)) == 0)
+#define nfsm_aligned(p, t)	((((intptr_t)(p)) & (sizeof(t) - 1)) == 0)
 #endif
 
 #endif


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Mar 25 03:35:17 UTC 2012 
Responsible-Changed-Why:  
simple enough - take 

http://www.freebsd.org/cgi/query-pr.cgi?pr=106646 
Responsible-Changed-From-To: eadler->freebsd-bugs 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Sep 2 17:05:29 UTC 2012 
Responsible-Changed-Why:  
I won't be looking at this PR for a while and I need to clear some out 
of my queue 

http://www.freebsd.org/cgi/query-pr.cgi?pr=106646 
>Unformatted:
