Commit Graph

14067 Commits

Author SHA1 Message Date
Andriy Voskoboinyk
d614ded66a lockf(1): return EX_UNAVAILABLE if -n is used and the lock file does not
exist

Apply EX_UNAVAILABLE patch part from PR 170775 to match the documentation.

Checked with a command from PR 210770:
lockf -n /tmp/doesnotexist echo; echo $?

PR:		210770
MFC after:	1 week
2019-03-20 07:40:38 +00:00
Greg Lehey
1f0493ec0f Change date of Canberra Day, now on second Monday in March.
https://en.wikipedia.org/wiki/Canberra_Day
2019-03-17 22:26:50 +00:00
Konstantin Belousov
bab3f1d04a proccontrol(1): Add kpti control mode.
Requested by:	jhb
Reviewed by:	jhb, markj (previous version)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D19514
2019-03-16 11:46:48 +00:00
Konstantin Belousov
504748bc88 Some fixes for proccontrol(1) man page.
- Fix markup.
- Mention that process can only allow tracing for itself.  This is already
  stated in procctl(2), but requiring knowledge of the syscall description
  is too much for the tool user.
- Clearly state that query mode only works for existing process.

Noted and reviewed by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2019-03-13 17:30:03 +00:00
Alan Somers
809a8352dd Drop "All rights reserved" from the files I own
Also, add SPDX tags where needed.

MFC after:	2 weeks
2019-03-11 22:23:56 +00:00
Marcel Moolenaar
370d612f5e Don't compress and uuencode the "hexdump -C" output files. Just
save them with the $FreeBSD$ tag prepended.  Changes to these
files are now a lot easier to comprehend, which makes diffs also
reviewable.
2019-03-09 02:03:07 +00:00
Bjoern A. Zeeb
b25d74e06c Improve ARP logging.
r344504 added an extra ARP_LOG() call in case of an if_output() failure.
It turns out IPv4 can be noisy. In order to not spam the console by default:
(a) add a counter for these events so people can keep better track of how
    often it happens, and
(b) add a sysctl to select the default ARP_LOG log level and set it to
    INFO avoiding the one (the new) DEBUG level by default.

Claim a spare (1st one after 10 years since the stats were added) in order
to not break netstat from FreeBSD 12->13 updates in the future.

Reviewed by:		karels
Differential Revision:	https://reviews.freebsd.org/D19490
2019-03-09 01:12:59 +00:00
Conrad Meyer
905fdc3ff1 seq(1): Require user-provided format strings to contain a conversion
This matches GNU seq, for example.

For users that are looking for similar functionality, 'jot -b foo N' will
print 'foo' N times.  See jot(1).

PR:		236347
Reported by:	<y AT maya.st>
Sponsored by:	Dell EMC Isilon
2019-03-07 18:24:16 +00:00
Mateusz Piotrowski
fdca34e4a5 Do not reference deskutils/cal from cal.1.
The ports version of cal is an abandonware so in order to minimize the
potential bit rot of our documentation let's not mention it at all.
Interested users are going to find suitable alternatives anyway on their
own.

Reported by:	bapt
Approved by:	bapt (src)
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D19492
2019-03-07 11:09:25 +00:00
Mateusz Piotrowski
a832f42afb Document that cal(1) cannot start a week with Monday.
Reviewed by:	bcr
Approved by:	bcr (doc)
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D19491
2019-03-07 10:19:40 +00:00
Alexander Motin
fcc8734127 Flush stdout after each iteration.
Without this, if output is redirected from the console, it is buffered for
too long, making tool quite unusable.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2019-03-06 15:19:04 +00:00
Marcel Moolenaar
835adc6898 Round # partitions up to fill the last GPT table sector
Set the number of partitions entries in the GPT header to a
multiple of the number of entries that fit in a sector.

PR:		236238
Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19465
2019-03-05 22:55:33 +00:00
Mark Johnston
6a85590370 Show wiring state of map entries in procstat -v.
Note that only entries wired by userspace are shown as such.  In
particular, entries transiently wired by sysctl_wire_old_buffer() are
not flagged as wired in procstat -v output.

Reviewed by:	kib (previous version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19461
2019-03-05 19:45:37 +00:00
Dimitry Andric
844fc3e907 Merge ^/head r344549 through r344775. 2019-03-04 19:14:32 +00:00
Kenneth D. Merry
0caf9bf62d Add IBM TS1160 density codes to libmt and the mt(1) man page.
These are taken directly from the density report from a TS1160
tape drive.  (Using mt getdensity)

A TS1160 drive stores 20TB raw (60TB with compression) on a JE tape.

lib/libmt/mtlib.c:
	Add 3592A6 encrypted/unencrypted density codes, and bpmm/bpi
	values.

usr.bin/mt/mt.1:
	Add 3592B5 encrypted/unencrypted density codes, bpmm/bpi
	values and number of tracks.  Bump the man page date.

MFC after:	3 days
Sponsored by:	Spectra Logic
2019-03-04 14:30:37 +00:00
Bjoern A. Zeeb
9784899d58 Fix compilation of world with WITHOUT_{INET,INET6}_SUPPORT or both set.
Buildworld failed when both WITHOUT_INET6_SUPPORT and INET equivalent were set.
Fix netstat and syslogd by applying appropriate #ifdef INET/INET6 to make world
compile again.

Reviewed by:		ngie, hrs, ume
Welcomed by:		Michael Dexter (D17040)
MFC after:		3 days
Differential Revision:	https://reviews.freebsd.org/D19418
2019-03-03 10:00:26 +00:00
Kyle Evans
ef30b5a809 patch(1): Exit successfully if we're fed a 0-length patch
This change is made in the name of GNU patch compatibility. If GNU patch is
fed a zero-length patch, it will exit successfully with no output. This is
used in at least one port to date (comms/wsjtx), and we break on this usage.

It seems unlikely that anyone relies on patch(1) calling their completely
empty patch garbage and failing, and GNU compatibility is a plus if it helps
with porting, so make the switch.

Reported by:	db
MFC after:	2 weeks
2019-03-01 01:20:21 +00:00
Thomas Munro
b5eab9d461 truss: Add support for fsync(2) and fdatasync(2).
The default handling showed the argument as hex.  Add explicit handling so
we can show it as decimal, since that's how we show file descriptors
everywhere else.

Approved by:	mjg (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19295
2019-02-28 09:13:41 +00:00
Konstantin Belousov
146537449b proccontrol(1) man page.
Reviewed by:	0mp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D19308
2019-02-26 17:46:19 +00:00
Mark Johnston
2528b7e2cb Fix handling of rights on stdio streams, take two.
Split the rights-limiting code into two cases: if one of the input
files isn't a regular file, use caph_limit_stream(3) instead of
open-coding the same logic; if both input files are regular files,
and the initial attempts to map them succeed, we limit the rights on
those files to CAP_MMAP_R.

Add a regression test for PR 234885.

PR:		234885
Reviewed by:	delphij
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19216
2019-02-25 19:47:27 +00:00
Dimitry Andric
a8fe8db49a Merge ^/head r344178 through r344512. 2019-02-25 11:59:29 +00:00
Ed Maste
33c1ce3b72 svn: support building with WITH_PIE
Subversion builds and links against its own .a archives using local
rules, so did not benefit from with the WITH_PIE library support added
in r344179.  Apply the same _pie suffix locally.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D19246
2019-02-21 15:08:25 +00:00
Dimitry Andric
281bdc30df Fix more AddressSanitizer violations in usr.bin/top
In line_update(), set lastcol correctly after moving to any non-zero
column, so the "overwrite old stuff" part does not attempt to address
negative offsets in the current line.

Rewrite setup_buffer() to always allocate at least 80 characters,
otherwise various calls to summary_format() will overwrite the end of
the buffers, if the screen width gets small enough.

MFC after:	1 week
2019-02-20 20:17:54 +00:00
Baptiste Daroussin
adedf5ee31 calendar: use iconv to respect the output encoding
calendar(1) can have input in various encoding, specifying
LANG=<locale_name> to enable calendar(1) to determine which one to use.

The problem is the content of the calendar itself is exposed as is making it
unreadable in many cases. For example french calendar which is encoded
ISO8859-1 is rendered badly in a fr_FR.UTF-8 environment.

Using iconv allows to solve this issue.
This will also allow to keep only 1 encoding in base for those files without
breaking user existing setup

Reported by:	many
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D19221
2019-02-20 06:40:52 +00:00
Konstantin Belousov
90ce241081 Minor cleanup for mkuzip(8) man page.
List all single-letter options in summary.
Order options alphabetically.

Sponsored by:	Mellanox Technologies
MFC after:	3 days
2019-02-19 20:26:03 +00:00
Ed Maste
c0347e182c kdump: expand comment on reasons for CAPFAIL_LOOKUP
Comment for CAPFAIL_LOOKUP refered only to paths containing ".." but
it is returned for other restricted VFS lookup cases, such as absolute
paths or openat(AT_FDCWD, ...).
2019-02-18 03:49:16 +00:00
Ed Maste
bcf99d2d99 Add WITH_PIE knob to build Position Independent Executables
Building binaries as PIE allows the executable itself to be loaded at a
random address when ASLR is enabled (not just its shared libraries).

With this change PIE objects have a .pieo extension and INTERNALLIB
libraries libXXX_pie.a.

MK_PIE is disabled for some kerberos5 tools, Clang, and Subversion, as
they explicitly reference .a libraries in their Makefiles.  These can
be addressed on an individual basis later.  MK_PIE is also disabled for
rtld-elf because it is already position-independent using bespoke
Makefile rules.

Currently only dynamically linked binaries will be built as PIE.

Discussed with:	dim
Reviewed by:	kib
MFC after:	1 month
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18423
2019-02-15 22:22:38 +00:00
Dimitry Andric
c981cbbd13 Merge ^/head r343956 through r344177. 2019-02-15 21:50:45 +00:00
Konstantin Belousov
fa50a3552d Implement Address Space Layout Randomization (ASLR)
With this change, randomization can be enabled for all non-fixed
mappings.  It means that the base address for the mapping is selected
with a guaranteed amount of entropy (bits). If the mapping was
requested to be superpage aligned, the randomization honours the
superpage attributes.

Although the value of ASLR is diminshing over time as exploit authors
work out simple ASLR bypass techniques, it elimintates the trivial
exploitation of certain vulnerabilities, at least in theory.  This
implementation is relatively small and happens at the correct
architectural level.  Also, it is not expected to introduce
regressions in existing cases when turned off (default for now), or
cause any significant maintaince burden.

The randomization is done on a best-effort basis - that is, the
allocator falls back to a first fit strategy if fragmentation prevents
entropy injection.  It is trivial to implement a strong mode where
failure to guarantee the requested amount of entropy results in
mapping request failure, but I do not consider that to be usable.

I have not fine-tuned the amount of entropy injected right now. It is
only a quantitive change that will not change the implementation.  The
current amount is controlled by aslr_pages_rnd.

To not spoil coalescing optimizations, to reduce the page table
fragmentation inherent to ASLR, and to keep the transient superpage
promotion for the malloced memory, locality clustering is implemented
for anonymous private mappings, which are automatically grouped until
fragmentation kicks in.  The initial location for the anon group range
is, of course, randomized.  This is controlled by vm.cluster_anon,
enabled by default.

The default mode keeps the sbrk area unpopulated by other mappings,
but this can be turned off, which gives much more breathing bits on
architectures with small address space, such as i386.  This is tied
with the question of following an application's hint about the mmap(2)
base address. Testing shows that ignoring the hint does not affect the
function of common applications, but I would expect more demanding
code could break. By default sbrk is preserved and mmap hints are
satisfied, which can be changed by using the
kern.elf{32,64}.aslr.honor_sbrk sysctl.

ASLR is enabled on per-ABI basis, and currently it is only allowed on
FreeBSD native i386 and amd64 (including compat 32bit) ABIs.  Support
for additional architectures will be added after further testing.

Both per-process and per-image controls are implemented:
- procctl(2) adds PROC_ASLR_CTL/PROC_ASLR_STATUS;
- NT_FREEBSD_FCTL_ASLR_DISABLE feature control note bit makes it possible
  to force ASLR off for the given binary.  (A tool to edit the feature
  control note is in development.)
Global controls are:
- kern.elf{32,64}.aslr.enable - for non-fixed mappings done by mmap(2);
- kern.elf{32,64}.aslr.pie_enable - for PIE image activation mappings;
- kern.elf{32,64}.aslr.honor_sbrk - allow to use sbrk area for mmap(2);
- vm.cluster_anon - enables anon mapping clustering.

PR:	208580 (exp runs)
Exp-runs done by:	antoine
Reviewed by:	markj (previous version)
Discussed with:	emaste
Tested by:	pho
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D5603
2019-02-10 17:19:45 +00:00
Dimitry Andric
7362ea6db0 Fix the first couple of AddressSanitizer violations in usr.bin/top.
Avoid setting zero bytes beyond the length of the 'thisline' parameters
in i_process() and u_process(), and don't attempt to memset a negative
number of bytes.

MFC after:	1 week
2019-02-10 13:44:36 +00:00
Dimitry Andric
2f301637c8 Fix multiple warnings in usr.bin/top about variables shadowing global
declarations from base gcc, by renaming those variables.

MFC after:	1 week
2019-02-10 13:34:21 +00:00
Dimitry Andric
d0f687d30f Fix multiple warnings in usr.bin/top about discarded qualifiers from
both clang and gcc, by either constifying variables, or when that is not
possible, using __DECONST.

MFC after:	1 week
2019-02-10 13:31:08 +00:00
Dimitry Andric
9e43c218d5 Merge ^/head r343807 through r343955. 2019-02-10 12:49:34 +00:00
Johannes Lundberg
5515886768 Add myself to committers-src.dot and calendar.freebsd
Reviewed by:	imp (mentor)
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D19101
2019-02-09 16:53:39 +00:00
Kai Knoblich
78aa2590c1 Add myself to committers-ports.dot and calendar.freebsd
Reviewed by:	miwi (mentor)
Approved by:	miwi (mentor)
Differential Revision:	https://reviews.freebsd.org/D19119
2019-02-08 17:57:39 +00:00
Andriy Voskoboinyk
245a7edb05 newkey(8): fix 'tmpname' memory leak (always) and input file descriptor leak
when output file cannot be opened

PR:		201732
Reported by:	David Binderman <dcb314@hotmail.com>
MFC after:	1 week
2019-02-08 14:31:44 +00:00
Andriy Voskoboinyk
558fe07149 ipcs(1): drop obsolete error checking
This code is not reached since r77551.

PR:		201728
MFC after:	5 days
2019-02-07 14:29:45 +00:00
Ed Maste
0235d5e283 vtfontcvt: whitespace cleanup
PR:		205707
Submitted by:	Dmitry Wagin
2019-02-06 18:50:48 +00:00
Dimitry Andric
c2c227a536 Merge ^/head r343571 through r343711. 2019-02-03 11:41:43 +00:00
Bryan Drewery
ab3cf2b476 Shar files may be seen as binary by grep.
Suggest using -a to egrep to properly see executed commands.

This is a minor improvement to the manpage.  A better improvement
would be removal or gigantic warnings.

Sponsored by:	Dell EMC
MFC after:	1 week
2019-01-31 23:21:18 +00:00
Ed Maste
97d368d62b elfdump: use designated array initialization for note types
This ensures the note type name is in the correct slot.

PR:		228290
Submitted by:	kib
MFC with:	343610
Sponsored by:	The FreeBSD Foundation
2019-01-31 16:49:06 +00:00
Ed Maste
8ae9aa2772 elfdump: fix build after r343610
One patch hunk did not survive the trip from git to svn.

PR:		228290
MFC with:	r343610
2019-01-31 16:21:09 +00:00
Ed Maste
2bc7b0242f elfdump: include note type names
Based on a patch submitted by Dan McGregor.

PR:		228290
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-01-31 16:19:04 +00:00
Ed Maste
0f663f7258 elfdump: whitespace fixup in advance of other changes 2019-01-31 16:11:15 +00:00
Kyle Evans
6cbda6d943 install(1): Fix relative path calculation with partial common dest/src
For example, from the referenced PR [1]:

$ mkdir /tmp/lib/ /tmp/libexec
$ touch /tmp/lib/foo.so
$ install -lrs /tmp/lib/foo.so /tmp/libexec/

The common path identification bits terminate src at /tmp/lib/ and the
destination at /tmp/libe. The subsequent backtracking is then incorrect, as
it traverses the destination and backtraces exactly one level while eating
the 'libexec' because it was previously (falsely) identified as common with
'lib'.

The obvious fix would be to make sure we've actually terminated just after
directory separators and rewind a character if we haven't. In the above
example, we would end up rewinding to /tmp/ and subsequently doing the right
thing.

Test case added.

PR:		235330 [1]
MFC after:	1 week
2019-01-31 05:20:11 +00:00
Dimitry Andric
7e565c552a Merge ^/head r343320 through r343570. 2019-01-30 07:10:33 +00:00
Oleksandr Tymoshenko
c245efb99b calendar(1): Fix Aschermittwoch date for Austrian calendar
PR:		165516
Submitted by:	jhs@berklix.com
MFC after:	1 week
2019-01-29 19:54:37 +00:00
Benedict Reuschling
a9ea96eafd A few corrections and clarifications to r343406.
- Use "in" instead of "on" when referring to directory and UFS partition.
- Switch from hw.physmem to hw.realmem and add a description to
distinguish the two.
- Explain why the "df" command is having trouble displaying ZFS sizes
correctly. Add a bit more descriptive text to help why the output of
"zfs list -o space" should be used.
- Switch to vmstat instead of iostat display for systat(1) as it shows
more information on one screen. Describe what is displayed based on the
text of the man page. Change the list of the other values accordingly.
- Sort the flags to "zfs destroy" alphabetically.

Reviewed by:	rgrimes
Approved by:	rgrimes
MFC after:	8 days
Differential Revision:	https://reviews.freebsd.org/D18993
2019-01-28 19:54:58 +00:00
Oleksandr Tymoshenko
f2ef15fec4 Fix whiteout support in find(1)
find(1) ignores -type w passed to it. With this patch find(1) properly
identifies and prints whiteouts.

PR:		126384, 156703
Submitted by:	oleg@mamontov.net
MFC after:	1 week
2019-01-28 02:00:39 +00:00
Stefan Eßer
f5ce14028c Silence Clang Scan warnings regarding the use of strcp().
While these warnings are false positives, the use of strdup() instead of
malloc() and strcpy() simplifies and clarifies the code.

While checking the remaining uses of strcpy and strcat I noticed an
assignment of a strlen() to a variable "s", whose value needs to be
preserved for use in later output routines (where it is used to allocate
a buffer). I do not think that the value of "s" will come out lower than
its correct value and thus there is no risk of a buffer overflow, in the
general case, but a specially crafter argument might lead to an overflow.

The bogus assignment to "s" is removed since this value was only used a
single time in the following malloc() call, which has been removed.

MFC after:	2 weeks
2019-01-24 18:39:45 +00:00