When a process transfers data to or from the kernel, and those data are organized into structures whose size depends on whether or not the size of a pointer is 4 or 8 bytes, an LP64 kernel always uses 64-bit structures, even with 32-bit processes. I know this is true of structures returned from sysctl(3), but I also think it is true of structures used with ioctl(2) and fcntl(2). Because 32-bit processes expect 32-bit structures, attempts to use the 64-bit structures fail at best and cause massive data corruption at worst. This is already affecting real-world code. A patch of mine that was recently committed to Wine (http://www.winehq.org) exposed this issue with the xtcpcb and xinpcb structs returned by the sysctl(3)s "net.inet.tcp.pcblist" and "net.inet.udp.pcblist" (cf. Wine bug 28857: http://bugs.winehq.org/show_bug.cgi?id=28857). Fix: FreeBSD should detect if a process is a 32-bit one, and if so, it should use 32-bit structures instead of 64-bit ones. I don't know how the former can be done; a cursory look through the <sys/proc.h> header reveals nothing. The latter is easy, but tedious: definitions for the 32-bit structs must be added to the kernel headers. Another way to solve this problem (at the cost of binary compatibility for 32-bit programs) is to simply make the 32-bit and 64-bit structures the same. How-To-Repeat: Run any 32-bit program under a 64-bit kernel that calls sysctl(3), ioctl(2), or fcntl(2) and uses a data structure with those calls whose size depends on the pointer size.
Responsible Changed From-To: freebsd-amd64->freebsd-bugs reclassify this one to see if that gets it a wider audience.
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped