summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump/mksubr
Commit message (Collapse)AuthorAgeFilesLines
* Merge an applicable subset of r263234 from HEAD to stable/10:rwatson2015-03-191-3/+3
| | | | | | | | | | | | | Update most userspace consumers of capability.h to use capsicum.h instead. auditdistd is not updated as I will make the change upstream and then do a vendor import sometime in the next week or two. Note that a significant fraction does not apply, as FreeBSD 10 doesn't contain a Capsicumised ping, casperd, libcasper, etc. When these features are merged, the capsicum.h change will need to be merged with them. Sponsored by: Google, Inc.
* MFC 273053:jhb2014-12-161-0/+60
| | | | | Decode the arguments passed to _umtx_op(). In particular, decode the opcode.
* Extend the support for exempting processes from being killed when swap isjhb2013-09-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | exhausted. - Add a new protect(1) command that can be used to set or revoke protection from arbitrary processes. Similar to ktrace it can apply a change to all existing descendants of a process as well as future descendants. - Add a new procctl(2) system call that provides a generic interface for control operations on processes (as opposed to the debugger-specific operations provided by ptrace(2)). procctl(2) uses a combination of idtype_t and an id to identify the set of processes on which to operate similar to wait6(). - Add a PROC_SPROTECT control operation to manage the protection status of a set of processes. MADV_PROTECT still works for backwards compatability. - Add a p_flag2 to struct proc (and a corresponding ki_flag2 to kinfo_proc) the first bit of which is used to track if P_PROTECT should be inherited by new child processes. Reviewed by: kib, jilles (earlier version) Approved by: re (delphij) MFC after: 1 month
* - Decode the idtype argument passed to wait6() in kdump and truss.jhb2013-09-121-1/+63
| | | | | | | | | | - Don't treat an options argument of 0 to wait4() as an error in kdump. - Decode the wait options passed to wait4() and wait6() in truss and decode the returned rusage and exit status. Approved by: re (kib) MFC after: 1 week
* Add a mmap flag (MAP_32BIT) on 64-bit platforms to request that a mapping usejhb2013-09-091-0/+4
| | | | | | | | | | | | | an address in the first 2GB of the process's address space. This flag should have the same semantics as the same flag on Linux. To facilitate this, add a new parameter to vm_map_find() that specifies an optional maximum virtual address. While here, fix several callers of vm_map_find() to use a VMFS_* constant for the findspace argument instead of TRUE and FALSE. Reviewed by: alc Approved by: re (kib)
* Change the cap_rights_t type from uint64_t to a structure that we can extendpjd2013-09-051-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the future in a backward compatible (API and ABI) way. The cap_rights_t represents capability rights. We used to use one bit to represent one right, but we are running out of spare bits. Currently the new structure provides place for 114 rights (so 50 more than the previous cap_rights_t), but it is possible to grow the structure to hold at least 285 rights, although we can make it even larger if 285 rights won't be enough. The structure definition looks like this: struct cap_rights { uint64_t cr_rights[CAP_RIGHTS_VERSION + 2]; }; The initial CAP_RIGHTS_VERSION is 0. The top two bits in the first element of the cr_rights[] array contain total number of elements in the array - 2. This means if those two bits are equal to 0, we have 2 array elements. The top two bits in all remaining array elements should be 0. The next five bits in all array elements contain array index. Only one bit is used and bit position in this five-bits range defines array index. This means there can be at most five array elements in the future. To define new right the CAPRIGHT() macro must be used. The macro takes two arguments - an array index and a bit to set, eg. #define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL) We still support aliases that combine few rights, but the rights have to belong to the same array element, eg: #define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL) #define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL) #define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP) There is new API to manage the new cap_rights_t structure: cap_rights_t *cap_rights_init(cap_rights_t *rights, ...); void cap_rights_set(cap_rights_t *rights, ...); void cap_rights_clear(cap_rights_t *rights, ...); bool cap_rights_is_set(const cap_rights_t *rights, ...); bool cap_rights_is_valid(const cap_rights_t *rights); void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src); void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src); bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little); Capability rights to the cap_rights_init(), cap_rights_set(), cap_rights_clear() and cap_rights_is_set() functions are provided by separating them with commas, eg: cap_rights_t rights; cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT); There is no need to terminate the list of rights, as those functions are actually macros that take care of the termination, eg: #define cap_rights_set(rights, ...) \ __cap_rights_set((rights), __VA_ARGS__, 0ULL) void __cap_rights_set(cap_rights_t *rights, ...); Thanks to using one bit as an array index we can assert in those functions that there are no two rights belonging to different array elements provided together. For example this is illegal and will be detected, because CAP_LOOKUP belongs to element 0 and CAP_PDKILL to element 1: cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL); Providing several rights that belongs to the same array's element this way is correct, but is not advised. It should only be used for aliases definition. This commit also breaks compatibility with some existing Capsicum system calls, but I see no other way to do that. This should be fine as Capsicum is still experimental and this change is not going to 9.x. Sponsored by: The FreeBSD Foundation
* kdump: Decode SOCK_CLOEXEC and SOCK_NONBLOCK in socket() and socketpair().jilles2013-08-261-0/+13
|
* Add new mmap(2) flags to permit applications to request specific virtualjhb2013-08-161-1/+34
| | | | | | | | | | | | | | | | | | | | | | | | | address alignment of mappings. - MAP_ALIGNED(n) requests a mapping aligned on a boundary of (1 << n). Requests for n >= number of bits in a pointer or less than the size of a page fail with EINVAL. This matches the API provided by NetBSD. - MAP_ALIGNED_SUPER is a special case of MAP_ALIGNED. It can be used to optimize the chances of using large pages. By default it will align the mapping on a large page boundary (the system is free to choose any large page size to align to that seems best for the mapping request). However, if the object being mapped is already using large pages, then it will align the virtual mapping to match the existing large pages in the object instead. - Internally, VMFS_ALIGNED_SPACE is now renamed to VMFS_SUPER_SPACE, and VMFS_ALIGNED_SPACE(n) is repurposed for specifying a specific alignment. MAP_ALIGNED(n) maps to using VMFS_ALIGNED_SPACE(n), while MAP_ALIGNED_SUPER maps to VMFS_SUPER_SPACE. - mmap() of a device object now uses VMFS_OPTIMAL_SPACE rather than explicitly using VMFS_SUPER_SPACE. All device objects are forced to use a specific color on creation, so VMFS_OPTIMAL_SPACE is effectively equivalent. Reviewed by: alc MFC after: 1 month
* kdump: Improve decoding of various *at calls:jilles2013-08-131-0/+12
| | | | | * Write AT_FDCWD where appropriate. * Decode the remaining arguments of openat() etc like open() etc.
* Merge Capsicum overhaul:pjd2013-03-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Capability is no longer separate descriptor type. Now every descriptor has set of its own capability rights. - The cap_new(2) system call is left, but it is no longer documented and should not be used in new code. - The new syscall cap_rights_limit(2) should be used instead of cap_new(2), which limits capability rights of the given descriptor without creating a new one. - The cap_getrights(2) syscall is renamed to cap_rights_get(2). - If CAP_IOCTL capability right is present we can further reduce allowed ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed ioctls can be retrived with cap_ioctls_get(2) syscall. - If CAP_FCNTL capability right is present we can further reduce fcntls that can be used with the new cap_fcntls_limit(2) syscall and retrive them with cap_fcntls_get(2). - To support ioctl and fcntl white-listing the filedesc structure was heavly modified. - The audit subsystem, kdump and procstat tools were updated to recognize new syscalls. - Capability rights were revised and eventhough I tried hard to provide backward API and ABI compatibility there are some incompatible changes that are described in detail below: CAP_CREATE old behaviour: - Allow for openat(2)+O_CREAT. - Allow for linkat(2). - Allow for symlinkat(2). CAP_CREATE new behaviour: - Allow for openat(2)+O_CREAT. Added CAP_LINKAT: - Allow for linkat(2). ABI: Reuses CAP_RMDIR bit. - Allow to be target for renameat(2). Added CAP_SYMLINKAT: - Allow for symlinkat(2). Removed CAP_DELETE. Old behaviour: - Allow for unlinkat(2) when removing non-directory object. - Allow to be source for renameat(2). Removed CAP_RMDIR. Old behaviour: - Allow for unlinkat(2) when removing directory. Added CAP_RENAMEAT: - Required for source directory for the renameat(2) syscall. Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR): - Allow for unlinkat(2) on any object. - Required if target of renameat(2) exists and will be removed by this call. Removed CAP_MAPEXEC. CAP_MMAP old behaviour: - Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and PROT_WRITE. CAP_MMAP new behaviour: - Allow for mmap(2)+PROT_NONE. Added CAP_MMAP_R: - Allow for mmap(PROT_READ). Added CAP_MMAP_W: - Allow for mmap(PROT_WRITE). Added CAP_MMAP_X: - Allow for mmap(PROT_EXEC). Added CAP_MMAP_RW: - Allow for mmap(PROT_READ | PROT_WRITE). Added CAP_MMAP_RX: - Allow for mmap(PROT_READ | PROT_EXEC). Added CAP_MMAP_WX: - Allow for mmap(PROT_WRITE | PROT_EXEC). Added CAP_MMAP_RWX: - Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC). Renamed CAP_MKDIR to CAP_MKDIRAT. Renamed CAP_MKFIFO to CAP_MKFIFOAT. Renamed CAP_MKNODE to CAP_MKNODEAT. CAP_READ old behaviour: - Allow pread(2). - Disallow read(2), readv(2) (if there is no CAP_SEEK). CAP_READ new behaviour: - Allow read(2), readv(2). - Disallow pread(2) (CAP_SEEK was also required). CAP_WRITE old behaviour: - Allow pwrite(2). - Disallow write(2), writev(2) (if there is no CAP_SEEK). CAP_WRITE new behaviour: - Allow write(2), writev(2). - Disallow pwrite(2) (CAP_SEEK was also required). Added convinient defines: #define CAP_PREAD (CAP_SEEK | CAP_READ) #define CAP_PWRITE (CAP_SEEK | CAP_WRITE) #define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ) #define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE) #define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL) #define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W) #define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X) #define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X) #define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X) #define CAP_RECV CAP_READ #define CAP_SEND CAP_WRITE #define CAP_SOCK_CLIENT \ (CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \ CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN) #define CAP_SOCK_SERVER \ (CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \ CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \ CAP_SETSOCKOPT | CAP_SHUTDOWN) Added defines for backward API compatibility: #define CAP_MAPEXEC CAP_MMAP_X #define CAP_DELETE CAP_UNLINKAT #define CAP_MKDIR CAP_MKDIRAT #define CAP_RMDIR CAP_UNLINKAT #define CAP_MKFIFO CAP_MKFIFOAT #define CAP_MKNOD CAP_MKNODAT #define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER) Sponsored by: The FreeBSD Foundation Reviewed by: Christoph Mallon <christoph.mallon@gmx.de> Many aspects discussed with: rwatson, benl, jonathan ABI compatibility discussed with: kib
* o Bring in sync decoding the first nfssvc(2) parameter (flags) withpluknet2013-02-121-1/+1
| | | | | | | the current definitions location. o Respect numbers in NFSSVC_* (e.g. NFSSVC_V4ROOTEXPORT). MFC after: 1 week
* kdump: Also decode fcntl commands containing underscores and digits.jilles2012-11-021-1/+1
| | | | | The commands F_SETLK_REMOTE, F_DUPFD_CLOEXEC and F_DUP2FD_CLOEXEC were not decoded.
* kdump: Pretty-print signal codes.jilles2012-09-221-0/+48
| | | | MFC after: 1 week
* Add new ktrace records for the start and end of VM faults. This givesjhb2012-04-051-0/+23
| | | | | | | | | | a pair of records similar to syscall entry and return that a user can use to determine how long page faults take. The new ktrace records are enabled via the 'p' trace type, and are enabled in the default set of trace points. Reviewed by: kib MFC after: 2 weeks
* Pretty-print the advice constants passed to posix_fadvise(2).jhb2012-02-231-0/+1
| | | | MFC after: 2 weeks
* Teach kdump(1) to decode capability bitmasks.des2011-10-081-0/+2
| | | | MFC after: 3 weeks
* I appreciate the logic behind using a (void) cast to indicate that thedes2011-10-081-39/+39
| | | | | | | | return value is intentionally ignored, but frankly, all it does is get in the way of the code. Also fix a few other incorrect casts, such as (void *)malloc(foo) and passing signed values to %x.
* Fix casting.des2011-10-081-12/+12
|
* Sort and line up.des2011-10-081-38/+37
|
* 1) Some of the #defines or enums for which we auto-generate namingdes2011-10-081-21/+25
| | | | | | | | | | | | | functions may be wider than int, so use intmax_t throughout. Also add missing casts in printf() calls. 2) Clean up some of the auto-generated code to improve readability. 3) Auto-generate kdump_subr.h. Note that this requires a semi-ugly hack in the Makefile to make sure it is generated before make(1) tries to build kdump.c, or preprocess it for 'make depend'. MFC after: 3 weeks
* Add 2-clause BSD license.netchild2011-06-171-0/+23
| | | | | | Approved by: David Kirchner <dpk@dpk.net> (initial author) Requested by: Otto Moerbeek <otto@drijf.net> MFC after: 1 week
* Fix regex for ptraceopname().dchagin2011-06-061-1/+1
| | | | | | PR: bin/157663 Submitted by: jason wright <jason@thought.net> MFC after: 10 days
* Decode IPC_CREAT and IPC_EXCL for semget(2).delphij2010-12-021-0/+2
| | | | | | PR: bin/152781 Submitted by: Anton Yuzhaninov <citrin citrin ru> MFC after: 2 weeks
* Fix regex for some socket- and acl-related syscall values.netchild2010-10-061-2/+2
| | | | | | Submitted by: Mikhail <hidden.node@gmail.com> PR: 149295 MFC-after: 2 weeks
* Fix indenting of the previous commit.rpaulo2010-09-161-4/+4
|
* When generating functions to print the arguments of system calls withrpaulo2010-09-161-0/+5
| | | | | | | | | | | | | bitwise parameters (e.g. mmap), print the syscall parameter value first. The resulting output looks like the %b specifier of printf(9). Before: mmap(0,0x8000,PROT_READ|PROT_WRITE,... After: mmap(0,0x8000,0x3<PROT_READ|PROT_WRITE>,... Submitted by: Norberto Lopes <nlopes.ml at gmail.com> Idea from: freebsd-arch/2006-April/005116.html
* - Remove ksethrcmdname.jeff2008-03-121-2/+0
|
* This patch adds a new ktrace(2) record type, KTR_STRUCT, whose payloaddes2008-02-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | consists of the null-terminated name and the contents of any structure you wish to record. A new ktrstruct() function constructs and emits a KTR_STRUCT record. It is accompanied by convenience macros for struct stat and struct sockaddr. In kdump(1), KTR_STRUCT records are handled by a dispatcher function that runs stringent sanity checks on its contents before handing it over to individual decoding funtions for each type of structure. Currently supported structures are struct stat and struct sockaddr for the AF_INET, AF_INET6 and AF_UNIX families; support for AF_APPLETALK and AF_IPX is present but disabled, as I am unable to test it properly. Since 's' was already taken, the letter 't' is used by ktrace(1) to enable KTR_STRUCT trace points, and in kdump(1) to enable their decoding. Derived from patches by Andrew Li <andrew2.li@citi.com>. PR: kern/117836 MFC after: 3 weeks
* These are files are shell scripts; give smart editors a chance to figuredes2008-02-031-4/+6
| | | | | | it out by adding the usual shebang. MFC after: 2 weeks
* Remove static ptrace_ops array and extract ptrace op names fromemaste2007-04-091-0/+2
| | | | sys/ptrace.h with mksubr.
* Add sockipprotoname() function. Decode the third parameter (protocol)rodrigc2007-01-041-0/+2
| | | | | | | | | | | of a socket() call with sockipprotoname() if the first parameter (domain) is PF_INET or PF_INET6. Old parsing behavior before this change: ping6 CALL socket(PF_INET6,SOCK_RAW,0x3a) New behavior after this change: ping6 CALL socket(PF_INET6,SOCK_RAW,IPPROTO_ICMPV6)
* Generate sockdomainname() function with auto_if_type() insteadrodrigc2007-01-041-1/+1
| | | | | | | | | | | of auto_or_type. The old parsing code would incorrectly decode a socket() call in the ping6 program as: CALL socket(PF_PUP|PF_ECMA|PF_APPLETALK|PF_COIP|PF_SIP,SOCK_DGRAM,0) The new parsing code decodes the same socket() call as: CALL socket(PF_INET6,SOCK_DGRAM,0)
* Add auto_if_type() function, which is similar to auto_switch_type().rodrigc2007-01-041-0/+30
| | | | | | | | However, auto_if_type() uses if/else statements in C instead of a single switch statement, when mapping an integer value to a #define. For certain cases where multiple #define constants alias to a single integer value, auto_if_type() makes things easier to parse than auto_switch_type().
* The second argument (type) to socket(2) is an enum, not a bitmask, so parserodrigc2006-12-221-1/+1
| | | | | | | | | | | | | it as an enum. If an SCTP SOCK_SEQPACKET socket was opened, kdump would display this wrong output: socket(PF_INET,SOCK_STREAM|SOCK_RDM|SOCK_SEQPACKET,0x84) instead of this correct output: socket(PF_INET,SOCK_SEQPACKET,0x84) MFC after: 2 weeks
* o optname, the third {set,get}sockopt(2) argument, is an enum, not a bitmap.maxim2006-09-181-1/+1
| | | | | | | Treat it accordingly. PR: bin/101642 MFC after: 3 weeks
* Remove slipped in spaces.kib2006-07-121-3/+3
| | | | | Pointed out by: maxim Approved by: pjd (mentor)
* Check that the signal number is in range.kib2006-07-121-1/+4
| | | | | | Submitted by: Michiel Boland <michiel boland org> MFC after: 1 week Approved by: pjd (mentor)
* Change kdump to print more useful information, i.e. it changes fromnetchild2006-05-201-0/+407
32229 telnet CALL mmap(0,0x8000,0x3,0x1002,0xffffffff,0,0,0) 32229 telnet CALL open(0x2807bc28,0,0x1b6) 32229 telnet CALL socket(0x2,0x2,0) to 32229 telnet CALL mmap(0,0x8000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,0xffffffff,0,0,0) 32229 telnet CALL open(0x2807bc28,O_RDONLY,<unused>0x1b6) 32229 telnet CALL socket(PF_INET,SOCK_DGRAM,0) David wanted to implement the suggestions which came up at the review from arch@ too, but real life rejected this proposal. So I commit what we already got and let another volunteer pick the remaining work from the ideas list. Submitted by: "David Kirchner" <dpk@dpk.net> Suggested by: FreeBSD ideas list page Reviewed by: arch
OpenPOWER on IntegriCloud