hostapd crash (due to unaligned access)
Sun Mar 14 03:43:27 PST 2004
I'm using hostap(d) on an 'obscure' architecture (Linux/PA-RISC) that
reacts allergic to unaligned access to variables. More specifically it
really slows an application if you don't have properly aligned variables
or accessing 'odd' addresses. It may also cause the application to crash,
which - of course - is even worse.
To the problem:
Unfortunately I can't tell exactly when I encountered first the problem.
IIRC 0.1.2 (and 2.4.2x kernels) was working fine (no unaligned access),
and I had a stable connection for weeks.
But since about 0.1.3 - and with every CVS versions since then - upto 0.2.0
I got the following messages in my log files every couple of minutes:
Mar 10 18:57:33 beast kernel: hostapd(311): unaligned access to 0xfaf004dd
So I get more than 250 syslog entries of "unaligned accesses" each day,
so what?! I might be able to fix that with editing /etc/syslog.conf ...
However the big problem is that hostapd will fail sooner of later
(usually about a day), and since I'm using bridging, it also brings down
the bridge, ie. I can't access the machine via wlan or (wired) ethernet
anymore. Access via the serial console however works fine, and I still
can access the internet (using eth1, which is not part of the bridge).
BTW, the problem is the same for 2.4.25 and 2.6.4, however 2.6.4 will
make hostapd fail more quickly (within a day), whereas using 2.4.25 will
make hostapd work for a little bit longer (2 or 3 days).
I tracked down the problem in hostapd/receive.c, line 179/180 of current
CVS of hostap.
179 elen = (u16 *) (buf + len - 1);
180 extra_len = le_to_host16(*elen);
The last line is triggering the unaligned trap handler on Linux/PA-RISC.
Line 179 doesn't seem to be treat alignment properly. Eg. on certain
RISC architectures (as my HP PA-RISC), an address to a 16bit value
(such as the 'u16 *' above) MUST be aligned to 16bit boundaries.
This is not guaranteed by the code above.
The fact that it was working with 0.1.2 and no longer with 0.1.3 is
consistent with the fact that hostapd now using the protocol 3 by default
(AFAIK that change was in 0.1.2-4), and the code for handling protocol 2
doesn't have this alignment issue.
Is there a way to change the code so that it assures proper alignment?
I'm not familiar with the inner workings of hostap(d), so I properly
would only make things worse if I'd try to fix it myself.
Thanks in advance,
Since I switched over to 2.6 kernels lately (because of some hardware
drivers), I cannot use the 'stable' 0.1.2 version anymore. At least for me
0.1.2 only works with 2.4 kernels and not with 2.6.
More information about the Hostap