diff options
3 files changed, 110 insertions, 0 deletions
diff --git a/meta/recipes-extended/procps/procps/0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch b/meta/recipes-extended/procps/procps/0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch new file mode 100644 index 0000000000..bbc137a3d8 --- /dev/null +++ b/meta/recipes-extended/procps/procps/0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | From 37f106029975e3045b0cd779525d14c55d24b74e Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jim Warner <james.warner@comcast.net> | ||
| 3 | Date: Mon, 21 Jun 2021 00:00:00 -0500 | ||
| 4 | Subject: [PATCH] top: fix a fix for the 'bye_bye' function (merge #127) | ||
| 5 | |||
| 6 | In the merge request shown below, 1 too many bytes are | ||
| 7 | written to stdout thus including the terminating null. | ||
| 8 | As the cure, this commit just reduces the length by 1. | ||
| 9 | |||
| 10 | [ along the way, we will remove some unneeded braces ] | ||
| 11 | [ plus add some additional comments with attribution ] | ||
| 12 | |||
| 13 | Reference(s): | ||
| 14 | https://gitlab.com/procps-ng/procps/-/merge_requests/127 | ||
| 15 | . original merged change | ||
| 16 | commit 0bf15c004db6a3342703a3c420a5692e376c457d | ||
| 17 | |||
| 18 | Signed-off-by: Jim Warner <james.warner@comcast.net> | ||
| 19 | |||
| 20 | Upstream-Status: Backport [https://gitlab.com/procps-ng/procps/-/commit/37f106029975e3045b0cd779525d14c55d24b74e] | ||
| 21 | |||
| 22 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> | ||
| 23 | --- | ||
| 24 | top/top.c | 14 +++++++++++--- | ||
| 25 | 1 file changed, 11 insertions(+), 3 deletions(-) | ||
| 26 | |||
| 27 | diff --git a/top/top.c b/top/top.c | ||
| 28 | index 4d9860d5..0d21a1a5 100644 | ||
| 29 | --- a/top/top.c | ||
| 30 | +++ b/top/top.c | ||
| 31 | @@ -569,13 +569,21 @@ static void bye_bye (const char *str) { | ||
| 32 | #endif // end: OFF_HST_HASH | ||
| 33 | |||
| 34 | numa_uninit(); | ||
| 35 | + | ||
| 36 | + /* we'll only have a 'str' if called by error_exit() | | ||
| 37 | + or that xalloc_our_handler() function. if we were | | ||
| 38 | + called from a sig_endpgm(), that parm is NULL ... | */ | ||
| 39 | if (str) { | ||
| 40 | fputs(str, stderr); | ||
| 41 | exit(EXIT_FAILURE); | ||
| 42 | } | ||
| 43 | - if (Batch) { | ||
| 44 | - write(fileno(stdout), "\n", sizeof("\n")); | ||
| 45 | - } | ||
| 46 | + /* this could happen when called from several places | | ||
| 47 | + including that sig_endpgm(). thus we must use an | | ||
| 48 | + async-signal-safe write function just in case ... | | ||
| 49 | + (thanks: Shaohua Zhan shaohua.zhan@windriver.com) | */ | ||
| 50 | + if (Batch) | ||
| 51 | + write(fileno(stdout), "\n", sizeof("\n") - 1); | ||
| 52 | + | ||
| 53 | exit(EXIT_SUCCESS); | ||
| 54 | } // end: bye_bye | ||
| 55 | |||
| 56 | -- | ||
| 57 | 2.34.1 | ||
| 58 | |||
diff --git a/meta/recipes-extended/procps/procps/0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch b/meta/recipes-extended/procps/procps/0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch new file mode 100644 index 0000000000..4da13df047 --- /dev/null +++ b/meta/recipes-extended/procps/procps/0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | From 6b8980a3b6279058d727377e914cfb6439d6f178 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Shaohua Zhan <shaohua.zhan@windriver.com> | ||
| 3 | Date: Mon, 22 Mar 2021 00:00:00 +0800 | ||
| 4 | Subject: [PATCH] top: replaced one use of fputs(3) with a write(2) call | ||
| 5 | |||
| 6 | This patch is ported from a merge request shown below, | ||
| 7 | and the following represents the original commit text. | ||
| 8 | |||
| 9 | ------------------------------------------------------ | ||
| 10 | top: In the bye_bye function, replace fputs with the write interface. | ||
| 11 | |||
| 12 | When top calls malloc, if a signal is received, it will | ||
| 13 | call sig_endpgm to process the signal. In the bye_bye function, if the | ||
| 14 | -b option is enable, the Batch variable is set, the fputs function | ||
| 15 | will calls malloc at the same time. The malloc function is not reentrant, so | ||
| 16 | it will cause the program to crash. | ||
| 17 | |||
| 18 | Signed-off-by: Shaohua Zhan <shaohua.zhan@windriver.com> | ||
| 19 | ------------------------------------------------------ | ||
| 20 | |||
| 21 | Reference(s): | ||
| 22 | https://gitlab.com/procps-ng/procps/-/merge_requests/127 | ||
| 23 | |||
| 24 | Signed-off-by: Jim Warner <james.warner@comcast.net> | ||
| 25 | |||
| 26 | Upstream-Status: Backport [https://gitlab.com/procps-ng/procps/-/commit/6b8980a3b6279058d727377e914cfb6439d6f178] | ||
| 27 | |||
| 28 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> | ||
| 29 | --- | ||
| 30 | top/top.c | 4 +++- | ||
| 31 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
| 32 | |||
| 33 | diff --git a/top/top.c b/top/top.c | ||
| 34 | index f4f82be4..951c240c 100644 | ||
| 35 | --- a/top/top.c | ||
| 36 | +++ b/top/top.c | ||
| 37 | @@ -417,7 +417,9 @@ static void bye_bye (const char *str) { | ||
| 38 | fputs(str, stderr); | ||
| 39 | exit(EXIT_FAILURE); | ||
| 40 | } | ||
| 41 | - if (Batch) fputs("\n", stdout); | ||
| 42 | + if (Batch) { | ||
| 43 | + write(fileno(stdout), "\n", sizeof("\n")); | ||
| 44 | + } | ||
| 45 | exit(EXIT_SUCCESS); | ||
| 46 | } // end: bye_bye | ||
| 47 | |||
| 48 | -- | ||
| 49 | 2.34.1 | ||
| 50 | |||
diff --git a/meta/recipes-extended/procps/procps_3.3.17.bb b/meta/recipes-extended/procps/procps_3.3.17.bb index bbec5a543c..131063efb9 100644 --- a/meta/recipes-extended/procps/procps_3.3.17.bb +++ b/meta/recipes-extended/procps/procps_3.3.17.bb | |||
| @@ -18,6 +18,8 @@ SRC_URI = "git://gitlab.com/procps-ng/procps.git;protocol=https;branch=master \ | |||
| 18 | file://0002-proc-escape.c-add-missing-include.patch \ | 18 | file://0002-proc-escape.c-add-missing-include.patch \ |
| 19 | file://CVE-2023-4016.patch \ | 19 | file://CVE-2023-4016.patch \ |
| 20 | file://CVE-2023-4016-2.patch \ | 20 | file://CVE-2023-4016-2.patch \ |
| 21 | file://0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch \ | ||
| 22 | file://0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch \ | ||
| 21 | " | 23 | " |
| 22 | SRCREV = "19a508ea121c0c4ac6d0224575a036de745eaaf8" | 24 | SRCREV = "19a508ea121c0c4ac6d0224575a036de745eaaf8" |
| 23 | 25 | ||
