| Summary: | rpc.statd throws alignment errors | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Volker Stolz <stolz> |
| Component: | alpha | Assignee: | freebsd-alpha (Nobody) <alpha> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | CC: | alpha |
| Priority: | Normal | ||
| Version: | Unspecified | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
Volker Stolz
2002-01-24 17:30:00 UTC
More details after building libc with debugging support:
#0 0x120005584 in get_myaddress (addr=0x11ffb950)
at /usr/src/lib/libc/../libc/rpc/get_myaddress.c:84
84 memcpy(&ifreq, ifr, sizeof(ifreq));
--
Wonderful \hbox (0.80312pt too nice) in paragraph at lines 16--18
Volker Stolz * stolz@i2.informatik.rwth-aachen.de
Please use PGP or S/MIME for correspondence!
Sigh. Okay. Here's my first take at this sucker:
Some interface addresses have 26 bytes in size, which causes
the alignment error. The attached fix will solve my rpc.statd
problem and hopefully a couple of things more (I saw dhclient
going mad on me earlier, but this seems to have been fixed now,
too). The obvious disadvantage: Each time, the ioctl will copy
up to 7(6?) bytes of garbage, but we can probably live with
that :-) Should I hunt down the place where this ifa->ifa_addr is
initialized and add the padding right then when the interface
(address) is created? This patch seems to be closely related to
the ifconfig patch.
Another question: Can I safely replace
memcpy(&ifreq, ifr, sizeof(ifreq));
with
ifreq=*ifr;
in lib/libc/rpc/get_myaddress.c? I know that this kind of
assignment has been non-standard, but I'd like to know if
this will safely work today. I did check, it works fine.
It will de-obfuscate the code and even eliminate one warning :-)
--- sys/net/if.c.orig Sun Jan 27 23:25:54 2002
+++ sys/net/if.c Sun Jan 27 23:12:54 2002
@@ -1298,6 +1298,7 @@
for ( ; space > sizeof (ifr) && ifa;
ifa = ifa->ifa_link.tqe_next) {
register struct sockaddr *sa = ifa->ifa_addr;
+ sa->sa_len = _ALIGN(sa->sa_len);
if (curproc->p_prison && prison_if(curproc, sa))
continue;
addrs++;
--
Wonderful \hbox (0.80312pt too nice) in paragraph at lines 16--18
Volker Stolz * stolz@i2.informatik.rwth-aachen.de
Please use PGP or S/MIME for correspondence!
This code ( /usr/src/lib//libc/rpc/get_myaddress.c ) has been retired about four years ago. The replacement code doesn't seem to have the same alignment problems. Please close this pr. -- Sten Spans "There is a crack in everything, that's how the light gets in." Leonard Cohen - Anthem State Changed From-To: open->closed Closed: No longer pertinent for 5.x/6.x |