klibc-bot for Jesse Taube
2025-Mar-02 20:48 UTC
[klibc] [klibc:master] ipconfig: align reads of ext for RISC architectures
Commit-ID: 6eadbccbd2ffe830fc18e74d6d4871b1382e0eff Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=6eadbccbd2ffe830fc18e74d6d4871b1382e0eff Author: Jesse Taube <mr.bossman075 at gmail.com> AuthorDate: Fri, 28 Feb 2025 00:25:03 -0500 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sun, 2 Mar 2025 21:46:00 +0100 [klibc] 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> [bwh: Change the comment to not be sparc-specific] Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- 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..1a4cda6e 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) { + /* ext may be misaligned */ + memcpy(&leasetime, ext, 4); + leasetime = ntohl(leasetime); + } break; case 53: /* DHCP Message Type */ if (len == 1)