procps/procps-ng-3.3.8-accuracy.dif
Yuchen Lin 65afea1e3b Accepting request 614832 from Base:System
- Reference patch procps-ng-3.3.15-typo.patch this patch add a
  missed parenthesis for a nroff macro that is \*We become \*(We
  in line 2186 of top/top.1

- Update to procps-ng-3.3.15 (bsc#1092100)
  * library: Increment to 8:0:1
    No removals, no new functions
    Changes: slab and pid structures
  * library: Just check for SIGLOST and don't delete it    issue #93
  * library: Fix integer overflow and LPE in file2strvec   CVE-2018-1124
  * library: Use size_t for alloc functions                CVE-2018-1126
  * library: Increase comm size to 64
  * pgrep: Fix stack-based buffer overflow                 CVE-2018-1125
  * pgrep: Remove >15 warning as comm can be longer        issue #92
  * ps: Fix buffer overflow in output buffer, causing DOS  CVE-2018-1123
  * ps: Increase command name selection field to 64
  * top: Don't use cwd for location of config              CVE-2018-1122
- Increase so major number

OBS-URL: https://build.opensuse.org/request/show/614832
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/procps?expand=0&rev=112
2018-06-22 11:11:14 +00:00

100 lines
4.6 KiB
Plaintext

---
ps/common.h | 1 +
ps/global.c | 5 ++++-
ps/output.c | 19 ++++++++++---------
3 files changed, 15 insertions(+), 10 deletions(-)
--- ps/common.h
+++ ps/common.h 2018-04-04 11:14:33.915688098 +0000
@@ -302,6 +302,7 @@ extern int running_only;
extern int screen_cols;
extern int screen_rows;
extern time_t seconds_since_boot;
+extern unsigned long long jiffies_since_boot;
extern selection_node *selection_list;
extern unsigned simple_select;
extern sort_node *sort_list;
--- ps/global.c
+++ ps/global.c 2018-04-04 11:14:33.915688098 +0000
@@ -78,6 +78,7 @@ int prefer_bsd_defaults = -1
int screen_cols = -1;
int screen_rows = -1;
time_t seconds_since_boot = -1;
+unsigned long long jiffies_since_boot = -1;
selection_node *selection_list = (selection_node *)0xdeadbeef;
unsigned simple_select = 0xffffffff;
sort_node *sort_list = (sort_node *)0xdeadbeef; /* ready-to-use sort list */
@@ -361,6 +362,7 @@ static const char *set_personality(void)
/************ Call this to reinitialize everything ***************/
void reset_global(void){
static proc_t p;
+ double uptime_secs;
reset_selection_list();
look_up_our_self(&p);
set_screen_size();
@@ -383,7 +385,8 @@ void reset_global(void){
negate_selection = 0;
page_size = getpagesize();
running_only = 0;
- seconds_since_boot = uptime(0,0);
+ seconds_since_boot = uptime(&uptime_secs,0);
+ jiffies_since_boot = ((long double)uptime_secs * Hertz);
selection_list = NULL;
simple_select = 0;
sort_list = NULL;
--- ps/output.c
+++ ps/output.c 2018-04-04 11:14:33.915688098 +0000
@@ -134,6 +134,7 @@ static int sr_ ## NAME (const proc_t* P,
#define cook_time(P) (P->utime + P->stime) / Hertz
#define cook_etime(P) (((unsigned long long)seconds_since_boot >= (P->start_time / Hertz)) ? ((unsigned long long)seconds_since_boot - (P->start_time / Hertz)) : 0)
+#define cook_jtime(P) (((unsigned long long)jiffies_since_boot >= (P->start_time)) ? ((unsigned long long)jiffies_since_boot - (P->start_time)) : 0)
#define CMP_COOKED_TIME(NAME) \
static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \
@@ -507,11 +508,11 @@ static int pr_etimes(char *restrict cons
static int pr_c(char *restrict const outbuf, const proc_t *restrict const pp){
unsigned long long total_time; /* jiffies used by this process */
unsigned pcpu = 0; /* scaled %cpu, 99 means 99% */
- unsigned long long seconds; /* seconds of process life */
+ unsigned long long jiffies; /* jiffies of process life */
total_time = pp->utime + pp->stime;
if(include_dead_children) total_time += (pp->cutime + pp->cstime);
- seconds = cook_etime(pp);
- if(seconds) pcpu = (total_time * 100ULL / Hertz) / seconds;
+ jiffies = cook_jtime(pp);
+ if(jiffies) pcpu = (total_time * 100ULL) / jiffies;
if (pcpu > 99U) pcpu = 99U;
return snprintf(outbuf, COLWID, "%2u", pcpu);
}
@@ -519,11 +520,11 @@ static int pr_c(char *restrict const out
static int pr_pcpu(char *restrict const outbuf, const proc_t *restrict const pp){
unsigned long long total_time; /* jiffies used by this process */
unsigned pcpu = 0; /* scaled %cpu, 999 means 99.9% */
- unsigned long long seconds; /* seconds of process life */
+ unsigned long long jiffies; /* jiffies of process life */
total_time = pp->utime + pp->stime;
if(include_dead_children) total_time += (pp->cutime + pp->cstime);
- seconds = cook_etime(pp);
- if(seconds) pcpu = (total_time * 1000ULL / Hertz) / seconds;
+ jiffies = cook_jtime(pp);
+ if(jiffies) pcpu = (total_time * 1000ULL) / jiffies;
if (pcpu > 999U)
return snprintf(outbuf, COLWID, "%u", pcpu/10U);
return snprintf(outbuf, COLWID, "%u.%u", pcpu/10U, pcpu%10U);
@@ -532,11 +533,11 @@ static int pr_pcpu(char *restrict const
static int pr_cp(char *restrict const outbuf, const proc_t *restrict const pp){
unsigned long long total_time; /* jiffies used by this process */
unsigned pcpu = 0; /* scaled %cpu, 999 means 99.9% */
- unsigned long long seconds; /* seconds of process life */
+ unsigned long long jiffies; /* jiffies of process life */
total_time = pp->utime + pp->stime;
if(include_dead_children) total_time += (pp->cutime + pp->cstime);
- seconds = cook_etime(pp);
- if(seconds) pcpu = (total_time * 1000ULL / Hertz) / seconds;
+ jiffies = cook_jtime(pp);
+ if(jiffies) pcpu = (total_time * 1000ULL) / jiffies;
if (pcpu > 999U) pcpu = 999U;
return snprintf(outbuf, COLWID, "%3u", pcpu);
}