Subject: kern/12726: mounting NTFS partition on alpha causes unaliged access fault
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@azeotrope.org>
List: netbsd-bugs
Date: 04/23/2001 17:30:12
>Number:         12726
>Category:       kern
>Synopsis:       mounting NTFS partition on alpha causes unaliged access fault
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 23 15:30:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Dave Huang
>Release:        NetBSD 1.5U as of April 23, 2001
>Organization:
Name: Dave Huang         |  Mammal, mammal / their names are called /
INet: khym@azeotrope.org |  they raise a paw / the bat, the cat /
FurryMUCK: Dahan         |  dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 25 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:
	
System: NetBSD yerfable.metonymy.com 1.5U NetBSD 1.5U (YERFABLE) #154: Mon Apr 23 17:17:58 CDT 2001 khym@yerfable.metonymy.com:/usr/src.local/sys/arch/alpha/compile/YERFABLE alpha
Architecture: alpha
Machine: alpha
>Description:
	Attempting to mount an NTFS partition on NetBSD/alpha causes
the kernel to crash with an unaligned access fault.
>How-To-Repeat:
Assuming wd1d is an NTFS partition:
# mount -r -t ntfs /dev/wd1d /mnt
CPU 0: fatal kernel trap:

CPU 0    trap entry = 0x4 (unaligned access fault)
CPU 0    a0         = 0xfffffe00000fd45d
CPU 0    a1         = 0x2d
CPU 0    a2         = 0x1f
CPU 0    pc         = 0xfffffc00004a24a0
CPU 0    ra         = 0xfffffc00004a248c
CPU 0    curproc    = 0xfffffc00017bb998
CPU 0        pid = 298, comm = mount_ntfs

panic: trap
Stopped in pid 298 (mount_ntfs) at    cpu_Debugger+0x4:   ret zero,(ra)
db> t
cpu_Debugger() at cpu_Debugger+0x4
panic() at panic+0xf8
trap() at trap+0x560
XentUna() at XentUna+0x20
--- unaligned access fault (from ipl 0) ---
ntfs_vgetex() at ntfs_vgetex+0x48
ntfs_vget() at ntfs_vget+0x38
ntfs_mountfs() at ntfs_mountfs+0x4b0
ntfs_mount() at ntfs_mount+0x1f0
sys_mount() at sys_mount+0x4f8
syscall_plain() at syscall_plain+0x128
XentSys() at XentSys+0x5c
--- syscall (21) ---
--- user mode ---

>Fix:
Looks like the #pragma pack(1) in ntfs.h should only apply to struct
bootfile, and not struct ntfsmount:

--- /usr/src/sys/ntfs/ntfs.h	Fri Mar 30 12:07:27 2001
+++ ntfs.h	Mon Apr 23 17:17:28 2001
@@ -240,6 +240,8 @@
 	u_int32_t       bf_volsn;	/* volume ser. num. */
 };
 
+#pragma pack()
+
 typedef wchar (ntfs_wget_func_t) __P((const char **));
 typedef int (ntfs_wput_func_t) __P((char *, size_t, wchar));
 typedef int (ntfs_wcmp_func_t) __P((wchar, wchar));
@@ -270,8 +272,6 @@
 #define	ntm_mftrecsz	ntm_bootfile.bf_mftrecsz
 #define	ntm_spc		ntm_bootfile.bf_spc
 #define	ntm_bps		ntm_bootfile.bf_bps
-
-#pragma pack()
 
 #define	NTFS_NEXTREC(s, type) ((type)(((caddr_t) s) + (s)->reclen))
 

Applying the above patch fixes the crash, but I still can't mount an
NTFS partition... now I get the problem reported in PR 10119.
>Release-Note:
>Audit-Trail:
>Unformatted: