openwrt/package/system/apk/patches/0030-defines-align-apk_array.patch
Matt Merhar 64ec08eee1
apk: backport upstream fixes for unaligned access
On the kirkwood target, packages would frequently fail to install with
APKE_ADB_SCHEMA, APKE_ADB_BLOCK, and/or segfaults. The culprit was
unaligned access leading to bogus values being read out of memory on
these particular ARMv5 CPUs.

Pull in the relevant upstream fixes to address this.

Fixes: https://github.com/openwrt/openwrt/issues/21307
Link: https://gitlab.alpinelinux.org/alpine/apk-tools/-/merge_requests/391
Link: https://gitlab.alpinelinux.org/alpine/apk-tools/-/merge_requests/392
Signed-off-by: Matt Merhar <mattmerhar@protonmail.com>
Link: https://github.com/openwrt/openwrt/pull/21958
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
2026-02-10 15:06:52 +01:00

26 lines
752 B
Diff

From fb856c4233202c489be5c6a2335da75bafab0a56 Mon Sep 17 00:00:00 2001
From: Matt Merhar <mattmerhar@protonmail.com>
Date: Tue, 3 Feb 2026 23:01:41 -0500
Subject: [PATCH 1/4] defines: align apk_array
-fsanitize=alignment complained about this one, though no issues were
otherwise encountered during runtime.
While x86-64 wants 8 byte alignment, 32-bit ARM hits SIGILL; so, use
sizeof(void *) to tune it per target.
---
src/apk_defines.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -178,7 +178,7 @@ struct apk_array {
uint32_t num;
uint32_t capacity : 31;
uint32_t allocated : 1;
-};
+} __attribute__((aligned(sizeof(void *))));
extern const struct apk_array _apk_array_empty;