Skip to content

Commit 80253da

Browse files
authored
Merge pull request #207 from infosiftr/patches
Add explicit "patches" directory
2 parents b1b77da + 6db9646 commit 80253da

File tree

11 files changed

+290
-50
lines changed

11 files changed

+290
-50
lines changed

.patches/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# BusyBox Patches
2+
3+
This directory contains patches we apply during our various builds of BusyBox. They are not necessarily *all* applied to all builds, but they are intended to be as minimal as possible, focused primarily on compilation or correctness issues, such that we still represent upstream's releases accurately.
4+
5+
Metadata in each patch should be following [Debian's "DEP-3" Patch Tagging Guidelines](https://dep-team.pages.debian.net/deps/dep3/) to ensure we track appropriate provenance (and that they were submitted upstream in some form, or that we're explicitly tracking our justification for *why* we didn't do so).

.patches/no-cbq.patch

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
Description: remove CBQ functionality
2+
Author: Tianon Gravi <[email protected]>
3+
Origin: https://bugs.busybox.net/attachment.cgi?id=9751&action=edit
4+
5+
See:
6+
- https://github.com/docker-library/busybox/issues/198
7+
- https://bugs.busybox.net/show_bug.cgi?id=15931
8+
- https://bugs.debian.org/1071648
9+
10+
See also:
11+
- https://github.com/torvalds/linux/commit/33241dca486264193ed68167c8eeae1fb197f3df
12+
- https://github.com/iproute2/iproute2/commit/07ba0af3fee132eddc1c2eab643ff4910181c993
13+
14+
diff --git a/networking/tc.c b/networking/tc.c
15+
index 3a79fd2d9..753efb9ff 100644
16+
--- a/networking/tc.c
17+
+++ b/networking/tc.c
18+
@@ -31,7 +31,7 @@
19+
//usage: "qdisc [handle QHANDLE] [root|"IF_FEATURE_TC_INGRESS("ingress|")"parent CLASSID]\n"
20+
/* //usage: "[estimator INTERVAL TIME_CONSTANT]\n" */
21+
//usage: " [[QDISC_KIND] [help|OPTIONS]]\n"
22+
-//usage: " QDISC_KIND := [p|b]fifo|tbf|prio|cbq|red|etc.\n"
23+
+//usage: " QDISC_KIND := [p|b]fifo|tbf|prio|red|etc.\n"
24+
//usage: "qdisc show [dev STRING]"IF_FEATURE_TC_INGRESS(" [ingress]")"\n"
25+
//usage: "class [classid CLASSID] [root|parent CLASSID]\n"
26+
//usage: " [[QDISC_KIND] [help|OPTIONS] ]\n"
27+
@@ -224,105 +224,6 @@ static int prio_print_opt(struct rtattr *opt)
28+
return 0;
29+
}
30+
31+
-#if 0
32+
-/* Class Based Queue */
33+
-static int cbq_parse_opt(int argc, char **argv, struct nlmsghdr *n)
34+
-{
35+
- return 0;
36+
-}
37+
-#endif
38+
-static int cbq_print_opt(struct rtattr *opt)
39+
-{
40+
- struct rtattr *tb[TCA_CBQ_MAX+1];
41+
- struct tc_ratespec *r = NULL;
42+
- struct tc_cbq_lssopt *lss = NULL;
43+
- struct tc_cbq_wrropt *wrr = NULL;
44+
- struct tc_cbq_fopt *fopt = NULL;
45+
- struct tc_cbq_ovl *ovl = NULL;
46+
- const char *const error = "CBQ: too short %s opt";
47+
- char buf[64];
48+
-
49+
- if (opt == NULL)
50+
- goto done;
51+
- parse_rtattr_nested(tb, TCA_CBQ_MAX, opt);
52+
-
53+
- if (tb[TCA_CBQ_RATE]) {
54+
- if (RTA_PAYLOAD(tb[TCA_CBQ_RATE]) < sizeof(*r))
55+
- bb_error_msg(error, "rate");
56+
- else
57+
- r = RTA_DATA(tb[TCA_CBQ_RATE]);
58+
- }
59+
- if (tb[TCA_CBQ_LSSOPT]) {
60+
- if (RTA_PAYLOAD(tb[TCA_CBQ_LSSOPT]) < sizeof(*lss))
61+
- bb_error_msg(error, "lss");
62+
- else
63+
- lss = RTA_DATA(tb[TCA_CBQ_LSSOPT]);
64+
- }
65+
- if (tb[TCA_CBQ_WRROPT]) {
66+
- if (RTA_PAYLOAD(tb[TCA_CBQ_WRROPT]) < sizeof(*wrr))
67+
- bb_error_msg(error, "wrr");
68+
- else
69+
- wrr = RTA_DATA(tb[TCA_CBQ_WRROPT]);
70+
- }
71+
- if (tb[TCA_CBQ_FOPT]) {
72+
- if (RTA_PAYLOAD(tb[TCA_CBQ_FOPT]) < sizeof(*fopt))
73+
- bb_error_msg(error, "fopt");
74+
- else
75+
- fopt = RTA_DATA(tb[TCA_CBQ_FOPT]);
76+
- }
77+
- if (tb[TCA_CBQ_OVL_STRATEGY]) {
78+
- if (RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(*ovl))
79+
- bb_error_msg("CBQ: too short overlimit strategy %u/%u",
80+
- (unsigned) RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]),
81+
- (unsigned) sizeof(*ovl));
82+
- else
83+
- ovl = RTA_DATA(tb[TCA_CBQ_OVL_STRATEGY]);
84+
- }
85+
-
86+
- if (r) {
87+
- print_rate(buf, sizeof(buf), r->rate);
88+
- printf("rate %s ", buf);
89+
- if (show_details) {
90+
- printf("cell %ub ", 1<<r->cell_log);
91+
- if (r->mpu)
92+
- printf("mpu %ub ", r->mpu);
93+
- if (r->overhead)
94+
- printf("overhead %ub ", r->overhead);
95+
- }
96+
- }
97+
- if (lss && lss->flags) {
98+
- bool comma = false;
99+
- bb_putchar('(');
100+
- if (lss->flags&TCF_CBQ_LSS_BOUNDED) {
101+
- printf("bounded");
102+
- comma = true;
103+
- }
104+
- if (lss->flags&TCF_CBQ_LSS_ISOLATED) {
105+
- if (comma)
106+
- bb_putchar(',');
107+
- printf("isolated");
108+
- }
109+
- printf(") ");
110+
- }
111+
- if (wrr) {
112+
- if (wrr->priority != TC_CBQ_MAXPRIO)
113+
- printf("prio %u", wrr->priority);
114+
- else
115+
- printf("prio no-transmit");
116+
- if (show_details) {
117+
- printf("/%u ", wrr->cpriority);
118+
- if (wrr->weight != 1) {
119+
- print_rate(buf, sizeof(buf), wrr->weight);
120+
- printf("weight %s ", buf);
121+
- }
122+
- if (wrr->allot)
123+
- printf("allot %ub ", wrr->allot);
124+
- }
125+
- }
126+
- done:
127+
- return 0;
128+
-}
129+
-
130+
static FAST_FUNC int print_qdisc(
131+
const struct sockaddr_nl *who UNUSED_PARAM,
132+
struct nlmsghdr *hdr,
133+
@@ -368,12 +269,10 @@ static FAST_FUNC int print_qdisc(
134+
if (msg->tcm_info != 1)
135+
printf("refcnt %d ", msg->tcm_info);
136+
if (tb[TCA_OPTIONS]) {
137+
- static const char _q_[] ALIGN1 = "pfifo_fast\0""cbq\0";
138+
+ static const char _q_[] ALIGN1 = "pfifo_fast\0";
139+
int qqq = index_in_strings(_q_, name);
140+
if (qqq == 0) { /* pfifo_fast aka prio */
141+
prio_print_opt(tb[TCA_OPTIONS]);
142+
- } else if (qqq == 1) { /* class based queuing */
143+
- cbq_print_opt(tb[TCA_OPTIONS]);
144+
} else {
145+
/* don't know how to print options for this qdisc */
146+
printf("(options for %s)", name);
147+
@@ -438,13 +337,10 @@ static FAST_FUNC int print_class(
148+
printf("leaf %x ", msg->tcm_info >> 16);
149+
/* Do that get_qdisc_kind(RTA_DATA(tb[TCA_KIND])). */
150+
if (tb[TCA_OPTIONS]) {
151+
- static const char _q_[] ALIGN1 = "pfifo_fast\0""cbq\0";
152+
+ static const char _q_[] ALIGN1 = "pfifo_fast\0";
153+
int qqq = index_in_strings(_q_, name);
154+
if (qqq == 0) { /* pfifo_fast aka prio */
155+
/* nothing. */ /*prio_print_opt(tb[TCA_OPTIONS]);*/
156+
- } else if (qqq == 1) { /* class based queuing */
157+
- /* cbq_print_copt() is identical to cbq_print_opt(). */
158+
- cbq_print_opt(tb[TCA_OPTIONS]);
159+
} else {
160+
/* don't know how to print options for this class */
161+
printf("(options for %s)", name);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Description: libbb/sha: add missing sha-NI guard
2+
Author: André Przywara <[email protected]>
3+
Date: Tue, 10 Sep 2024 06:33:00 -0700
4+
Origin: http://lists.busybox.net/pipermail/busybox/2024-September/090899.html
5+
6+
The ENABLE_SHA1_HWACCEL Kconfig symbol is meant to be archicture
7+
agnostic, so can be enabled regardless of whether your build
8+
architecture provides hardware acceleration or not. At the moment only
9+
x86 implements this, so every piece of optimised code should be guarded
10+
by both ENABLE_SHA1_HWACCEL and (__x86_64__ || __i386__). This is missing
11+
at one place, so compiling for arm64 breaks when ENABLE_SHA1_HWACCEL is
12+
enabled:
13+
================================
14+
libbb/hash_md5_sha.c: In function ‘sha1_end’:
15+
libbb/hash_md5_sha.c:1316:28: error: ‘sha1_process_block64_shaNI’ undeclared (first use in this function); did you mean ‘sha1_process_block64’?
16+
1316 | || ctx->process_block == sha1_process_block64_shaNI
17+
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
18+
| sha1_process_block64
19+
libbb/hash_md5_sha.c:1316:28: note: each undeclared identifier is reported only once for each function it appears in
20+
make[1]: *** [scripts/Makefile.build:197: libbb/hash_md5_sha.o] Error 1
21+
make: *** [Makefile:744: libbb] Error 2
22+
================================
23+
24+
Add the missing guards around the call to sha1_process_block64_shaNI to
25+
fix the build on other architectures with ENABLE_SHA1_HWACCEL enabled.
26+
27+
Change-Id: I40bba388422625f4230abf15a5de23e1fdc654fc
28+
Signed-off-by: André Przywara <[email protected]>
29+
---
30+
libbb/hash_md5_sha.c | 2 ++
31+
1 file changed, 2 insertions(+)
32+
33+
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
34+
index 57a801459..75a61c32c 100644
35+
--- a/libbb/hash_md5_sha.c
36+
+++ b/libbb/hash_md5_sha.c
37+
@@ -1313,7 +1313,9 @@ unsigned FAST_FUNC sha1_end(sha1_ctx_t *ctx, void *resbuf)
38+
hash_size = 8;
39+
if (ctx->process_block == sha1_process_block64
40+
#if ENABLE_SHA1_HWACCEL
41+
+# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
42+
|| ctx->process_block == sha1_process_block64_shaNI
43+
+# endif
44+
#endif
45+
) {
46+
hash_size = 5;
47+
--
48+
2.25.1

Dockerfile-builder.template

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,31 @@ RUN set -eux; \
251251

252252
WORKDIR /usr/src/busybox
253253

254-
# https://github.com/docker-library/busybox/issues/198
255-
# https://bugs.busybox.net/show_bug.cgi?id=15931
256-
# https://bugs.debian.org/1071648
254+
{{
255+
(
256+
[
257+
"no-cbq.patch",
258+
if .version | startswith("1.36.") then empty else
259+
"sha1_process_block64_shaNI.patch"
260+
end,
261+
empty # trailing comma
262+
]
263+
| map("/.patches/" + .)
264+
) as $patches
265+
| if $patches | length > 0 then (
266+
-}}
267+
# apply necessary/minimal patches (see /.patches/ in the top level of the repository)
268+
COPY \
269+
{{ $patches | map( -}}
270+
{{ . }} \
271+
{{ ) | join("") -}}
272+
./.patches/
257273
RUN set -eux; \
258-
curl -fL -o busybox-no-cbq.patch 'https://bugs.busybox.net/attachment.cgi?id=9751'; \
259-
echo '6671a12c48dbcefb653fc8403d1f103a1e2eba4a49b1ee9a9c27da8aa2db80d4 *busybox-no-cbq.patch' | sha256sum -c -; \
260-
patch -p1 --input=busybox-no-cbq.patch; \
261-
rm busybox-no-cbq.patch
274+
for patch in .patches/*.patch; do \
275+
patch -p1 --input="$patch"; \
276+
done; \
277+
rm -rf .patches
278+
{{ ) else "" end -}}
262279

263280
RUN set -eux; \
264281
\

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ for dir; do
3535
--load \
3636
--tag "$base-builder" \
3737
--file "$dir/Dockerfile.builder" \
38-
"$dir"
38+
. # context is "." so we can access the (shared) ".patches" directory
3939

4040
oci="$dir/$BASHBREW_ARCH"
4141
rm -rf "$oci"

latest-1/glibc/Dockerfile.builder

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

latest-1/musl/Dockerfile.builder

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

latest-1/uclibc/Dockerfile.builder

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

latest/glibc/Dockerfile.builder

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

latest/musl/Dockerfile.builder

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)