Commit Graph

93 Commits

Author SHA1 Message Date
jmc ba0173419e add some missing flags, as pointed out by deraadt; while
here rework the text so it reads a little better;

ok deraadt
2022-10-22 06:39:12 +00:00
deraadt e45a0bdddd Show the entry immutable bit in the various output formats. 2022-10-07 15:22:10 +00:00
deraadt 4ec73a1227 MAXCOMLEN is no longer needed in these programs, so remove the annotation
from sys/param.h include lines, or remove the include lines entirely if
it this was the least requirement.
ok millert
2022-02-22 17:35:01 +00:00
deraadt 3736a0a00a sys/proc.h requires sys/signal.h (will become visible when sys/param.h
is removed)
2022-02-20 00:09:29 +00:00
deraadt 8993664688 correct order of region bits for -a case: rwxSepc 2019-11-29 19:56:40 +00:00
deraadt e50417250f Repurpose the "syscalls must be on a writeable page" mechanism to
enforce a new policy: system calls must be in pre-registered regions.
We have discussed more strict checks than this, but none satisfy the
cost/benefit based upon our understanding of attack methods, anyways
let's see what the next iteration looks like.

This is intended to harden (translation: attackers must put extra
effort into attacking) against a mixture of W^X failures and JIT bugs
which allow syscall misinterpretation, especially in environments with
polymorphic-instruction/variable-sized instructions.  It fits in a bit
with libc/libcrypto/ld.so random relink on boot and no-restart-at-crash
behaviour, particularily for remote problems. Less effective once on-host
since someone the libraries can be read.

For static-executables the kernel registers the main program's
PIE-mapped exec section valid, as well as the randomly-placed sigtramp
page.  For dynamic executables ELF ld.so's exec segment is also
labelled valid; ld.so then has enough information to register libc's
exec section as valid via call-once msyscall(2)

For dynamic binaries, we continue to to permit the main program exec
segment because "go" (and potentially a few other applications) have
embedded system calls in the main program.  Hopefully at least go gets
fixed soon.

We declare the concept of embedded syscalls a bad idea for numerous
reasons, as we notice the ecosystem has many of
static-syscall-in-base-binary which are dynamically linked against
libraries which in turn use libc, which contains another set of
syscall stubs.  We've been concerned about adding even one additional
syscall entry point... but go's approach tends to double the entry-point
attack surface.

This was started at a nano-hackathon in Bob Beck's basement 2 weeks
ago during a long discussion with mortimer trying to hide from the SSL
scream-conversations, and finished in more comfortable circumstances
next to a wood-stove at Elk Lakes cabin with UVM scream-conversations.

ok guenther kettenis mortimer, lots of feedback from others
conversations about go with jsing tb sthen
2019-11-29 06:34:44 +00:00
deraadt 7aa9f692dc dev_t is signed to permit passing -1 as an invalid condition, but the
decomposition into major and minor is unsigned, so we should print them
with %u instead of %d.
ok guenther
2019-02-05 02:17:32 +00:00
otto e10be9fc02 Fix description of -v and implement -v for -a showing holes; ok deraadt@ 2018-03-31 17:26:13 +00:00
dlg f933361f20 port the RBT code to userland by making it part of libc.
src/lib/libc/gen/tree.c is a copy of src/sys/kern/subr_tree.c, but with
annotations for symbol visibility. changes to one should be reflected
in the other.

the malloc debug code that uses RB code is ported to RBT.

because libc provides the RBT code, procmap doesn't have to reach into
the kernel and build subr_tree.c itself now.

mild enthusiasm from many
ok guenther@
2017-06-19 03:06:26 +00:00
deraadt 19aedf2361 Make a move towards ending 4 decades of kernel snooping.
Add sysctl kern.allowkmem (default 0) which controls the ability to open
/dev/mem or /dev/kmem at securelevel > 0.  Over 15 years we converted 99%
of utilities in the tree to operate on sysctl-nodes (either by themselves
or via code hiding in the guts of -lkvm).

pstat -d and -v & procmap are affected and continued use of them will
require kern.allowkmem=1 in /etc/sysctl.conf.  acpidump (and it's
buddy sendbug) are affected, but we'll work out a solution soon.

There will be some impact in ports.

ok kettenis guenther
2016-09-25 15:23:36 +00:00
dlg 17f2de0ac6 procmap fumbles with uvm_map_addr structures, which are now in RBTs
it also does proper traversal of the tree (ie, it does FOREACH)
which in turn uses MIN and NEXT operations to iterate over the whole
tree. theyre complicated and need code.

so for now this pulls in subr_tree.c from the kernel and builds it
as part of procmap. that allows for traversal of the RBT using the
same code that the kernel uses.

it is a bit ugly though because procmap updates the pointers between
items in the tree so they point at local copies instead of kernel
addresses. its made worse because RBT code has pointers between
rb_entry structs, not between the nodes.

im putting this in now to unbreak the tree. it can be polished after
coffee/naps.
2016-09-16 04:45:35 +00:00
stefan 2f639c72a4 Re-introduce vnode-to-filename mapping
The name cache walking code got adapted to the new name cache layout.
Along with the previous commit, procmap is now able to map a vnode
to a filename as long as it is in the name cache.

"nice stuff" deraadt@
2016-05-26 17:23:49 +00:00
stefan 24d8c97678 Must extract uvm_vnode from uvm_object first before reading the vnode
Otherwise procmap interprets the uvm_vnode contents as a vnode,
yielding bogus values. This should cure the
"procmap: invalid address (ffffffffffffffff) == -1 vs. 656 @ ffffffffffffffff"
error messages that appear sporadically.

ok deraadt@
2016-05-25 15:45:53 +00:00
stefan d87a780302 Remove am_maxslot from amap.
am_maxslot represents the total number of slots an amap can be extended
to. Since we do not extend amaps, this field as well as rounding the
number of slots to the next malloc bucket is not useful.

This also removes the corresponding output from procmap(1).

ok kettenis@
2016-04-16 18:39:30 +00:00
jmc 0870f47d28 remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;
2015-03-13 19:58:40 +00:00
kettenis 126e54ad4d Also print the fspace member of map entries when PRINT_VM_MAP_ENTRY is
requested.

ok deraadt@
2015-01-19 19:25:28 +00:00
deraadt b9fc9a728f Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)
2015-01-16 06:39:28 +00:00
deraadt 1e8cdc2e59 Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis
2014-11-16 12:30:52 +00:00
doug 00f00f3013 Additional cleanup for procfs removal
ok guenther@
2014-09-08 04:40:30 +00:00
guenther cf6677a65b Delete procfs; it's always had races and is now unused: no one noticed for
months that I broke it before the 5.5 release.

confirmed as not being required by ports by sthen@, ajacoutot@, dcoppa@
2014-09-08 01:47:05 +00:00
deraadt e6c6495d62 decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis
2014-07-08 17:19:21 +00:00
deraadt d543b64550 There really isn't a strict "heap" anymore, so just call everything like
that an anon.  Useful change since BRKSIZ will soon leave the namespace.
ok kettenis
2014-07-08 10:15:16 +00:00
guenther 5ad04d3516 Use errc/warnc to simplify code.
Also, in 'ftp', always put the error message last, after the hostname/ipaddr.

ok jsing@ krw@ millert@
2014-05-20 01:25:23 +00:00
tedu 291c1a78cf remove tendrils of namei dumping code 2014-02-13 21:17:13 +00:00
tedu a362fec478 use strtonum 2014-02-13 21:07:42 +00:00
schwarze 369bef3a14 obvious .Pa fixes; found with mandocdb(8) 2014-01-21 03:15:44 +00:00
otto e76eb0cbd5 get ready for big ino_t; ok gunther@ 2013-08-12 05:41:01 +00:00
schwarze 44e68d472b use .Mt for email addresses; from Jan Stary <hans at stare dot cz>; ok jmc@ 2013-07-16 11:13:33 +00:00
dcoppa 63d456997f Since the "better kmem pointer hiding" commit, procmap does not work
anymore for regular users.
So remove the setgid kmem for the time being (until tedu@ fixes it).

ok tedu@
2013-06-25 15:11:58 +00:00
miod dd728bb232 Don't bother printing vm_swrss of a process, the current uvm accounting
logic never sets this value.
2013-05-14 20:18:52 +00:00
deraadt 66f21f2987 pretty-print bigger ino_t variables 2013-04-24 14:29:00 +00:00
tedu 66fdeb0918 revert 1.45. it depended on a kernel change we will not be making, and
the old code was cleaner
2013-04-21 00:40:08 +00:00
tedu 16db1b702e for the sake of argument, let's pretend this #if 0 code isn't wanted 2013-03-26 08:58:00 +00:00
tedu c38420897f rework the main loop so we can drop kmem privs a little later,
prepping for a coming kernel change. we need to call sysctl for
all the procs to get their vmspace pointer, then we drop, then
we go grovelling. ok deraadt
2013-03-23 10:46:04 +00:00
tedu 42db40a40a revert, that restriction is already enforced the right way 2013-03-20 15:24:17 +00:00
deraadt 49f570061b Only root can look at the kernel address space. 2013-03-20 14:53:35 +00:00
deraadt e4a14e780f document a safe cast, which should be (unsigned int) instead of simply
(unsigned)
2013-01-16 00:13:23 +00:00
ariane aecbb8ab18 Userspace counterpart of new vmmap.
Allows memory walks to function.
2012-03-09 13:02:45 +00:00
jmc e324319b8a make -column lists pretty again;
specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.
2011-09-03 22:59:07 +00:00
ariane d3e280a1cb Userland counterpart of the vmmap backout; cranks major version of libkvm. 2011-06-06 17:18:26 +00:00
ariane 4e3da9ea5c Reimplement uvm/uvm_map.
vmmap is designed to perform address space randomized allocations,
without letting fragmentation of the address space go through the roof.

Some highlights:
- kernel address space randomization
- proper implementation of guardpages
- roughly 10% system time reduction during kernel build

Tested by alot of people on tech@ and developers.
Theo's machines are still happy.
2011-05-24 15:27:36 +00:00
tedu 2f0339a462 BRKSIZ is the right constant now, so I don't get lots of teeny tiny heaps
mixed up in my address space.
2011-04-23 01:01:34 +00:00
guenther 5027561d80 Switch back from KERN_PROC2/kinfo_proc2 to KERN_PROC/kinfo_proc now
that we've got name we want for the API we want

"ZAP!" deraadt@
2011-04-10 03:20:58 +00:00
miod 691235adb9 Avoid using NULL in non-pointer contexts: use 0 for integer values and '\0'
for chars.
2011-04-06 11:36:23 +00:00
thib 397daf5dc4 Remove portalfs.
While it is a terribly cool idea, it's just awful and since noone has stepped
up to the plate to keep it up with the current vop state, retire it to the
attic.

ok krw@, deraadt@, guenther@, miod@.
comments from jmc@
2011-04-05 18:51:25 +00:00
jmc 741b6f30d7 add an EXIT STATUS section for /usr/sbin; 2010-09-03 11:22:36 +00:00
miod 22dcaf1b32 Update nlist array and uncomment a few things to pave the way for upcoming
new name cache information gathering code.
2009-08-12 20:13:12 +00:00
beck d1b478c6b4 Namecache revamp.
This eliminates the large single namecache hash table, and implements
the name cache as a global lru of entires, and a redblack tree in each
vnode. It makes cache_purge actually purge the namecache entries associated
with a vnode when a vnode is recycled (very important for later on actually being
able to resize the vnode pool)

This commit does #if 0 out a bunch of procmap code that was
already broken before this change, but needs to be redone completely.

Tested by many, including in thib's nfs test setup.

ok oga@,art@,thib@,miod@
2009-08-12 16:42:24 +00:00
miod af25effb59 No longer consider kernel pointers invalid if pointing under the kernel
load address (hello, PMAP_DIRECT architectures). Makes procmap walk the
kernel name cache correctly.
ok art@
2009-06-04 22:38:53 +00:00
sobrado e4281b20e6 replace standardized text concerning the exit values of applications
with the right mdoc macros.
2009-01-19 09:46:59 +00:00