Date: Wed, 13 Dec 2006 05:07:37 +1100 (EST) From: Peter Jeremy <peterjeremy@optushome.com.au> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/106646: [patch] Pointer incorrectly cast to ulong Message-ID: <200612121807.kBCI7bmv003510@turion.vk2pj.dyndns.org> Resent-Message-ID: <200612121820.kBCIK2BL003640@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 106646 >Category: kern >Synopsis: [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: >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: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612121807.kBCI7bmv003510>