aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
Commit message (Collapse)AuthorAgeFilesLines
* Use if ... else when printing memory attributesAndrew Turner2021-06-121-36/+18
| | | | | | | | | | | | | | | | In vmstat there is a switch statement that converts these attributes to a string. As some values can be duplicate we have to hide these from userspace. Replace this switch statement with an if ... else macro that lets us repeat values without a compiler error. Reviewed by: kib MFC after: 2 weeks Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D29703 (cherry picked from commit 15221c552b3cabcbf26613246e855010b176805a)
* mendMichael Tuexen2021-06-073-7/+16
|
* elfctl: avoid touching file if no change madeEd Maste2021-06-021-1/+5
| | | | | | | | | | Suggested by: brooks Reviewed by: brooks, markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30452 (cherry picked from commit 3f2508b7f3855102abed99b846e30e728ba3d04d)
* sort: Hook NetBSD tests up to the buildMark Johnston2021-05-201-2/+2
| | | | | | Sponsored by: The FreeBSD Foundation (cherry picked from commit 186ba88a7c1f2bea14eb3fb092671e8367f7187f)
* sort: Cache value of MB_CUR_MAXCyril Zhang2021-05-205-34/+45
| | | | | | | | | | | | | | | Every usage of MB_CUR_MAX results in a call to __mb_cur_max. This is inefficient and redundant. Caching the value of MB_CUR_MAX in a global variable removes these calls and speeds up the runtime of sort. For numeric sorting, runtime is almost halved in some tests. PR: 255551 PR: 255840 Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30170 (cherry picked from commit 71ec05a21257e159f40d54e26ad0011bb19b5134)
* sort: Stop "fixing" obsolete key syntax after -- flagCyril Zhang2021-05-201-0/+5
| | | | | | | | | PR: 255798 Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30234 (cherry picked from commit fa43162c63790806d0effba5ac98a1a3c6b835e1)
* truss: Decode FreeBSD 11 mknod(2) and mknodat(2)Mark Johnston2021-05-191-2/+6
| | | | | | Sponsored by: The FreeBSD Foundation (cherry picked from commit cd497bd40bb65b5e4603d57614eb15ca7d947a10)
* Clean up copyright messages.Kirk McKusick2021-05-172-10/+8
| | | | (cherry picked from commit 9e16b9530aab5e1c4efee2a8fe2feaf33340c764)
* find(1): Document the -f optionCeri Davies2021-05-161-1/+14
| | | | | | | | | PR: 223127 Reported by: Mathieu Arnold <mat at FreeBSD dot org> Reviewed by: bcr, gbe Differential Revision: https://reviews.freebsd.org/D30215 (cherry picked from commit 82483ea7adfe4213059f6dacf31f3bd1327b2cc0)
* usr.bin/patch: remove unneeded header.Xin LI2021-05-161-1/+0
| | | | (cherry picked from commit 9769f6f808210ddc304bc9e3c55121e6ce4d9075)
* usr.bin/netstat: use roundup2 when rounding up to power of 2.Xin LI2021-05-162-3/+3
| | | | (cherry picked from commit f6b6d216cafb154a85313a2d1bd34b18b9bfbba8)
* truss: Add missing underscore to compat_prefix for FreeBSD32Alex Richardson2021-05-111-1/+1
| | | | | | | | | | I accidentally dropped this in the final version of D27625, so it didn't actually work as intended. I found this while testing the MFC to stable/13. MFC after: immediately Fixes: 7daca4e2043f ("truss: improved support for decoding compat32 arguments") (cherry picked from commit 3cbad8287aa0ed72e07df1130ce2ae490642e63a)
* usr.bin/lex: regenerate bootstrap files after d37f81e35bAlex Richardson2021-05-112-18/+6
| | | | | | Reviewed by: jkim (cherry picked from commit c6e66cbfbbd1c5dec215cf91a79689037255171c)
* truss: improved support for decoding compat32 argumentsAlex Richardson2021-05-113-45/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently running `truss -a -e` does not decode any argument values for freebsd32_* syscalls (open/readlink/etc.) This change checks whether a syscall starts with freebsd{32,64}_ and if so strips that prefix when looking up the syscall information. To ensure that the truss logs include the real syscall name we create a copy of the syscall information struct with the updated. The other problem is that when reading string array values, truss naively iterates over an array of char* and fetches the pointer value. This will result in arguments not being loaded if the pointer is not aligned to sizeof(void*), which can happens in the compat32 case. If it happens to be aligned, we would end up printing every other value. To fix this problem, this changes adds a pointer_size member to the procabi struct and uses that to correctly read indirect arguments as 64/32 bit addresses in the the compat32 case (and also compat64 on CheriBSD). The motivating use-case for this change is using truss for 64-bit programs on a CHERI system, but most of the diff also applies to 32-bit compat on a 64-bit system, so I'm upstreaming this instead of keeping it as a local CheriBSD patch. Output of `truss -aef ldd32 /usr/bin/ldd32` before: 39113: freebsd32_mmap(0x0,0x1000,0x3,0x1002,0xffffffff,0x0,0x0) = 543440896 (0x20644000) 39113: freebsd32_ioctl(0x1,0x402c7413,0xffffd2a0) = 0 (0x0) /usr/bin/ldd32: 39113: write(1,"/usr/bin/ldd32:\n",16) = 16 (0x10) 39113: fork() = 39114 (0x98ca) 39114: <new process> 39114: freebsd32_execve(0xffffd97e,0xffffd680,0x20634000) EJUSTRETURN 39114: freebsd32_mmap(0x0,0x20000,0x3,0x1002,0xffffffff,0x0,0x0) = 541237248 (0x2042a000) 39114: freebsd32_mprotect(0x20427000,0x1000,0x1) = 0 (0x0) 39114: issetugid() = 0 (0x0) 39114: openat(AT_FDCWD,"/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory' 39114: openat(AT_FDCWD,"/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3) 39114: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0#\0\0\0\0"...,128) = 128 (0x80) 39114: freebsd32_fstat(0x3,0xffffbd98) = 0 (0x0) 39114: freebsd32_pread(0x3,0x2042f000,0x23,0x80,0x0) = 35 (0x23) 39114: close(3) = 0 (0x0) 39114: openat(AT_FDCWD,"/usr/lib32/libc.so.7",O_RDONLY|O_CLOEXEC|O_VERIFY,00) = 3 (0x3) 39114: freebsd32_fstat(0x3,0xffffc7d0) = 0 (0x0) 39114: freebsd32_mmap(0x0,0x1000,0x1,0x40002,0x3,0x0,0x0) = 541368320 (0x2044a000) After: 783: freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 543543296 (0x2065d000) 783: freebsd32_ioctl(1,TIOCGETA,0xffffd7b0) = 0 (0x0) /usr/bin/ldd32: 783: write(1,"/usr/bin/ldd32:\n",16) = 16 (0x10) 784: <new process> 783: fork() = 784 (0x310) 784: freebsd32_execve("/usr/bin/ldd32",[ "(null)" ],[ "LD_32_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_32_TRACE_LOADED_OBJECTS=yes", "LD_TRACE_LOADED_OBJECTS=yes", "USER=root", "LOGNAME=root", "HOME=/root", "SHELL=/bin/csh", "BLOCKSIZE=K", "MAIL=/var/mail/root", "MM_CHARSET=UTF-8", "LANG=C.UTF-8", "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin", "TERM=vt100", "HOSTTYPE=FreeBSD", "VENDOR=amd", "OSTYPE=FreeBSD", "MACHTYPE=x86_64", "SHLVL=1", "PWD=/root", "GROUP=wheel", "HOST=freebsd-amd64", "EDITOR=vi", "PAGER=less" ]) EJUSTRETURN 784: freebsd32_mmap(0x0,135168,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 541212672 (0x20424000) 784: freebsd32_mprotect(0x20421000,4096,PROT_READ) = 0 (0x0) 784: issetugid() = 0 (0x0) 784: sigfastblock(0x1,0x204234fc) = 0 (0x0) 784: open("/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory' 784: open("/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3) 784: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0\v\0\0\0"...,128) = 128 (0x80) 784: freebsd32_fstat(3,{ mode=-r--r--r-- ,inode=18680,size=32768,blksize=0 }) = 0 (0x0) 784: freebsd32_pread(3,"/usr/lib32\0",11,0x80) = 11 (0xb) Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D27625 (cherry picked from commit 7daca4e2043fa8d88658eb8c2fc195128cb5c3da)
* truss: split counting of syscalls and syscall calling conventionAlex Richardson2021-05-114-63/+67
| | | | | | | | | | | | | | | | This change is a refactoring cleanup to improve support for compat32 syscalls (and compat64 on CHERI systems). Each process ABI now has it's own struct sycall instead of using one global list. The list of all syscalls is replaced with a list of seen syscalls. Looking up the syscall argument passing convention now interates over the fixed-size array instead of using a link-list that's populated on startup so we no longer need the init_syscall() function. The actual functional changes are in D27625. Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D27636 (cherry picked from commit 6019514b0b53c3fc151868b88357405b6d67f308)
* gcore: add option to dump core using kernel facilityKonstantin Belousov2021-05-102-11/+80
| | | | (cherry picked from commit 73e8f06ac523ee4b530e17d50cc580dc366f7ad8)
* gcore: split code to open core file into helperKonstantin Belousov2021-05-101-8/+17
| | | | (cherry picked from commit c192228b7398df72e472128605338555e5aa2db9)
* less: upgrade to v581.2.Xin LI2021-05-091-1/+12
| | | | | | | | (cherry picked from commit 50d31dbc6e2bc3aa6007edb8cdecbcb84e85d6c0) less: upgrade to v581. (cherry picked from commit 2235c7feac959bcc9ddfd6a2bc6be32102b1f84c)
* diff: eleminitate useless macrosBaptiste Daroussin2021-05-051-57/+56
| | | | | | | The diff_output was not bringing any values but was obfuscating the code. (cherry picked from commit 7a57c9cb5a4dffb0483beeae6da7cf266ea634be)
* diff: simplify the hash functionsBaptiste Daroussin2021-05-051-50/+27
| | | | | | | Instead of 3 different complex case they have all been folded into a simple on based on switch (cherry picked from commit e43239f5140e1b80de122458a2ac037172866058)
* diff: fix typo in a commentBaptiste Daroussin2021-05-051-1/+1
| | | | (cherry picked from commit e52546a3a75f6e4b327178f4d50a98dd99101c64)
* diff: remove stalled entries in headersBaptiste Daroussin2021-05-051-3/+0
| | | | (cherry picked from commit 931ad51808a650fd28be27210f25ba05d8e71199)
* diff: eliminate space at end of lineBaptiste Daroussin2021-05-051-33/+33
| | | | | | No functionnal changes (cherry picked from commit 15abb23286541c17ff95bac056cd4979822c4288)
* diff: add a test case about the non regular file supportBaptiste Daroussin2021-05-051-0/+15
| | | | (cherry picked from commit c440e7870a020546ad241848e2ff8e9cb27a3073)
* Fix zgrep --versionMateusz Piotrowski2021-04-261-3/+3
| | | | | | | | | | | | | | | "zgrep --version" is expected to print the version information in the same way as "zgrep -V". However, the case handling the --version flag is never reached, so "zgrep --version" prints: zgrep: missing pattern instead of: grep (BSD grep, GNU compatible) 2.6.0-FreeBSD Reviewed by: yuripv Approved by: yuripv (src) Differential Revision: https://reviews.freebsd.org/D29813 (cherry picked from commit 16e0391f8e2124eb85af984204548cf841648db5)
* flex: Regen bootstrap filesJung-uk Kim2021-04-234-14/+18
| | | | | | | | | | This also partially reverts r326025 (8a16b7a18f5d). I do not see any point of adding SPDX tag in generated file. Submitted by: Dan McGregor <dan.mcgregor@usask.ca> (initial version) Differential Revision: https://reviews.freebsd.org/D28596 (cherry picked from commit 686cf5468c4a85c2a6385cdbab2383900876a41d)
* du_test: Skip three tests if sparse files are not supportedAlex Richardson2021-04-221-0/+14
| | | | | | | | | | | This fixes running the du tests with /tmp as tmpfs (which is what we do in the CheriBSD CI). Obtained from: CheriBSD Reviewed By: ngie Differential Revision: https://reviews.freebsd.org/D28398 (cherry picked from commit 39a1f858ad735ef816a9b1fb7eeade2c6802eb98)
* Improve size readability.Michael Reifenberger2021-04-213-89/+49
| | | | | | | | | | | | | Preserve more space for swap devise names. Prevent line overflow with long devise name. Don't draw a bar when swap is not used at all. Simplify and optimize code. Change the label to end at end of 100%. PR: 251655 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27496 (cherry picked from commit 8d06c3e7a40831ac139d83b85b282206229b426f)
* systat.1: Remove Tn macrosMateusz Piotrowski2021-04-171-41/+14
| | | | | | | | They are no longer supported by mdoc(7). MFC after: 1 week (cherry picked from commit fcbaf46b763a91bb41fe68afdcf59a7d210bc2f7)
* systat.1: Fix synopsisMateusz Piotrowski2021-04-171-1/+1
| | | | | | | systat does not have a "-display" flag. Use Ar to indicate that "display" is meant to be substituted with an actual display command. (cherry picked from commit e6f59be239aa17f80b44ded4779e29f5d5352b28)
* Add GPT PREP-boot type to mkimg(1) from geom_gpt.Nathan Whitehorn2021-04-151-0/+2
| | | | | | | | This partition type can be used to boot some PowerKVM VMs. We don't support it well because of some limitations in SLOF, but it's worth at least have feature parity in geom and mkimg. (cherry picked from commit f7aebfbe5c0ab63dbb3d134d143ccff2c2b278bb)
* m4(1): Add a SEE ALSO section and reference an AT&T manualGordon Bergling2021-04-151-1/+12
| | | | | | Obtained from: OpenBSD (cherry picked from commit 97fa288a663dfae192c471ec5cbfdf0d2f45367e)
* sed(1): Add a reference for a 4.4BSD manual documentGordon Bergling2021-04-151-1/+10
| | | | | | Obtained from: OpenBSD (cherry picked from commit 9048d9a933f57991ee042618ab89dd49d8cbad89)
* [bc] Update to version 4.0.0Stefan Eßer2021-04-101-2/+0
| | | | | | | | | | | | | | | This version fixes an issue (missing pop of top-of-stack value in the "P" command of the dc program). This issue did not affect the bc program, since it does not use dc as an back-end to actually perform the calculations as was the case with the traditional bc and dc programs. The major number has been bumped due to Windows support that has been added to this version. It does not correspond to a major change that might affect FreeBSD. (cherry picked from commit b55a927bc884d7780d65a508572023b0dc2dede9)
* Fix `netstat -rs` reporting.Alexander V. Chernikov2021-04-042-13/+1
| | | | | | | | | | rttrash (unused but not yet delete entries) were eliminated during routing rework. Remove reading these symbols from the kernel. PR: 254681 Reported by: rashey@superbox.pl (cherry picked from commit 4084b1ab0413d15dab496b1c24c3875601c71438)
* Fix warning about signed comparison and drop WARNS for ktrdump(8).Dmitry Chagin2021-04-012-9/+7
| | | | | | | Reviewed By: jhb, imp Differential Revision: https://reviews.freebsd.org/D29381 (cherry picked from commit 9e5aeba51b431256adfd18b087ee61b09bfd6a79)
* fortune: add a tip about gstatAlan Somers2021-03-211-0/+6
| | | | (cherry picked from commit 60a632f047cdb6e5314711f593a4d3b1f1d8dde9)
* find(1): Refine the HISTORY within the manual page.Gordon Bergling2021-03-201-3/+10
| | | | | | | | | | | | A simple find command appeared in Version 1 AT&T UNIX and was removed in Version 3 AT&T UNIX. It was rewritten for Version 5 AT&T UNIX and later be enhanced for the Programmer's Workbench (PWB). These changes were later incorporated in AT&T UNIX v7. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D29114 (cherry picked from commit a9275d996c229a30879baa42a6d02d24663ac43b)
* find(1): Mark -not as an extensions to POSIXDaniel Ebdrup Jensen2021-03-201-3/+3
| | | | | | | | | While here, change mdoc macro from Ic to Fl. PR: 253499 Reported by: Michael Siegel <bugcounterism at malbolge.net> (cherry picked from commit 75e6f664c469927ca73ecd7b16a8058bc292a451)
* tail: fix "tail -F" file rotation detectionChuck Silvers2021-03-181-1/+1
| | | | | | | | | | When checking if the newly opened file is the same as the old one, we need to fstat() the new file descriptor, not the old one again. Reviewed by: glebius Sponsored by: Netflix (cherry picked from commit 7787e7eed9d2a43fb6eb66666040f1b495995a2f)
* backlight(8): Add note that with option it print the current brightness.Emmanuel Vadot2021-03-101-1/+4
| | | | | | | MFC after: 3 days PR: 253737 (cherry picked from commit 1df30489a8f7083c98010c94d9ce522f9e8213dc)
* backlight: Fix incr/decr with percent value of 0David Schlachter2021-03-101-2/+7
| | | | | | | | | This now does nothing instead of incr/decr by 10% MFC After: 3 days PR: 253736 (cherry picked from commit 3b005d51bd0fe4d8d19fb2df4d470b6e8baebf16)
* service(8): use an environment more consistent with init(8)Andrew Gierth2021-03-072-10/+22
| | | | | | | | | | | | | | | | | | init(8) sets the "daemon" login class without specifying a pw entry (so no substitutions are done on the variables). service(8)'s use of env -L had the effect of specifying root's pw entry, with two effects: getpwnam and getpwuid are being called, which may not be entirely safe depending on what nsswitch is up to and what stage of boot we are at, and substitutions would have been done. Fix by teaching env(8) to allow -L -/classname to set the class environment with no pw entry at all specified, and use it in service(8). PR: 253959 (cherry picked from commit 55deb0a5f089c8a27cfc1666655b93881c2b47ae) (cherry picked from commit 0c1a5eaae83267365330437adb60f44e1a622a2b)
* mkimg: Add support for offset if the source is an imageEmmanuel Vadot2021-03-021-8/+11
| | | | | | | | | | | | This allow us to create image with the following format: mkimg -v -o sdcard -s gpt -p efi:=esp_aarch64.img:1M -p freebsd-ufs::1G Which will add a efi partition at a 1M offset on the image with its content coming from the esp_aarch64.img file. MFC after: 3 days (cherry picked from commit 8f3c71c85e5f6a4d2bddbfead225d33b96dbd7d7)
* mkimg: We always want the last block of the last inserted partitionEmmanuel Vadot2021-03-021-4/+2
| | | | | | | | | | | | | | Even with an absolute offset we want to know the last block the partition otherwise we endup with an image the size of the metadata. This allow to create image with the ESP placed at a specific position which is useful on arm/arm64 where u-boot have always a hard time to read the ESP if it's not aligned on 512k. mkimg -v -o sdcard -s gpt -p efi::54M:1M -p freebsd-ufs::1G now works. MFC after: 3 days (cherry picked from commit 3b6268bb9e4aea939c4ce7f37353174aa90e6751)
* procstat: distinguish vm map guards in procstat vm output.Konstantin Belousov2021-02-212-1/+7
| | | | (cherry picked from commit 25c6318c7906f6f4e0c66ce16f81bdb830ba2e3b)
* truss: Decode sendfile(2) argumentsMark Johnston2021-02-192-0/+24
| | | | (cherry picked from commit 90da2c797bfa7639005ed46ab9173feb8bd85ecd)
* lastcomm(1): Only install if MK_ACCT is onEmmanuel Vadot2021-02-191-1/+1
| | | | | | MFC after: 3 days (cherry picked from commit 8af54bdfcaecf922f936a14d1d9efcf84076029f)
* Update Subversion to 1.14.1 LTS. See contrib/subversion/CHANGES for aDimitry Andric2021-02-182-2/+3
| | | | | | | | | | | | | | | | | summary of changes, or for a more thorough overview: https://subversion.apache.org/docs/release-notes/1.14 NOTE 1: There is no need to dump and reload repositories, and the working copy format is still the same as Subversion 1.8 through 1.13. NOTE 2: The upstream release also contains a fix for a security issue in mod_dav_svn (CVE-2020-17525), but since we do not build or use any Apache modules, it is not an issue for the FreeBSD base system. Relnotes: yes (cherry-picked from 0ff1014944897f4f3ffa4462406cdee920b53400)
* usr.bin/grep: Fix Address OOB read errorAlex Richardson2021-02-162-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | I found this when compiling all the bootstrap tools with -fsanitize=addres: ==65590==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62d000008400 at pc 0x000000473053 bp 0x7ffc1c7dd910 sp 0x7ffc1c7dd0b8 READ of size 32769 at 0x62d000008400 thread T0 #0 0x473052 in regexec (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052) #1 0x4c9cf3 in procline /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:539:8 #2 0x4c8687 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:379:18 #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8 0x62d000008400 is located 0 bytes to the right of 32768-byte region [0x62d000000400,0x62d000008400) allocated by thread T0 here: #0 0x493d5d in malloc (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x493d5d) #1 0x4cad75 in grep_malloc /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:656:13 #2 0x4c8129 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8 SUMMARY: AddressSanitizer: heap-buffer-overflow (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052) in regexec Reviewed By: kevans MFC after: 1 week (cherry picked from commit 81c3f64110bb76e24d6062eafd7206c10f676d6f)