Package: procps / 2:3.3.12-3+deb9u1
Metadata
Package | Version | Patches format |
---|---|---|
procps | 2:3.3.12-3+deb9u1 | 3.0 (quilt) |
Patch series
view the series filePatch | File delta | Description |
---|---|---|
remove_strtod_tests | (download) |
lib/test_strtod_nol.c |
1 1 + 0 - 0 ! |
--- |
watch_hostname_max_define | (download) |
watch.c |
4 4 + 0 - 0 ! |
--- |
disable_sched_test | (download) |
testsuite/ps.test/ps_sched_batch.exp |
16 8 + 8 - 0 ! |
disable ps sched test Disables the command to test the class of scheduler used in ps -o cls For some reason, some Debian buildds fail on this test, however running the command in the environment works, chalk it down to buildd oddness and move along. |
uptime_test | (download) |
testsuite/w.test/w.exp |
16 8 + 8 - 0 ! |
--- |
832148_no_sigpwr | (download) |
proc/sig.c |
4 3 + 1 - 0 ! |
no sigpwr on freebsd Removes warning and definition for SIGPWR on FreeBSD as it doesn't exist there anyhow. |
0008 pgrep Prevent a potential stack based buffer overflo.patch | (download) |
pgrep.c |
27 16 + 11 - 0 ! |
[patch 008/126] pgrep: prevent a potential stack-based buffer overflow. This is one of the worst issues that we found: if the strlen() of one of the cmdline arguments is greater than INT_MAX (it is possible), then the "int bytes" could wrap around completely, back to a very large positive int, and the next strncat() would be called with a huge number of destination bytes (a stack-based buffer overflow). Fortunately, every distribution that we checked compiles its procps utilities with FORTIFY, and the fortified strncat() detects and aborts the buffer overflow before it occurs. This patch also fixes a secondary issue: the old "--bytes;" meant that cmdline[sizeof (cmdline) - 2] was never written to if the while loop was never entered; in the example below, "ff" is the uninitialized byte: ((exec -ca `python3 -c 'print("A" * 131000)'` /usr/bin/cat < /dev/zero) | sleep 60) & pgrep -a -P "$!" 2>/dev/null | hexdump -C 00000000 31 32 34 36 30 20 41 41 41 41 41 41 41 41 41 41 |12460 AAAAAAAAAA| 00000010 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 |AAAAAAAAAAAAAAAA| * 00001000 41 41 41 41 ff 0a 31 32 34 36 32 20 73 6c 65 65 |AAAA..12462 slee| 00001010 70 20 36 30 0a |p 60.| |
0035 proc alloc. Use size_t not unsigned int.patch | (download) |
proc/alloc.c |
20 12 + 8 - 0 ! |
[patch 035/126] proc/alloc.*: use size_t, not unsigned int. Otherwise this can truncate sizes on 64-bit platforms, and is one of the reasons the integer overflows in file2strvec() are exploitable at all. Also: catch potential integer overflow in xstrdup() (should never happen, but better safe than sorry), and use memcpy() instead of strcpy() (faster). Warnings: - in glibc, realloc(ptr, 0) is equivalent to free(ptr), but not here, because of the ++size; - here, xstrdup() can return NULL (if str is NULL), which goes against the idea of the xalloc wrappers. We were tempted to call exit() or xerrx() in those cases, but decided against it, because it might break things in unexpected places; TODO? |
0054 ps output.c Fix outbuf overflows in pr_args etc.patch | (download) |
ps/output.c |
23 14 + 9 - 0 ! |
[patch 054/126] ps/output.c: fix outbuf overflows in pr_args() etc. Because there is usually less than OUTBUF_SIZE available at endp. |
0074 proc readproc.c Fix bugs and overflows in file2strve.patch | (download) |
proc/readproc.c |
54 33 + 21 - 0 ! |
[patch 074/126] proc/readproc.c: fix bugs and overflows in file2strvec(). Note: this is by far the most important and complex patch of the whole series, please review it carefully; thank you very much! For this patch, we decided to keep the original function's design and skeleton, to avoid regressions and behavior changes, while fixing the various bugs and overflows. And like the "Harden file2str()" patch, this patch does not fail when about to overflow, but truncates instead: there is information available about this process, so return it to the caller; also, we used INT_MAX as a limit, but a lower limit could be used. The easy changes: - Replace sprintf() with snprintf() (and check for truncation). - Replace "if (n == 0 && rbuf == 0)" with "if (n <= 0 && tot <= 0)" and do break instead of return: it simplifies the code (only one place to handle errors), and also guarantees that in the while loop either n or tot is > 0 (or both), even if n is reset to 0 when about to overflow. - Remove the "if (n < 0)" block in the while loop: it is (and was) dead code, since we enter the while loop only if n >= 0. - Rewrite the missing-null-terminator detection: in the original function, if the size of the file is a multiple of 2047, a null- terminator is appended even if the file is already null-terminated. - Replace "if (n <= 0 && !end_of_file)" with "if (n < 0 || tot <= 0)": originally, it was equivalent to "if (n < 0)", but we added "tot <= 0" to handle the first break of the while loop, and to guarantee that in the rest of the function tot is > 0. - Double-force ("belt and suspenders") the null-termination of rbuf: this is (and was) essential to the correctness of the function. - Replace the final "while" loop with a "for" loop that behaves just like the preceding "for" loop: in the original function, this would lead to unexpected results (for example, if rbuf is |\0|A|\0|, this would return the array {"",NULL} but should return {"","A",NULL}; and if rbuf is |A|\0|B| (should never happen because rbuf should be null- terminated), this would make room for two pointers in ret, but would write three pointers to ret). The hard changes: - Prevent the integer overflow of tot in the while loop, but unlike file2str(), file2strvec() cannot let tot grow until it almost reaches INT_MAX, because it needs more space for the pointers: this is why we introduced ARG_LEN, which also guarantees that we can add "align" and a few sizeof(char*)s to tot without overflowing. - Prevent the integer overflow of "tot + c + align": when INT_MAX is (almost) reached, we write the maximal safe amount of pointers to ret (ARG_LEN guarantees that there is always space for *ret = rbuf and the NULL terminator). [carnil: backport for 3.3.12: Add include for limits.h and use of MAX_INT] |
0097 top Do not default to the cwd in configs_read.patch | (download) |
top/top.c |
24 23 + 1 - 0 ! |
[patch 097/126] top: do not default to the cwd in configs_read(). If the HOME environment variable is not set, or not absolute, use the home directory returned by getpwuid(getuid()), if set and absolute (instead of the cwd "."); otherwise, set p_home to NULL. To keep the changes to a minimum, we rely on POSIX, which requires that fopen() fails with ENOENT if the pathname (Rc_name) is an empty string. This integrates well into the existing code, and makes write_rcfile() work without a change. Also, it makes the code in configs_read() easier to follow: only set and use p_home if safe, and only set Rc_name if safe (in all the other cases it is the empty string, and the fopen() calls fail). Plus, check for snprintf() truncation (and if it happens, reset Rc_name to the empty string). Important note: top.1 should probably be updated, since it mentions the fallback to the current working directory. [carnil: Backport to 3.3.12: p_home -> p, context] |