diff options
author | PÁLI Gábor János <pali.gabor@gmail.com> | 2022-06-25 23:04:28 +0200 |
---|---|---|
committer | PÁLI Gábor János <pali.gabor@gmail.com> | 2022-06-25 23:04:28 +0200 |
commit | 373d8e3dcb62f76a5c2b3608251529c608b98b1d (patch) | |
tree | 9d3c179ffd2b2fbd0aaf5b2c98deba8a241c2b46 /aports/busybox | |
parent | 2e6c1798e14737745b36726419863180566d53de (diff) | |
download | freebsd-wifibox-alpine-373d8e3dcb62f76a5c2b3608251529c608b98b1d.zip |
Move to Linux 5.15.49 + Alpine 3.16.0.
Diffstat (limited to 'aports/busybox')
10 files changed, 565 insertions, 63 deletions
diff --git a/aports/busybox/0001-ash-add-built-in-BB_ASH_VERSION-variable.patch b/aports/busybox/0001-ash-add-built-in-BB_ASH_VERSION-variable.patch index f7f901f..d8f5ea0 100644 --- a/aports/busybox/0001-ash-add-built-in-BB_ASH_VERSION-variable.patch +++ b/aports/busybox/0001-ash-add-built-in-BB_ASH_VERSION-variable.patch @@ -1,4 +1,4 @@ -From cf95fcc20717e4c0906109b13565fdd06d874ee0 Mon Sep 17 00:00:00 2001 +From df5fffa062ebc46bd13d65c84a4abca6ae1c614d Mon Sep 17 00:00:00 2001 From: Ariadne Conill <ariadne@dereferenced.org> Date: Wed, 10 Mar 2021 23:38:57 -0700 Subject: [PATCH] ash: add built-in $BB_ASH_VERSION variable @@ -19,11 +19,11 @@ varinit_data 360 384 +24 Signed-off-by: Ariadne Conill <ariadne@dereferenced.org> --- - shell/ash.c | 26 +++++++++++++++++++------- - 1 file changed, 19 insertions(+), 7 deletions(-) + shell/ash.c | 28 ++++++++++++++++++++-------- + 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/shell/ash.c b/shell/ash.c -index 6a16833b1..b8525dd57 100644 +index 827643808..5f8f41ee9 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -153,6 +153,14 @@ @@ -41,7 +41,7 @@ index 6a16833b1..b8525dd57 100644 //config:endif # ash options //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) -@@ -2109,6 +2117,9 @@ static const struct { +@@ -2138,6 +2146,9 @@ static const struct { { VSTRFIXED|VTEXTFIXED , "PS1=$ " , NULL }, { VSTRFIXED|VTEXTFIXED , "PS2=> " , NULL }, { VSTRFIXED|VTEXTFIXED , "PS4=+ " , NULL }, @@ -51,7 +51,7 @@ index 6a16833b1..b8525dd57 100644 #if ENABLE_ASH_GETOPTS { VSTRFIXED|VTEXTFIXED , defoptindvar, getoptsreset }, #endif -@@ -2159,18 +2170,19 @@ extern struct globals_var *BB_GLOBAL_CONST ash_ptr_to_globals_var; +@@ -2197,19 +2208,20 @@ extern struct globals_var *BB_GLOBAL_CONST ash_ptr_to_globals_var; #define vps1 varinit[VAR_OFFSET1 + 2] #define vps2 varinit[VAR_OFFSET1 + 3] #define vps4 varinit[VAR_OFFSET1 + 4] @@ -62,22 +62,21 @@ index 6a16833b1..b8525dd57 100644 #endif -#define VAR_OFFSET2 (VAR_OFFSET1 + ENABLE_ASH_GETOPTS) -#define vlineno varinit[VAR_OFFSET2 + 5] +-#define vfuncname varinit[VAR_OFFSET2 + 6] +#define VAR_OFFSET3 (VAR_OFFSET2 + ENABLE_ASH_GETOPTS) +#define vlineno varinit[VAR_OFFSET3 + 5] ++#define vfuncname varinit[VAR_OFFSET3 + 6] #if ENABLE_ASH_RANDOM_SUPPORT --# define vrandom varinit[VAR_OFFSET2 + 6] -+# define vrandom varinit[VAR_OFFSET3 + 6] +-# define vrandom varinit[VAR_OFFSET2 + 7] ++# define vrandom varinit[VAR_OFFSET3 + 7] #endif -#define VAR_OFFSET3 (VAR_OFFSET2 + ENABLE_ASH_RANDOM_SUPPORT) +#define VAR_OFFSET4 (VAR_OFFSET2 + ENABLE_ASH_RANDOM_SUPPORT) #if BASH_EPOCH_VARS --# define vepochs varinit[VAR_OFFSET3 + 6] --# define vepochr varinit[VAR_OFFSET3 + 7] -+# define vepochs varinit[VAR_OFFSET4 + 6] -+# define vepochr varinit[VAR_OFFSET4 + 7] +-# define vepochs varinit[VAR_OFFSET3 + 7] +-# define vepochr varinit[VAR_OFFSET3 + 8] ++# define vepochs varinit[VAR_OFFSET4 + 7] ++# define vepochr varinit[VAR_OFFSET4 + 8] #endif #define INIT_G_var() do { \ unsigned i; \ --- -2.30.2 - diff --git a/aports/busybox/0001-avoid-redefined-warnings-when-building-with-utmps.patch b/aports/busybox/0001-avoid-redefined-warnings-when-building-with-utmps.patch new file mode 100644 index 0000000..246e9b0 --- /dev/null +++ b/aports/busybox/0001-avoid-redefined-warnings-when-building-with-utmps.patch @@ -0,0 +1,16 @@ +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Mon, 06 Sep 2021 23:13:05 +0200 +Subject: [PATCH] Avoid redefined warnings when building with utmps + +--- a/include/libbb.h ++++ b/include/libbb.h +@@ -107,6 +107,9 @@ + # define _PATH_UTMPX _PATH_UTMP + # else + # if !defined(__FreeBSD__) ++/* _PATH_UTMP and _PATH_WTMP are defined both in paths.h and utmps/utmp.h. */ ++# undef _PATH_UTMP ++# undef _PATH_WTMP + # include <utmp.h> + # else + # define _PATH_UTMPX "/var/run/utx.active" diff --git a/aports/busybox/0001-modinfo-add-k-option-for-kernel-version.patch b/aports/busybox/0001-modinfo-add-k-option-for-kernel-version.patch new file mode 100644 index 0000000..f1bf02f --- /dev/null +++ b/aports/busybox/0001-modinfo-add-k-option-for-kernel-version.patch @@ -0,0 +1,140 @@ +From 8fed81a74070cb42e1dff1a8c2382bd123385e22 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Thu, 28 Apr 2022 16:03:16 +0200 +Subject: [PATCH] modinfo: add -k option for kernel version + +It is useful to be able to specify kernel version when generating +initramfs and similar for a kernel version that might not be the running +one. + +bloatcheck on x86_64: + +function old new delta +packed_usage 26193 26218 +25 +modinfo_main 391 414 +23 +.rodata 80296 80298 +2 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 3/0 up/down: 50/0) Total: 50 +bytes + text data bss dec hex filename + 834606 14124 2008 850738 cfb32 busybox_old + 834657 14124 2008 850789 cfb65 busybox_unstripped + +Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> +--- + modutils/modinfo.c | 30 ++++++++++++++++++------------ + 1 file changed, 18 insertions(+), 12 deletions(-) + +diff --git a/modutils/modinfo.c b/modutils/modinfo.c +index 0a86c3296..53bc02880 100644 +--- a/modutils/modinfo.c ++++ b/modutils/modinfo.c +@@ -38,17 +38,18 @@ static const char *const shortcuts[] ALIGN_PTR = { + + enum { + OPT_0 = (1 << 0), /* \0 as separator */ +- OPT_F = (1 << 1), /* field name */ ++ OPT_k = (1 << 1), /* kernel version */ ++ OPT_F = (1 << 2), /* field name */ + /* first bits are for -nadlp options, the rest are for + * fields not selectable with "shortcut" options + */ +- OPT_n = (1 << 2), +- OPT_TAGS = ((1 << ARRAY_SIZE(shortcuts)) - 1) << 2, ++ OPT_n = (1 << 3), ++ OPT_TAGS = ((1 << ARRAY_SIZE(shortcuts)) - 1) << 3, + }; + + static void display(const char *data, const char *pattern) + { +- int flag = option_mask32 >> 1; /* shift out -0 bit */ ++ int flag = option_mask32 >> 2; /* shift out -0 and -k bits */ + if (flag & (flag-1)) { + /* more than one field to show: print "FIELD:" pfx */ + int n = printf("%s:", pattern); +@@ -82,7 +83,8 @@ static void modinfo(const char *path, const char *version, + } + } + +- for (j = 1; (1<<j) & (OPT_TAGS|OPT_F); j++) { ++ /* skip initial -0 and -k option bits */ ++ for (j = 2; (1<<j) & (OPT_TAGS|OPT_F); j++) { + const char *pattern; + + if (!((1<<j) & tags)) +@@ -90,7 +92,7 @@ static void modinfo(const char *path, const char *version, + + pattern = field; + if ((1<<j) & OPT_TAGS) +- pattern = shortcuts[j-2]; ++ pattern = shortcuts[j-3]; + + if (strcmp(pattern, shortcuts[0]) == 0) { + /* "-n" or "-F filename" */ +@@ -123,7 +125,7 @@ static void modinfo(const char *path, const char *version, + } + + //usage:#define modinfo_trivial_usage +-//usage: "[-adlpn0] [-F keyword] MODULE" ++//usage: "[-adlpn0] [-F keyword] [-k kernel] MODULE" + //usage:#define modinfo_full_usage "\n\n" + //usage: " -a Shortcut for '-F author'" + //usage: "\n -d Shortcut for '-F description'" +@@ -131,6 +133,7 @@ static void modinfo(const char *path, const char *version, + //usage: "\n -p Shortcut for '-F parm'" + ////usage: "\n -n Shortcut for '-F filename'" + //usage: "\n -F keyword Keyword to look for" ++//usage: "\n -k kernel kernel version" + //usage: "\n -0 NUL terminated output" + //usage:#define modinfo_example_usage + //usage: "$ modinfo -F vermagic loop\n" +@@ -139,6 +142,7 @@ int modinfo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int modinfo_main(int argc UNUSED_PARAM, char **argv) + { + const char *field; ++ const char *kernel; + char name[MODULE_NAME_LEN]; + struct utsname uts; + parser_t *parser; +@@ -147,15 +151,17 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv) + unsigned i; + + field = NULL; +- opts = getopt32(argv, "^" "0F:nadlp" "\0" "-1"/*minimum one arg*/, &field); ++ uname(&uts); ++ kernel = uts.release; ++ opts = getopt32(argv, "^" "0k:F:nadlp" "\0" "-1"/*minimum one arg*/, &kernel, &field); + /* If no field selected, show all */ + if (!(opts & (OPT_TAGS|OPT_F))) + option_mask32 |= OPT_TAGS; ++ + argv += optind; + +- uname(&uts); + parser = config_open2( +- xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, uts.release, CONFIG_DEFAULT_DEPMOD_FILE), ++ xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, kernel, CONFIG_DEFAULT_DEPMOD_FILE), + xfopen_for_read + ); + +@@ -167,7 +173,7 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv) + filename2modname(bb_basename(tokens[0]), name); + for (i = 0; argv[i]; i++) { + if (fnmatch(argv[i], name, 0) == 0) { +- modinfo(tokens[0], uts.release, field); ++ modinfo(tokens[0], kernel, field); + argv[i] = (char *) ""; + } + } +@@ -177,7 +183,7 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv) + + for (i = 0; argv[i]; i++) { + if (argv[i][0]) { +- modinfo(argv[i], uts.release, field); ++ modinfo(argv[i], kernel, field); + } + } + +-- +2.36.0 + diff --git a/aports/busybox/0013-ash-fix-unsafe-use-of-mempcpy.patch b/aports/busybox/0013-ash-fix-unsafe-use-of-mempcpy.patch new file mode 100644 index 0000000..944fd38 --- /dev/null +++ b/aports/busybox/0013-ash-fix-unsafe-use-of-mempcpy.patch @@ -0,0 +1,32 @@ +From 7750b5a25a8cf9081b7c248687c876d0068e85bb Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko <vda.linux@googlemail.com> +Date: Tue, 1 Mar 2022 09:56:54 +0100 +Subject: [PATCH] ash: fix unsafe use of mempcpy + +function old new delta +subevalvar 1549 1557 +8 + +Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> +--- + shell/ash.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/shell/ash.c b/shell/ash.c +index 54335c5dd..44ec2eafd 100644 +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -7191,7 +7191,13 @@ subevalvar(char *start, char *str, int strloc, + len = orig_len - pos; + + if (!quotes) { +- loc = mempcpy(startp, startp + pos, len); ++ /* want: loc = mempcpy(startp, startp + pos, len) ++ * but it does not allow overlapping arguments */ ++ loc = startp; ++ while (--len >= 0) { ++ *loc = loc[pos]; ++ loc++; ++ } + } else { + for (vstr = startp; pos != 0; pos--) { + if ((unsigned char)*vstr == CTLESC) diff --git a/aports/busybox/0014-ash-fix-use-after-free-in-bash-pattern-substitution.patch b/aports/busybox/0014-ash-fix-use-after-free-in-bash-pattern-substitution.patch new file mode 100644 index 0000000..6ff2b82 --- /dev/null +++ b/aports/busybox/0014-ash-fix-use-after-free-in-bash-pattern-substitution.patch @@ -0,0 +1,81 @@ +From 103728181bfd9a60537166d036e5baca7b67cc1f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren@soeren-tempel.net> +Date: Sat, 29 Jan 2022 06:11:12 +0100 +Subject: [PATCH] ash: fix use-after-free in bash pattern substitution +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +At Alpine Linux downstream, we were made aware of a segmentation fault +occurring during string replacement in BusyBox ash [0]. Further +debugging revealed that the segmentation fault occurs due to a +use-after-free in BusyBox's bash pattern substitution implementation. +Specially, the problem is that the repl variable (pointing to the +replacement string) points to a value in the stack string. However, when +accessing the repl pointer in Line 7350 it is possible that the stack +has been moved since the last repl assignment due to the STPUTC +invocations in Line 7317 and 7321 (since STPUTC may grow the stack via +realloc(3)). + +For this reason, the code in Line 7350 may access an unmapped memory +region and therefore causes a segmentation fault if prior STPUTC +invocations moved the stack via realloc(3). The valgrind output +for this edge case looks as follows: + + Invalid read of size 1 + at 0x15D8DD: subevalvar (ash.c:7350) + by 0x15DC43: evalvar (ash.c:7666) + by 0x15B717: argstr (ash.c:6893) + by 0x15BAEC: expandarg (ash.c:8090) + by 0x15F4CC: evalcommand (ash.c:10429) + by 0x15B26C: evaltree (ash.c:9365) + by 0x15E4FC: cmdloop (ash.c:13569) + by 0x15FD8B: ash_main (ash.c:14748) + by 0x115BF2: run_applet_no_and_exit (appletlib.c:967) + by 0x115F16: run_applet_and_exit (appletlib.c:986) + by 0x115EF9: busybox_main (appletlib.c:917) + by 0x115EF9: run_applet_and_exit (appletlib.c:979) + by 0x115F8F: main (appletlib.c:1126) + Address 0x48b8646 is 2,054 bytes inside a block of size 4,776 free'd + at 0x48A6FC9: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x116E86: xrealloc (xfuncs_printf.c:61) + by 0x1565DB: growstackblock (ash.c:1736) + by 0x156EF7: growstackstr (ash.c:1775) + by 0x156F1A: _STPUTC (ash.c:1816) + by 0x15D843: subevalvar (ash.c:7317) + by 0x15DC43: evalvar (ash.c:7666) + by 0x15B717: argstr (ash.c:6893) + by 0x15BAEC: expandarg (ash.c:8090) + by 0x15F4CC: evalcommand (ash.c:10429) + by 0x15B26C: evaltree (ash.c:9365) + by 0x15E4FC: cmdloop (ash.c:13569) + +A testcase for reproducing this edge case is provided in the downstream +bug report [1]. This commit fixes the issue by reconstructing the repl +pointer relative to stackblock() via strloc and slash_pos. + +[0]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13469 +[1]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13469#note_210530 + +Signed-off-by: Sören Tempel <soeren@soeren-tempel.net> +--- + shell/ash.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/shell/ash.c b/shell/ash.c +index 55df54bd0..24f9a8270 100644 +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -7346,6 +7346,12 @@ subevalvar(char *start, char *str, int strloc, + idx = loc; + } + ++ // The STPUTC invocations above may resize and move the ++ // stack via realloc(3). Since repl is a pointer into the ++ // stack, we need to reconstruct it relative to stackblock(). ++ if (slash_pos >= 0) ++ repl = (char *)stackblock() + strloc + slash_pos + 1; ++ + //bb_error_msg("repl:'%s'", repl); + for (loc = (char*)repl; *loc; loc++) { + char *restart_detect = stackblock(); diff --git a/aports/busybox/0015-ed-don-t-use-memcpy-with-overlapping-memory-regions.patch b/aports/busybox/0015-ed-don-t-use-memcpy-with-overlapping-memory-regions.patch new file mode 100644 index 0000000..5697a55 --- /dev/null +++ b/aports/busybox/0015-ed-don-t-use-memcpy-with-overlapping-memory-regions.patch @@ -0,0 +1,34 @@ +From 65bb493f2475368161431ed72816fd0c61e479b1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> +Date: Tue, 8 Feb 2022 09:29:21 +0100 +Subject: [PATCH] ed: don't use memcpy with overlapping memory regions + +The memcpy invocations in the subCommand function, modified by this +commit, previously used memcpy with overlapping memory regions. This is +undefined behavior. On Alpine Linux, it causes BusyBox ed to crash since +we compile BusyBox with -D_FORTIFY_SOURCE=2 and our fortify-headers +implementation catches this source of undefined behavior [0]. The issue +can only be triggered if the replacement string is the same size or +shorter than the old string. + +Looking at the code, it seems to me that a memmove(3) is what was +actually intended here, this commit modifies the code accordingly. + +[0]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13504 +--- + editors/ed.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/editors/ed.c b/editors/ed.c +index 209ce9942..4a84f7433 100644 +--- a/editors/ed.c ++++ b/editors/ed.c +@@ -720,7 +720,7 @@ static void subCommand(const char *cmd, int num1, int num2) + if (deltaLen <= 0) { + memcpy(&lp->data[offset], newStr, newLen); + if (deltaLen) { +- memcpy(&lp->data[offset + newLen], ++ memmove(&lp->data[offset + newLen], + &lp->data[offset + oldLen], + lp->len - offset - oldLen); + diff --git a/aports/busybox/0016-ash-don-t-read-past-end-of-var-in-subvareval-for-bas.patch b/aports/busybox/0016-ash-don-t-read-past-end-of-var-in-subvareval-for-bas.patch new file mode 100644 index 0000000..3527fa5 --- /dev/null +++ b/aports/busybox/0016-ash-don-t-read-past-end-of-var-in-subvareval-for-bas.patch @@ -0,0 +1,88 @@ +From fa52ac9781f479de8ab4d8526276244c0a0471f4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren@soeren-tempel.net> +Date: Mon, 28 Feb 2022 08:36:50 +0100 +Subject: [PATCH] ash: don't read past end of var in subvareval for bash + substitutions +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Without this patch, BusyBox handles bash pattern substitutions without +a terminating '/' character incorrectly. + +Consider the following shell script: + + _bootstrapver=5.0.211-r0 + _referencesdir="/usr/${_bootstrapver/-*}/Sources" + echo $_referencesdir + +This should output `/usr/5.0.211/Sources`. However, without this patch +it instead outputs `/usr/5.0.211Sources`. This is due to the fact that +BusyBox expects the bash pattern substitutions to always be terminated +with a '/' (at least in this part of subvareval) and thus reads passed +the substitution itself and consumes the '/' character which is part of +the literal string. If there is no '/' after the substitution then +BusyBox might perform an out-of-bounds read under certain circumstances. + +When replacing the bash pattern substitution with `${_bootstrapver/-*/}`, +or with this patch applied, ash outputs the correct value. + +Signed-off-by: Sören Tempel <soeren@soeren-tempel.net> +Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> +--- + shell/ash.c | 4 ++++ + shell/ash_test/ash-vars/var_bash_repl_unterminated.right | 1 + + shell/ash_test/ash-vars/var_bash_repl_unterminated.tests | 2 ++ + shell/hush_test/hush-vars/var_bash_repl_unterminated.right | 1 + + shell/hush_test/hush-vars/var_bash_repl_unterminated.tests | 2 ++ + 5 files changed, 10 insertions(+) + create mode 100644 shell/ash_test/ash-vars/var_bash_repl_unterminated.right + create mode 100755 shell/ash_test/ash-vars/var_bash_repl_unterminated.tests + create mode 100644 shell/hush_test/hush-vars/var_bash_repl_unterminated.right + create mode 100755 shell/hush_test/hush-vars/var_bash_repl_unterminated.tests + +diff --git a/shell/ash.c b/shell/ash.c +index adb0f223a..54335c5dd 100644 +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -7081,6 +7081,10 @@ subevalvar(char *start, char *str, int strloc, + *repl = '\0'; + break; + } ++ if ((unsigned char)*repl == CTLENDVAR) { /* ${v/pattern} (no trailing /, no repl) */ ++ repl = NULL; ++ break; ++ } + /* Handle escaped slashes, e.g. "${v/\//_}" (they are CTLESC'ed by this point) */ + if ((unsigned char)*repl == CTLESC && repl[1]) + repl++; +diff --git a/shell/ash_test/ash-vars/var_bash_repl_unterminated.right b/shell/ash_test/ash-vars/var_bash_repl_unterminated.right +new file mode 100644 +index 000000000..5bff3a6fa +--- /dev/null ++++ b/shell/ash_test/ash-vars/var_bash_repl_unterminated.right +@@ -0,0 +1 @@ ++b/d +diff --git a/shell/ash_test/ash-vars/var_bash_repl_unterminated.tests b/shell/ash_test/ash-vars/var_bash_repl_unterminated.tests +new file mode 100755 +index 000000000..c9513343d +--- /dev/null ++++ b/shell/ash_test/ash-vars/var_bash_repl_unterminated.tests +@@ -0,0 +1,2 @@ ++a=b-c ++echo ${a/-*}/d +diff --git a/shell/hush_test/hush-vars/var_bash_repl_unterminated.right b/shell/hush_test/hush-vars/var_bash_repl_unterminated.right +new file mode 100644 +index 000000000..5bff3a6fa +--- /dev/null ++++ b/shell/hush_test/hush-vars/var_bash_repl_unterminated.right +@@ -0,0 +1 @@ ++b/d +diff --git a/shell/hush_test/hush-vars/var_bash_repl_unterminated.tests b/shell/hush_test/hush-vars/var_bash_repl_unterminated.tests +new file mode 100755 +index 000000000..c9513343d +--- /dev/null ++++ b/shell/hush_test/hush-vars/var_bash_repl_unterminated.tests +@@ -0,0 +1,2 @@ ++a=b-c ++echo ${a/-*}/d diff --git a/aports/busybox/0017-ash-Fix-use-after-free-on-idx-variable.patch b/aports/busybox/0017-ash-Fix-use-after-free-on-idx-variable.patch new file mode 100644 index 0000000..22a2578 --- /dev/null +++ b/aports/busybox/0017-ash-Fix-use-after-free-on-idx-variable.patch @@ -0,0 +1,94 @@ +From 3813e89e3622b034b0e51acae496493a717555cc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> +Date: Wed, 1 Jun 2022 11:51:40 +0200 +Subject: [PATCH] ash: Fix use-after-free on idx variable + +Consider the following code from ash.c: + + STPUTC(*idx, expdest); + if (quotes && (unsigned char)*idx == CTLESC) { + +The idx variable points to a value in the stack string (as managed +by STPUTC). STPUTC may resize this stack string via realloc(3). If +this happens, the idx pointer needs to be updated. Otherwise, +dereferencing idx may result in a use-after free. + +The valgrind output for this edge case looks as follows: + + Invalid read of size 1 + at 0x113AD7: subevalvar (ash.c:7326) + by 0x112EC7: evalvar (ash.c:7674) + by 0x113219: argstr (ash.c:6891) + by 0x113D10: expandarg (ash.c:8098) + by 0x118989: evalcommand (ash.c:10377) + by 0x116744: evaltree (ash.c:9373) + by 0x1170DC: cmdloop (ash.c:13577) + by 0x1191E4: ash_main (ash.c:14756) + by 0x10CB3B: run_applet_no_and_exit (appletlib.c:967) + by 0x10CBCA: run_applet_and_exit (appletlib.c:986) + by 0x10CBCA: main (appletlib.c:1126) + Address 0x48b4099 is 857 bytes inside a block of size 2,736 free'd + at 0x48A6FC9: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x125B03: xrealloc (xfuncs_printf.c:61) + by 0x10F9D2: growstackblock (ash.c:1736) + by 0x10FA4E: growstackstr (ash.c:1775) + by 0x10FA71: _STPUTC (ash.c:1816) + by 0x113A94: subevalvar (ash.c:7325) + by 0x112EC7: evalvar (ash.c:7674) + by 0x113219: argstr (ash.c:6891) + by 0x113D10: expandarg (ash.c:8098) + by 0x118989: evalcommand (ash.c:10377) + by 0x116744: evaltree (ash.c:9373) + by 0x1170DC: cmdloop (ash.c:13577) + Block was alloc'd at + at 0x48A26D5: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x125AE9: xmalloc (xfuncs_printf.c:50) + by 0x10ED56: stalloc (ash.c:1622) + by 0x10F9FF: growstackblock (ash.c:1746) + by 0x10FB2A: growstackto (ash.c:1783) + by 0x10FB47: makestrspace (ash.c:1795) + by 0x10FDE7: memtodest (ash.c:6390) + by 0x10FE91: strtodest (ash.c:6417) + by 0x112CC5: varvalue (ash.c:7558) + by 0x112D80: evalvar (ash.c:7603) + by 0x113219: argstr (ash.c:6891) + by 0x113D10: expandarg (ash.c:8098) + +This patch fixes this issue by updating the pointers again via +the restart label if STPUTC re-sized the stack. This issue +has been reported to us at Alpine Linux downstream. + +Also: Move the second realloc-check inside the if statement +that follows so it isn't done twice if the condition evaluates +to false. + +See also: + +* https://gitlab.alpinelinux.org/alpine/aports/-/issues/13900 +* http://lists.busybox.net/pipermail/busybox/2022-April/089655.html +--- + shell/ash.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/shell/ash.c b/shell/ash.c +index ef4a47afe..cbc50eefe 100644 +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -7323,13 +7323,15 @@ subevalvar(char *start, char *str, int strloc, + if (idx >= end) + break; + STPUTC(*idx, expdest); ++ if (stackblock() != restart_detect) ++ goto restart; + if (quotes && (unsigned char)*idx == CTLESC) { + idx++; + len++; + STPUTC(*idx, expdest); ++ if (stackblock() != restart_detect) ++ goto restart; + } +- if (stackblock() != restart_detect) +- goto restart; + idx++; + len++; + rmesc++; diff --git a/aports/busybox/APKBUILD b/aports/busybox/APKBUILD index 40b1d3f..ec0d3fb 100644 --- a/aports/busybox/APKBUILD +++ b/aports/busybox/APKBUILD @@ -1,13 +1,16 @@ # Maintainer: Gabor Pali <pali.gabor@gmail.com> pkgname=busybox -pkgver=1.34.1 -pkgrel=5 +pkgver=1.35.0 +pkgrel=0 # base: 14, -initscripts: 4.1-r1 pkgdesc="Size optimized toolbox of many common UNIX utilities" url="https://busybox.net/" arch="all" license="GPL-2.0-only" makedepends_build="perl" -makedepends_host="linux-headers openssl1.1-compat-dev libretls-dev" +makedepends_host="linux-headers openssl-dev" +# Only build with UTMPS support if we are not bootstrapping. +# skalibs-static is needed for utmps-static +[ -z "$BOOTSTRAP" ] && makedepends_host="$makedepends_host utmps-dev utmps-static skalibs-static" makedepends="$makedepends_build $makedepends_host" checkdepends= provides="/bin/sh" @@ -15,8 +18,6 @@ install= subpackages= options="!check" source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2 - 0001-rev-correct-output-for-long-input-lines.patch - 0001-nologin-Install-applet-to-sbin-instead-of-usr-sbin.patch 0001-adduser-default-to-sbin-nologin-as-shell-for-system-.patch 0001-properly-fix-wget-https-support.patch @@ -31,16 +32,17 @@ source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2 0009-depmod-support-generating-kmod-binary-index-files.patch 0010-Add-flag-for-not-following-symlinks-when-recursing.patch 0012-udhcpc-Don-t-background-if-n-is-given.patch - + 0013-ash-fix-unsafe-use-of-mempcpy.patch + 0014-ash-fix-use-after-free-in-bash-pattern-substitution.patch + 0015-ed-don-t-use-memcpy-with-overlapping-memory-regions.patch + 0016-ash-don-t-read-past-end-of-var-in-subvareval-for-bas.patch + 0017-ash-Fix-use-after-free-on-idx-variable.patch 0001-ash-add-built-in-BB_ASH_VERSION-variable.patch - - 0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch - 0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch - 0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch - + 0001-avoid-redefined-warnings-when-building-with-utmps.patch 0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch 0002-nslookup-sanitize-all-printed-strings-with-printable.patch + 0001-modinfo-add-k-option-for-kernel-version.patch acpid.logrotate config @@ -59,6 +61,9 @@ source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2 " # secfixes: +# 1.35.0-r7: +# - ALPINE-13661 +# - CVE-2022-28391 # 1.34.1-r5: # - ALPINE-13661 # - CVE-2022-28391 @@ -162,7 +167,8 @@ EOF install -m644 "$srcdir"/$i "$pkgdir"/etc/conf.d/${i%.*} || return 1 done install -m644 mdev.conf "$pkgdir"/etc - install -m755 persistent-storage "$pkgdir"/lib/mdev/ + install -m755 persistent-storage \ + "$pkgdir"/lib/mdev/ # poweroff script for acpid cat >"$pkgdir"/etc/acpi/PWRF/00000080 <<EOF @@ -173,8 +179,7 @@ EOF } sha512sums=" -fb7e53a56c07b1098a12ee7232ad5401b147816648a0619b3b5358fdcf0915cfbb054500c0e0dd4acb3bc0a93a584b62bc5448e1f16b28004f58b39518a13b9d busybox-1.34.1.tar.bz2 -054e766429887e610c4a17846f495b7099bb419217f5fcc0dce0ed62b8740c2d4ee53b12a609b1830c26ac2af1eca9beb6140063b7d2665939f99f8664dfcc05 0001-rev-correct-output-for-long-input-lines.patch +62b2e718b6669271380445ed6db249618d777a4e8d5e6d879fa39ffee43887b6a2e93ceef874c615c565ad492deb772b03a19b7475c403202741579fb151e16a busybox-1.35.0.tar.bz2 ead3403578c071c2216de17ab0543984c1f1509c12c062f03af49141547c3ea21356f3e8f0f0695550f05a41a1379dd73fc3cc18dcd78addbb411f247351e353 0001-nologin-Install-applet-to-sbin-instead-of-usr-sbin.patch a2787a3ecaf6746dadef62166e8ee6ecaa166147e5ad8b917c5838536057c875bab5f9cf40c3e05eba74d575484ac662929ac3799d58432d3a99ac46f364f302 0001-adduser-default-to-sbin-nologin-as-shell-for-system-.patch 1efe1c4894ae983fed5ac848125f8603f157b9d91c952c53f4192b48d3e50967e05559851148397b583f34fb02d480393547904b4635e4248248be567ab268ea 0001-properly-fix-wget-https-support.patch @@ -189,14 +194,19 @@ f12916e70f7cc1ef4f6d85d09b9a496a52a494e6318029fdce9a9c812ab5c7b2a046c33b66834127 df02adb3e3cd3349cc8d070911e3392164cb2e30bd72cae7ceaa974b2db6f958fdcedf809abc7b4bee37c729a4d20abf127f615b0e238a667d572137abe6a79e 0009-depmod-support-generating-kmod-binary-index-files.patch ecbe5c890d966f09280c7eb534109f785c68e292765f17ed7ff62fcc61d20f61443c4155add0a1ebfb67ce8564e104c1aa22a8ef0400e119b0bca2bca3671f2d 0010-Add-flag-for-not-following-symlinks-when-recursing.patch 3ae5ecf3ea66c8d98762432026806fdb67b13a28075c6a3cb6e811a34ef89c2f0ed651946003aaad97fb4b7f74d132af3c394c114b7a72e1d20b319b739c5a6e 0012-udhcpc-Don-t-background-if-n-is-given.patch -d12246f1134bbd3993462d27172c4739cc601b251d57ce8e088745773afa965551236e8cb8b9013dfc142fd055e369a771d86c7c54615c89bd30393400bfa390 0001-ash-add-built-in-BB_ASH_VERSION-variable.patch -6f8fa4ec190d64d6c3d5377994be933885ed0b40361c99ca35881684db3b1b79664d6eab56a389df290b9f6c4db502c617ec8e4ffa6d5284bd41cea1f478b26c 0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch -97109be04445b7b887c402b7072c1da57212ef11f2eca6d34c24d5a4e3b2866ee79aca7a0ca41043726293d9bed1b2fa8aab100501569f00b8670c280a87a01c 0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch +6b1ebc6da26c355a63c166f4c8d1774e7a9c5456ec76b773395a2158cb4848cf245fa5553843666c0a46f4c97d03e08815abae777f2b80bbb69d916618f94761 0013-ash-fix-unsafe-use-of-mempcpy.patch +3eb7609054fa8e03d7e366f7debc5cb0630ff65d521a91be84803bdef3854f81e29d26a9567c501a121e94a55d3a3477894e774508f80def775f2ecc812805e7 0014-ash-fix-use-after-free-in-bash-pattern-substitution.patch +0040800382a6e3adcc6a8094b821488c7e297fc80304afba23a4fca43b7b26ac699378dfbd930ebbf9985336b3e431301f7ca93e2d041a071902a48740d263ef 0015-ed-don-t-use-memcpy-with-overlapping-memory-regions.patch +4c95dc4bf6aff9018bfb52b400f6d8375a1d22493b44ea516cb12dba6556f12797a3cba55768d2e59ff57c0f3247ec1ff95edb8f17561f3d37ec18d83ca47eb0 0016-ash-don-t-read-past-end-of-var-in-subvareval-for-bas.patch +ccdf098fb15eaa316708181469a1193d6eec7067131e7b7645e0219bf03cfd07f4f79e8f62c1e560f6146dcc38186a29bdee08aaa39f290e11d020b8f07d2f65 0017-ash-Fix-use-after-free-on-idx-variable.patch +6d100fe44da2b97c2cbdda253d0504b487212d195144d9315cddbe8c51d18fae3745701923b170b40e35f54b592f94f02cadbffd9cb716661c12a7f1da022763 0001-ash-add-built-in-BB_ASH_VERSION-variable.patch e33dbc27d77c4636f4852d5d5216ef60a9a4343484e4559e391c13c813bf65c782b889914eff2e1f038d74cf02cb0d23824ebbb1044b5f8c86260d5a1bbc4e4d 0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch +2640698e5108434991a8491fcc508bd991d2111b14bb6957385393a36603e1d81fdf826ad7b150d487d2a924630ee54c0fc4f979214e90feca9ba7d2fd96a865 0001-avoid-redefined-warnings-when-building-with-utmps.patch b52050678e79e4da856956906d07fcb620cbf35f2ef6b5a8ee3b8d244ea63b4b98eef505451184d5b4937740d91eef154ed748c30d329ac485be51b37626f251 0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch ead4ad65d270d8659e1898fa16f76b6cbcf567d8aba238eacccda3764edb4362240d9359d6389873bedc126d405f805fc6dfce653a7181618ebcc67c94bd08d2 0002-nslookup-sanitize-all-printed-strings-with-printable.patch +4f6ddd59d6096943f617b0938fca428114190b8b37732d6783faab291451a2c30c452ed39299db22d1d9679d007022f87d43e93b38a4f6ced64a8659e9233773 0001-modinfo-add-k-option-for-kernel-version.patch aa93095e20de88730f526c6f463cef711b290b9582cdbd8c1ba2bd290019150cbeaa7007c2e15f0362d5b9315dd63f60511878f0ea05e893f4fdfb4a54af3fb1 acpid.logrotate -86171e6e1a2c905ca4182997812758a249c5b38a3371e925e78c533845ff5f0e8035d8baf223dbe3f8c2afd2237c243f14b76d42d7c5db69117bed59dee245d2 config +0b92eafab0722a6c9cc4880e3be4976de9713e1e1c715c6c727a948cbd68268fce01ce308291834f70d0cf3328f7c8a44cbdb5b7c70d90f91b15efcb5b90acb3 config c3194ccffe7300a0f55d50fb56d38c8df55d588adac13056fd0be2676594974477f94de5570a5a882bc864c3711cf67aa43b6ad6808e672f4533dd0f7363d2f5 default.script dd548670114a92404b8e35fb915fdbe5994498b05b0a418583271c3dd72fb7800950e42c095c902a014eb198c046b8a346d43dccd8e7a158048ae33767c572ed acpid.initd c9d0fb0f8cc27d661d3b4e58c56eb598ca368890576e18ffffd42efdf68ba35537656be9be319b2e2818aa0152d3ca8611bece2433512fbfcd4eed7988765549 crond.initd diff --git a/aports/busybox/config b/aports/busybox/config index 71b8a4b..5114bd3 100644 --- a/aports/busybox/config +++ b/aports/busybox/config @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Busybox version: 1.34.1 -# Sun Apr 24 10:12:56 2022 +# Busybox version: 1.35.0 +# Sat Jun 25 18:59:59 2022 # CONFIG_HAVE_DOT_CONFIG=y @@ -94,9 +94,12 @@ CONFIG_FEATURE_BUFFERS_USE_MALLOC=y CONFIG_PASSWORD_MINLEN=6 CONFIG_MD5_SMALL=1 CONFIG_SHA3_SMALL=1 -# CONFIG_FEATURE_FAST_TOP is not set -# CONFIG_FEATURE_ETC_NETWORKS is not set -# CONFIG_FEATURE_ETC_SERVICES is not set +CONFIG_FEATURE_NON_POSIX_CP=y +# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set +CONFIG_FEATURE_USE_SENDFILE=y +CONFIG_FEATURE_COPYBUF_KB=4 +CONFIG_MONOTONIC_SYSCALL=y +CONFIG_IOCTL_HEX2STR_ERROR=y CONFIG_FEATURE_EDITING=y CONFIG_FEATURE_EDITING_MAX_LEN=1024 # CONFIG_FEATURE_EDITING_VI is not set @@ -120,14 +123,6 @@ CONFIG_LAST_SUPPORTED_WCHAR=767 # CONFIG_UNICODE_BIDI_SUPPORT is not set # CONFIG_UNICODE_NEUTRAL_TABLE is not set # CONFIG_UNICODE_PRESERVE_BROKEN is not set -CONFIG_FEATURE_NON_POSIX_CP=y -# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set -CONFIG_FEATURE_USE_SENDFILE=y -CONFIG_FEATURE_COPYBUF_KB=4 -CONFIG_FEATURE_SKIP_ROOTFS=y -CONFIG_MONOTONIC_SYSCALL=y -CONFIG_IOCTL_HEX2STR_ERROR=y -# CONFIG_FEATURE_HWIB is not set # # Applets @@ -199,6 +194,22 @@ CONFIG_GZIP_FAST=0 # # Coreutils # +CONFIG_FEATURE_VERBOSE=y + +# +# Common options for date and touch +# +CONFIG_FEATURE_TIMEZONE=y + +# +# Common options for cp and mv +# +CONFIG_FEATURE_PRESERVE_HARDLINKS=y + +# +# Common options for df, du, ls +# +CONFIG_FEATURE_HUMAN_READABLE=y CONFIG_BASENAME=y CONFIG_CAT=y CONFIG_FEATURE_CATN=y @@ -227,6 +238,7 @@ CONFIG_FEATURE_DATE_COMPAT=y # CONFIG_FEATURE_DD_STATUS is not set CONFIG_DF=y CONFIG_FEATURE_DF_FANCY=y +CONFIG_FEATURE_SKIP_ROOTFS=y CONFIG_DIRNAME=y # CONFIG_DOS2UNIX is not set # CONFIG_UNIX2DOS is not set @@ -346,21 +358,6 @@ CONFIG_WHOAMI=y CONFIG_YES=y # -# Common options -# -CONFIG_FEATURE_VERBOSE=y - -# -# Common options for cp and mv -# -CONFIG_FEATURE_PRESERVE_HARDLINKS=y - -# -# Common options for df, du, ls -# -CONFIG_FEATURE_HUMAN_READABLE=y - -# # Console Utilities # # CONFIG_CHVT is not set @@ -446,7 +443,11 @@ CONFIG_FEATURE_VI_UNDO_QUEUE_MAX=0 CONFIG_FIND=y CONFIG_FEATURE_FIND_PRINT0=y CONFIG_FEATURE_FIND_MTIME=y +CONFIG_FEATURE_FIND_ATIME=y +CONFIG_FEATURE_FIND_CTIME=y CONFIG_FEATURE_FIND_MMIN=y +CONFIG_FEATURE_FIND_AMIN=y +CONFIG_FEATURE_FIND_CMIN=y CONFIG_FEATURE_FIND_PERM=y CONFIG_FEATURE_FIND_TYPE=y CONFIG_FEATURE_FIND_EXECUTABLE=y @@ -454,6 +455,7 @@ CONFIG_FEATURE_FIND_XDEV=y CONFIG_FEATURE_FIND_MAXDEPTH=y CONFIG_FEATURE_FIND_NEWER=y CONFIG_FEATURE_FIND_INUM=y +CONFIG_FEATURE_FIND_SAMEFILE=y CONFIG_FEATURE_FIND_EXEC=y CONFIG_FEATURE_FIND_EXEC_PLUS=y CONFIG_FEATURE_FIND_USER=y @@ -850,6 +852,9 @@ CONFIG_FEATURE_IPV6=y # CONFIG_FEATURE_UNIX_LOCAL is not set CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y # CONFIG_VERBOSE_RESOLUTION_ERRORS is not set +# CONFIG_FEATURE_ETC_NETWORKS is not set +# CONFIG_FEATURE_ETC_SERVICES is not set +# CONFIG_FEATURE_HWIB is not set # CONFIG_FEATURE_TLS_SHA1 is not set # CONFIG_ARP is not set # CONFIG_ARPING is not set @@ -868,6 +873,7 @@ CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y CONFIG_HOSTNAME=y # CONFIG_DNSDOMAINNAME is not set # CONFIG_HTTPD is not set +CONFIG_FEATURE_HTTPD_PORT_DEFAULT=0 # CONFIG_FEATURE_HTTPD_RANGES is not set # CONFIG_FEATURE_HTTPD_SETUID is not set # CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set @@ -960,6 +966,7 @@ CONFIG_SLATTACH=y # CONFIG_FEATURE_TELNET_WIDTH is not set # CONFIG_TELNETD is not set # CONFIG_FEATURE_TELNETD_STANDALONE is not set +CONFIG_FEATURE_TELNETD_PORT_DEFAULT=0 # CONFIG_FEATURE_TELNETD_INETD_WAIT is not set # CONFIG_TFTP is not set # CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set @@ -1024,17 +1031,19 @@ CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="" # # Mail Utilities # +CONFIG_FEATURE_MIME_CHARSET="" # CONFIG_MAKEMIME is not set # CONFIG_POPMAILDIR is not set # CONFIG_FEATURE_POPMAILDIR_DELIVERY is not set # CONFIG_REFORMIME is not set # CONFIG_FEATURE_REFORMIME_COMPAT is not set # CONFIG_SENDMAIL is not set -CONFIG_FEATURE_MIME_CHARSET="" # # Process Utilities # +# CONFIG_FEATURE_FAST_TOP is not set +CONFIG_FEATURE_SHOW_THREADS=y CONFIG_FREE=y CONFIG_FUSER=y CONFIG_IOSTAT=y @@ -1073,7 +1082,6 @@ CONFIG_FEATURE_TOPMEM=y CONFIG_UPTIME=y CONFIG_FEATURE_UPTIME_UTMP_SUPPORT=y CONFIG_WATCH=y -CONFIG_FEATURE_SHOW_THREADS=y # # Runit Utilities |