Summary: | [patch] procstat shows wrong stack nx information in ELF auxv mode | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | J. Pernfuß <code.jpe> | ||||||
Component: | bin | Assignee: | Allan Jude <allanjude> | ||||||
Status: | Closed FIXED | ||||||||
Severity: | Affects Many People | CC: | allanjude, emaste, fk, shawn.webb | ||||||
Priority: | --- | ||||||||
Version: | CURRENT | ||||||||
Hardware: | amd64 | ||||||||
OS: | Any | ||||||||
Attachments: |
|
Created attachment 160749 [details]
Updated patch for after r287486 (libxo)
Updated the patch for after r287486.
A commit references this bug: Author: allanjude Date: Sun Sep 6 17:47:04 UTC 2015 New revision: 287509 URL: https://svnweb.freebsd.org/changeset/base/287509 Log: Fix inverted output re: stack protection no-execute flag in procstat(1) PR: 196110 Submitted by: Joerg Pernfuss <code.jpe@gmail.com> Approved by: bapt (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D3576 Changes: head/usr.bin/procstat/procstat_auxv.c Looks like the MFC to stable/10 didn't happen (yet). I seems to require the pre-libxo version of the patch and thus a direct commit anyway. FreeBSD stable/10 will be EoL soon. |
Created attachment 150736 [details] Patch for procstat_auxv.c The ELF auxiliary vector displayed by `procstat -x` contains information about whether or not the stack for that process is executable or not. This information is currently reversed, showing executable when nxstack is enabled. It can be reproduced quite easily: # sysctl kern.elf64.nxstack kern.elf64.nxstack: 1 # procstat -x $$ | grep AT_STACKPROT 1471 csh AT_STACKPROT EXECUTABLE After disabling nxstack, new processes show nonexecutable. # sysctl kern.elf64.nxstack=0 kern.elf64.nxstack: 1 -> 0 # sh -c 'procstat -x $$ | grep AT_STACKPROT' 1477 sh AT_STACKPROT NONEXECUTABLE Looking at the procstat code, the displayed string labels are reversed for the check. The bitwise and will return !0 if the executable bit is set. if ((auxv[i].a_un.a_val & VM_PROT_EXECUTE) != 0) PRINT(AT_STACKPROT, %s, "NONEXECUTABLE"); else PRINT(AT_STACKPROT, %s, "EXECUTABLE"); break; Attached is a simple patch to switch the labels.