Compare commits

..

No commits in common. "98aefb47d456fe4f8873f063f36c4c6d0120fae7" and "930ebc654e41e16fd9a885da84d9591556fe0c77" have entirely different histories.

7 changed files with 1 additions and 409 deletions

View File

@ -1,32 +0,0 @@
From 92bdeb176f3ce8793ba1a2f3d82525b5c51f7449 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Wed, 4 Oct 2023 12:00:00 -0500
Subject: [PATCH] NEWS: acknowledge fix for the lost tasks ps issue #304
[ and eliminate 1 decades old useless initialization ]
Reference(s):
. Sep, 2023 - fix for ps issue #304
commit 09fbd70de33c451dde84254718ded2ccac48aed4
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
src/ps/display.c | 2 +-
1 files changed, 1 insertions(+), 1 deletion(-)
diff --git a/src/ps/display.c b/src/ps/display.c
index 325edf38..9b5c7165 100644
--- a/src/ps/display.c
+++ b/src/ps/display.c
@@ -357,7 +357,7 @@ next_proc:
/***** forest output requires sorting by ppid; add start_time by default */
static void prep_forest_sort(void){
- sort_node *endp, *tmp_list = sort_list;
+ sort_node *endp, *tmp_list;
const format_struct *incoming;
if(!sort_list) { /* assume start time order */
--
GitLab

View File

@ -1,79 +0,0 @@
From 6418b8c1fbcfdcda4cad8efacccceb7bcdbb1de9 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Wed, 20 Mar 2024 00:00:00 -0500
Subject: [PATCH] library: address remaining cpu distortions, <stat> api
When the potential cpu distortion was addressed in the
commit referenced below, the revision did not quite go
far enough. This was revealed in the merge plus issue
posts also shown. Thus a need for this final solution.
[ and now that all the stat_jifs fields are verified ]
[ that TICsetH macro need not check for distortions. ]
Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/223
https://gitlab.com/procps-ng/procps/-/issues/321
. Mar, 2017 - cpu distorions relocated/improved
commit 253ac7f709412a8699767bd70faeaf98e19614f0
Discovered-by: Chao Liu SuperSix173 <liuchao173@huawei.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
library/stat.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/library/stat.c b/library/stat.c
index c37e9b54..b04fe0a5 100644
--- a/library/stat.c
+++ b/library/stat.c
@@ -182,9 +182,10 @@ struct stat_info {
#define SYS_set(e,t,x) setDECL(e) { \
(void)T; R->result. t = S->new. x; }
// delta assignment
+// ( thanks to 'stat_derive_unique', this macro no longer needs to )
+// ( protect against a negative value when a cpu is brought online )
#define TICsetH(e,t,x) setDECL(e) { \
- (void)S; R->result. t = ( T->new. x - T->old. x ); \
- if (R->result. t < 0) R->result. t = 0; }
+ (void)S; R->result. t = ( T->new. x - T->old. x ); }
#define SYSsetH(e,t,x) setDECL(e) { \
(void)T; R->result. t = ( S->new. x - S->old. x ); }
@@ -555,6 +556,9 @@ wrap_up:
static inline void stat_derive_unique (
struct hist_tic *this)
{
+ unsigned long long *new, *old;
+ int i;
+
/* note: we calculate these derived values in a manner consistent with
the calculations for cgroup accounting, as nearly as possible
( see linux sources: ./kernel/cgroup/rstat.c, root_cgroup_cputime ) */
@@ -576,13 +580,15 @@ static inline void stat_derive_unique (
this->new.xbsy
= this->new.xtot - this->new.xidl;
- // don't distort deltas when cpus are taken offline or brought online
- if (this->new.xusr < this->old.xusr
- || (this->new.xsys < this->old.xsys)
- || (this->new.xidl < this->old.xidl)
- || (this->new.xbsy < this->old.xbsy)
- || (this->new.xtot < this->old.xtot))
- memcpy(&this->old, &this->new, sizeof(struct stat_jifs));
+ // don't distort results when cpus are brought back online
+ new = (unsigned long long *)&this->new;
+ old = (unsigned long long *)&this->old;
+ for (i = 0; i < sizeof(struct stat_jifs) / sizeof(unsigned long long); i++) {
+ if (*(new++) < *(old++)) {
+ memcpy(&this->old, &this->new, sizeof(struct stat_jifs));
+ break;
+ }
+ }
} // end: stat_derive_unique
--
2.33.0

View File

@ -1,73 +0,0 @@
From dd3cb0892d142e370413e1cba582d390042883e5 Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Mon, 19 Dec 2022 16:50:12 +1100
Subject: [PATCH] ps: Correct BSD c option
procps 3.3.17 the c option changed the command/args field
to cmd but this got removed as part of newlib
Functionality is back in with a test case.
References:
https://bugs.debian.org/1026326
Signed-off-by: Craig Small <csmall@dropbear.xyz>
---
NEWS | 1 +
src/ps/output.c | 7 +++++--
testsuite/ps.test/ps_output.exp | 6 ++++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 2d13978d..8a2d6b04 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,8 @@ procps-ng-NEXT
---------------
* docs: Don't install English manpages twice
* skill: Match on -p again Debian #1025915
+ * ps: c flag shows command name again Debian #1026326
* vmstat: Referesh memory statistics Debian #1027963
procps-ng-4.0.2
---------------
* library revision - 0:1:0
diff --git a/src/ps/output.c b/src/ps/output.c
index 5a14f5be..26001a6c 100644
--- a/src/ps/output.c
+++ b/src/ps/output.c
@@ -403,13 +403,16 @@ Modifications to the arguments are not shown.
static int pr_args(char *restrict const outbuf, const proc_t *restrict const pp){
char *endp;
int rightward, fh;
-setREL2(CMDLINE,ENVIRON)
+setREL3(CMDLINE,CMD,ENVIRON)
endp = outbuf;
rightward = max_rightward;
fh = forest_helper(outbuf);
endp += fh;
rightward -= fh;
- endp += escape_str(endp, rSv(CMDLINE, str, pp), OUTBUF_SIZE_AT(endp), &rightward);
+ if (!bsd_c_option)
+ endp += escape_str(endp, rSv(CMDLINE, str, pp), OUTBUF_SIZE_AT(endp), &rightward);
+ else
+ endp += escape_str(endp, rSv(CMD, str, pp), OUTBUF_SIZE_AT(endp), &rightward);
if(bsd_e_option && rightward>1) {
char *e = rSv(ENVIRON, str, pp);
if(*e != '-' || *(e+1) != '\0') {
diff --git a/testsuite/ps.test/ps_output.exp b/testsuite/ps.test/ps_output.exp
index 998490e5..b0f789e0 100644
--- a/testsuite/ps.test/ps_output.exp
+++ b/testsuite/ps.test/ps_output.exp
@@ -51,3 +51,9 @@ expect_pass "$test" "error: missing AIX field descriptor"
set test "ps with unknown AIX field"
spawn $ps -o "%p %Z"
expect_pass "$test" "error: unknown AIX field descriptor"
+
+make_testproc
+set test "ps with c option"
+spawn $ps co command $testproc1_pid
+expect_pass "$test" "^COMMAND\\s+spcorp\\s*$"
+kill_testproc
--
2.33.0

View File

@ -1,70 +0,0 @@
From 2c933ecba3bb1d3041a5a7a53a7b4078a6003413 Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Thu, 10 Aug 2023 21:18:38 +1000
Subject: [PATCH] ps: Fix possible buffer overflow in -C option
ps allocates memory using malloc(length of arg * len of struct).
In certain strange circumstances, the arg length could be very large
and the multiplecation will overflow, allocating a small amount of
memory.
Subsequent strncpy() will then write into unallocated memory.
The fix is to use calloc. It's slower but this is a one-time
allocation. Other malloc(x * y) calls have also been replaced
by calloc(x, y)
References:
https://www.freelists.org/post/procps/ps-buffer-overflow-CVE-20234016
https://nvd.nist.gov/vuln/detail/CVE-2023-4016
https://gitlab.com/procps-ng/procps/-/issues/297
https://bugs.debian.org/1042887
Conflict: remove NEWS part
Signed-off-by: Craig Small <csmall@dropbear.xyz>
---
src/ps/parser.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/ps/parser.c b/src/ps/parser.c
index 248aa741..15873dfa 100644
--- a/src/ps/parser.c
+++ b/src/ps/parser.c
@@ -189,7 +189,6 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
const char *err; /* error code that could or did happen */
/*** prepare to operate ***/
node = xmalloc(sizeof(selection_node));
- node->u = xmalloc(strlen(arg)*sizeof(sel_union)); /* waste is insignificant */
node->n = 0;
buf = strdup(arg);
/*** sanity check and count items ***/
@@ -210,6 +209,7 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
} while (*++walk);
if(need_item) goto parse_error;
node->n = items;
+ node->u = xcalloc(items, sizeof(sel_union));
/*** actually parse the list ***/
walk = buf;
while(items--){
@@ -1050,15 +1050,15 @@ static const char *parse_trailing_pids(void){
thisarg = ps_argc - 1; /* we must be at the end now */
pidnode = xmalloc(sizeof(selection_node));
- pidnode->u = xmalloc(i*sizeof(sel_union)); /* waste is insignificant */
+ pidnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
pidnode->n = 0;
grpnode = xmalloc(sizeof(selection_node));
- grpnode->u = xmalloc(i*sizeof(sel_union)); /* waste is insignificant */
+ grpnode->u = xcalloc(i,sizeof(sel_union)); /* waste is insignificant */
grpnode->n = 0;
sidnode = xmalloc(sizeof(selection_node));
- sidnode->u = xmalloc(i*sizeof(sel_union)); /* waste is insignificant */
+ sidnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
sidnode->n = 0;
while(i--){
--
2.33.0

View File

@ -1,63 +0,0 @@
From 09fbd70de33c451dde84254718ded2ccac48aed4 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Wed, 20 Sep 2023 00:00:00 -0500
Subject: [PATCH] ps: don't lose tasks when --sort used with forest mode
In an issue cited below the loss of tasks was revealed
whenever the --sort option is used in combination with
forest mode. One could argue against such combinations
and print an error. But we'll take an easier approach.
This patch restores the prior version 3.3.17 behavior.
Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/304
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
src/ps/display.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/ps/display.c b/src/ps/display.c
index e1a3b0da..325edf38 100644
--- a/src/ps/display.c
+++ b/src/ps/display.c
@@ -357,12 +357,12 @@ next_proc:
/***** forest output requires sorting by ppid; add start_time by default */
static void prep_forest_sort(void){
- sort_node *tmp_list = sort_list;
+ sort_node *endp, *tmp_list = sort_list;
const format_struct *incoming;
if(!sort_list) { /* assume start time order */
- incoming = search_format_array("ppid");
- if(!incoming) { fprintf(stderr, _("could not find ppid\n")); exit(1); }
+ incoming = search_format_array("start_time");
+ if(!incoming) { fprintf(stderr, _("could not find start_time\n")); exit(1); }
tmp_list = xmalloc(sizeof(sort_node));
tmp_list->reverse = PIDS_SORT_ASCEND;
tmp_list->typecode = '?'; /* what was this for? */
@@ -371,14 +371,15 @@ static void prep_forest_sort(void){
sort_list = tmp_list;
}
/* this is required for the forest option */
- incoming = search_format_array("start_time");
- if(!incoming) { fprintf(stderr, _("could not find start_time\n")); exit(1); }
+ incoming = search_format_array("ppid");
+ if(!incoming) { fprintf(stderr, _("could not find ppid\n")); exit(1); }
tmp_list = xmalloc(sizeof(sort_node));
tmp_list->reverse = PIDS_SORT_ASCEND;
tmp_list->typecode = '?'; /* what was this for? */
tmp_list->sr = incoming->sr;
- tmp_list->next = sort_list;
- sort_list = tmp_list;
+ tmp_list->next = NULL;
+ endp = sort_list; while(endp->next) endp = endp->next;
+ endp->next = tmp_list;
}
/* we rely on the POSIX requirement for zeroed memory */
--
GitLab

View File

@ -1,70 +0,0 @@
From f4eeff0b26a2c48552f8ed843bea95bf97437d2a Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Tue, 11 Jul 2023 19:16:15 +1000
Subject: [PATCH] vmstat: Print guest time
Guest time was removed from User time but not printed. This meant
that if guest time was non-zero then the CPU numbers did not add
up to 100%
References:
!191
!113
commit 2461bb5bc17ee4bc01b142b5bba2c5d87578285c
Signed-off-by: Craig Small <csmall@dropbear.xyz>
---
src/vmstat.c | 6 +++---
testsuite/vmstat.test/vmstat.exp | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/vmstat.c b/src/vmstat.c
index acb7b80..68d356c 100644
--- a/src/vmstat.c
+++ b/src/vmstat.c
@@ -254,13 +254,13 @@ static void new_header(void)
* that follow (marked with max x chars) might not work,
* unless manual page is translated as well. */
const char *header =
- _("procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----");
+ _("procs -----------memory---------- ---swap-- -----io---- -system-- -------cpu-------");
const char *wide_header =
_("--procs-- -----------------------memory---------------------- ---swap-- -----io---- -system-- ----------cpu----------");
const char *timestamp_header = _(" -----timestamp-----");
const char format[] =
- "%2s %2s %6s %6s %6s %6s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s";
+ "%2s %2s %6s %6s %6s %6s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s %2s";
const char wide_format[] =
"%4s %4s %12s %12s %12s %12s %4s %4s %5s %5s %4s %4s %3s %3s %3s %3s %3s %3s";
@@ -349,7 +349,7 @@ static void new_format(void)
#define MEMv(E) MEMINFO_VAL(E, ul_int, mem_stack, mem_info)
#define DSYSv(E) STAT_VAL(E, s_int, stat_stack, stat_info)
const char format[] =
- "%2lu %2lu %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u";
+ "%2lu %2lu %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u %2u";
const char wide_format[] =
"%4lu %4lu %12lu %12lu %12lu %12lu %4u %4u %5u %5u %4u %4u %3u %3u %3u %3u %3u %3u";
diff --git a/testsuite/vmstat.test/vmstat.exp b/testsuite/vmstat.test/vmstat.exp
index 1cd13a1..48d0b0f 100644
--- a/testsuite/vmstat.test/vmstat.exp
+++ b/testsuite/vmstat.test/vmstat.exp
@@ -12,11 +12,11 @@ if { [ file readable "/proc/vmstat" ] == 0 } {
} else {
set test "vmstat with no arguments"
spawn $vmstat
- expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+buff\\s+cache\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st\\s*\(\\s+\\d+\){17}\\s*$"
+ expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+buff\\s+cache\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st gu\\s*\(\\s+\\d+\){18}\\s*$"
set test "vmstat with -a flag"
spawn $vmstat -a
- expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+inact\\s+active\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st\\s*\(\\s+\\d+\){17}\\s*$"
+ expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+inact\\s+active\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st gu\\s*\(\\s+\\d+\){18}\\s*$"
set test "vmstat fork option"
spawn $vmstat -f
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: procps-ng
Version: 4.0.2
Release: 13
Release: 8
Summary: Utilities that provide system information.
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
URL: https://sourceforge.net/projects/procps-ng/
@ -20,12 +20,6 @@ Patch8: backport-pmap-Increase-memory-allocation-failure-judgment.patch
Patch9: backport-top-added-guest-tics-when-multiple-cpus-were-merged.patch
Patch10: backport-library-restore-the-proper-main-thread-tics-valuation.patch
Patch11: backport-vmstat-Update-memory-statistics.patch
Patch12: backport-vmstat-Print-guest-time.patch
Patch13: backport-ps-Fix-possible-buffer-overflow-in-C-option.patch
Patch14: backport-ps-Correct-BSD-c-option.patch
Patch15: backport-library-address-remaining-cpu-distortions-stat-api.patch
Patch16: backport-ps-don-t-lose-tasks-when-sort-used-with-forest-mode.patch
Patch17: backport-acknowledge-fix-for-the-lost-tasks-ps-issue.patch
BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel systemd-pam
@ -108,21 +102,6 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
%{_mandir}/man*
%changelog
* Thu Apr 25 2024 yinyongkang <yinyongkang@kylinos.cn> - 4.0.2-13
- ps: don't lose tasks when --sort used with forest mode
* Tue Apr 02 2024 Liu Chao <liuchao173@huawei.com> - 4.0.2-12
- library: address remaining cpu distorrions, <stat> api
* Fri Mar 29 2024 Weifeng Su <suweifeng1@huawei.com> - 4.0.2-11
- backport patch to Correct BSD c option issue
* Tue Aug 15 2023 Liu Chao <liuchao173@huawei.com> - 4.0.2-10
- ps: Fix possible buffer overflow in -C option
* Thu Jul 13 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-9
- vmstat: print guest time
* Wed Jul 12 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-8
- vmstat: Update memory statistics