Jesse Taube
2025-Feb-15 20:51 UTC
[klibc] [PATCH] ipconfig: align reads of ext for sparc64
Sparc64 will busfault when reading data from exts if they are not type aligned. A similar issue was fixed in dhcpcd here: https://github.com/NetworkConfiguration/dhcpcd/issues/430 https://github.com/ColinMcInnes/dhcpcd/commit/07a5fdd7d34b072e52c316877d14c6d2581cb379 Signed-off-by: Jesse Taube <mr.bossman075 at gmail.com> --- usr/kinit/ipconfig/dhcp_proto.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr/kinit/ipconfig/dhcp_proto.c b/usr/kinit/ipconfig/dhcp_proto.c index 4e560b84..2b83de45 100644 --- a/usr/kinit/ipconfig/dhcp_proto.c +++ b/usr/kinit/ipconfig/dhcp_proto.c @@ -112,8 +112,11 @@ static int dhcp_parse(struct netdev *dev, struct bootp_hdr *hdr, break; switch (opt) { case 51: /* IP Address Lease Time */ - if (len == 4) - leasetime = ntohl(*(uint32_t *)ext); + if (len == 4) { + /* Sparc64 needs ext reads to be type aligned */ + memcpy(&leasetime, ext, 4); + leasetime = ntohl(leasetime); + } break; case 53: /* DHCP Message Type */ if (len == 1) -- 2.47.2
Ben Hutchings
2025-Feb-23 17:57 UTC
[klibc] [PATCH] ipconfig: align reads of ext for sparc64
On Sat, 2025-02-15 at 15:51 -0500, Jesse Taube wrote:> Sparc64 will busfault when reading data from exts > if they are not type aligned.Many RISC architectures require this alignment, not just sparc64. Could you change the description and comment to be more general? Ben.> A similar issue was fixed in dhcpcd here: > https://github.com/NetworkConfiguration/dhcpcd/issues/430 > https://github.com/ColinMcInnes/dhcpcd/commit/07a5fdd7d34b072e52c316877d14c6d2581cb379 > > Signed-off-by: Jesse Taube <mr.bossman075 at gmail.com> > --- > usr/kinit/ipconfig/dhcp_proto.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/usr/kinit/ipconfig/dhcp_proto.c b/usr/kinit/ipconfig/dhcp_proto.c > index 4e560b84..2b83de45 100644 > --- a/usr/kinit/ipconfig/dhcp_proto.c > +++ b/usr/kinit/ipconfig/dhcp_proto.c > @@ -112,8 +112,11 @@ static int dhcp_parse(struct netdev *dev, struct bootp_hdr *hdr, > break; > switch (opt) { > case 51: /* IP Address Lease Time */ > - if (len == 4) > - leasetime = ntohl(*(uint32_t *)ext); > + if (len == 4) { > + /* Sparc64 needs ext reads to be type aligned */ > + memcpy(&leasetime, ext, 4); > + leasetime = ntohl(leasetime); > + } > break; > case 53: /* DHCP Message Type */ > if (len == 1)-- Ben Hutchings Klipstein's 4th Law of Prototyping and Production: A fail-safe circuit will destroy others. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: <https://lists.zytor.com/archives/klibc/attachments/20250223/36c12eb0/attachment.sig>