Jesse Taube
2025-Feb-28 05:25 UTC
[klibc] [PATCH v2] ipconfig: align reads of ext for RISC architectures
Some RISC architectures such as Sparc64 will busfault when reading data
from exts if they are not type aligned. Use memcpy to read the data from
exts to ensure type alignment.
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>
---
V1 -> V2:
- Update commit title to use RISC
- Update commit body
Sorry for missing the changes and version bump in the previous commit.
Also the response to V1 went to spam, sorry for the delay.
---
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-Mar-02 20:47 UTC
[klibc] [PATCH v2] ipconfig: align reads of ext for RISC architectures
On Fri, 2025-02-28 at 00:25 -0500, Jesse Taube wrote:> Some RISC architectures such as Sparc64 will busfault when reading data > from exts if they are not type aligned. Use memcpy to read the data from > exts to ensure type alignment. > > 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> > --- > V1 -> V2: > - Update commit title to use RISC > - Update commit bodyThe comment still referred to sparc, but I fixed that up.> Sorry for missing the changes and version bump in the previous commit. > Also the response to V1 went to spam, sorry for the delay.[...] Applied, thank you! Ben. -- Ben Hutchings Teamwork is essential - it allows you to blame someone else. -------------- 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/20250302/7cea8208/attachment.sig>