From 2f7c9d51349dd8ccfacd5b72dec2c62565d39584 Mon Sep 17 00:00:00 2001 From: Stefan Jumarea Date: Sat, 4 Mar 2023 15:00:29 +0200 Subject: [PATCH 1/2] Makefile.uk: Add ucontext.h header The `ucontext.h` header is needed by the `ucontext` library. Signed-off-by: Stefan Jumarea --- Makefile.uk.musl.linux | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.uk.musl.linux b/Makefile.uk.musl.linux index ff19844..757531f 100644 --- a/Makefile.uk.musl.linux +++ b/Makefile.uk.musl.linux @@ -37,6 +37,7 @@ LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/wait.h LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/xattr.h LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/time.h LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/unistd.h +LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/ucontext.h LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/adjtime.c LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/adjtimex.c From 38dda468e00cde9c6a0de99549f5109fcfbe3338 Mon Sep 17 00:00:00 2001 From: Stefan Jumarea Date: Sat, 4 Mar 2023 15:01:08 +0200 Subject: [PATCH 2/2] patches: Check is libc.auxv is NULL before derefering The `dl_iterate_phdr` function checks the value of `libc.auxv[i]` without checking if `libc.auvx` is NULL or not, which can lead to segfaults. Signed-off-by: Stefan Jumarea --- ...-libc.auxv-is-NULL-before-derefering.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 patches/0020-PATCH-Check-if-libc.auxv-is-NULL-before-derefering.patch diff --git a/patches/0020-PATCH-Check-if-libc.auxv-is-NULL-before-derefering.patch b/patches/0020-PATCH-Check-if-libc.auxv-is-NULL-before-derefering.patch new file mode 100644 index 0000000..457d0d1 --- /dev/null +++ b/patches/0020-PATCH-Check-if-libc.auxv-is-NULL-before-derefering.patch @@ -0,0 +1,26 @@ +From 806eb5a52058fe1ac1dbd85bc418d11b2e622d48 Mon Sep 17 00:00:00 2001 +From: Stefan Jumarea +Date: Sat, 4 Mar 2023 11:39:51 +0200 +Subject: [PATCH] [PATCH]: Check if libc.auxv is NULL before derefering it + +Signed-off-by: Stefan Jumarea +--- + src/ldso/dl_iterate_phdr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/ldso/dl_iterate_phdr.c b/src/ldso/dl_iterate_phdr.c +index 9546dd3..c869812 100644 +--- a/src/ldso/dl_iterate_phdr.c ++++ b/src/ldso/dl_iterate_phdr.c +@@ -16,7 +16,7 @@ static int static_dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size + struct dl_phdr_info info; + size_t i, aux[AUX_CNT] = {0}; + +- for (i=0; libc.auxv[i]; i+=2) ++ for (i=0; libc.auxv && libc.auxv[i]; i+=2) + if (libc.auxv[i]