Commit Graph

8429 Commits

Author SHA1 Message Date
Enji Cooper
c0f64185c6 rctl_add_rule(2): fix manlint warnings
- Fix commas (either missing or misused) after .Nm entries in SYNOPSIS

Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:32:57 +00:00
Enji Cooper
60f14b3186 cap_enter(2): fix manlint issues
- Sort SEE ALSO section appropriately.
- Correct section for sysctl(9).

Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:31:03 +00:00
Enji Cooper
bb09af5f58 _umtx_op(2): fix minor manlint issues
- Sort .Xr entries in SEE ALSO section.
- Sort SEE ALSO and STANDARDS sections properly, in terms of the
  entire document.

Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:26:45 +00:00
Enji Cooper
94f6747eb9 xdr(3): add missing comma after xdr_sizeof(3) in SYNOPSIS
This unbreaks the .Nm declaration

Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:17:52 +00:00
Enji Cooper
2a105685d2 fopencookie(3): declare function pointers in SYNOPSIS correctly
Add obligatory `*` in declarations.

Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:15:57 +00:00
Enji Cooper
40850c3b4f quick_exit(3): delete trailing whitespace in licensing tort
Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:14:46 +00:00
Enji Cooper
7372d8148c acl_to_text(3): start sentences on new lines
Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:12:31 +00:00
Enji Cooper
5f19e26b75 acl_create_entry(3): separate .Nm entries with commas in SYNOPSIS
Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:11:15 +00:00
Enji Cooper
f18519e1d5 sctp_send(3): start sentences on new lines
Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:10:20 +00:00
Enji Cooper
5e84ba7a43 localeconv(3): start sentences on new lines
Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:09:26 +00:00
Enji Cooper
39d657f5db fopen(3): make manlint fixes
- Break on new lines.
- Use .Dv with NULL.
- Rewrap lines as necessary/when possible.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:08:30 +00:00
Enji Cooper
b4b5c4a602 posix1e(3): reference using the section (3) when referencing libbsm with .Xr
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:05:34 +00:00
Enji Cooper
a18696433a __iconv_get_list: separate .Nm entries with commas
MFC after:	2 weeks
Reported by:	make manlint
Sponsored by:	Dell EMC Isilon
2017-05-23 07:02:01 +00:00
Enji Cooper
671ea87fba tcsendbreak(3): delete spurious blank line at the end of the man page
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 06:58:08 +00:00
Enji Cooper
3d54bd2294 dirname(3): fix section ordering
IMPLEMENTATION NOTES come before RETURN VALUES

MFC after:	2 weeks
Reported by:	make manlint
Sponsored by:	Dell EMC Isilon
2017-05-23 06:56:57 +00:00
Enji Cooper
a966418a66 directory(3): delete trailing whitespace and rewrite E.g. as e.g.
Reported by:	make manlint
Sponsored by:	Dell EMC Isilon
2017-05-23 06:55:51 +00:00
Enji Cooper
41a9662896 basename(3): fix section ordering
IMPLEMENTATION NOTES come before RETURN VALUES

MFC after:	2 weeks
Reported by:	make manlint
Sponsored by:	Dell EMC Isilon
2017-05-23 06:53:31 +00:00
Enji Cooper
1384163706 err(3): use NULL, aka (void*)0 per POSIX instead of (FILE *)0
This is being done to aid humans and static analysis checkers.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 06:14:02 +00:00
Eric van Gyzen
07f29d9f76 Remove old spinlock_debug code from libc
This no longer seems useful.  Remove it.

This was prompted by a "cast discards volatile qualifier" warning
in libthr when WARNS=6.

Reviewed by:	kib
MFC after:	3 days
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D10832
2017-05-20 17:32:01 +00:00
Xin LI
ca1578f0c0 The current qsort(3) implementation ignores the sizes of partitions, and
always perform recursion on the left partition, then use a tail call to
handle the right partition.  In the worst case this could require O(N)
levels of recursions.

Reduce the possible recursion level to log2(N) by always recursing on the
smaller partition instead.

Obtained from:	PostgreSQL 9d6077abf9d6efd992a59f05ef5aba981ea32096
2017-05-19 04:59:12 +00:00
Xin LI
a3f893fc61 Use size_t.
Inspired by:	OpenBSD src/lib/libc/stdlib/qsort.c,v 1.11
2017-05-19 04:44:14 +00:00
Konstantin Belousov
fade31741d Add tests for some cases in r318298.
The first test triggers the out of bounds read of the 'left' array. It
only fails when realpath.c is compiled with '-fsanitize=address'.

The other test checks for ENOENT when running into an empty
symlink. This matches NetBSD's realpath(3) semantics. Previously,
empty symlinks were treated like ".".

Submitted by:	Jan Kokemц╪ller <jan.kokemueller@gmail.com>
PR:	219154
MFC after:	2 weeks
2017-05-18 13:49:53 +00:00
Stephen J. Kiernan
f55d7dd1c9 Add information to open(2) man page about the O_VERIFY flag.
Reviewed by:	bjk wblock
Approved by:	sjg (mentor)
Obtained from:	Juniper Networks, Inc.
2017-05-15 19:32:26 +00:00
Ed Maste
b47e69e69e getusershell: don't write past end of line buffer reading local shells
_local_initshells did not reset cp to the beginning of the line buffer
for every iteration that it called fgets(3), leading to writing past the
end of line with fairly long /etc/shells or excessively long line
lengths. Correct this by properly resetting cp.

PR:		192528
Submitted by:	Kyle Evans <kevans91@ksu.edu>
Reviewed by:	cem, jilles
Differential Revision:	https://reviews.freebsd.org/D10690
2017-05-15 17:57:09 +00:00
Konstantin Belousov
cf5cedd785 Style.
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2017-05-15 17:54:36 +00:00
Konstantin Belousov
d933a4c06b Simplify cleanup on failure in realpath(3).
If realpath() allocated memory for result and failed, the memory is
freed in each place where return is performed.  More, the function
needs to track the allocation status, to not free user-supplied
buffer.

Consolidate the memory handling in the wrapper, freeing the buffer if
the actual worker failed.

Reviewed by:	emaste (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D10670
2017-05-15 17:34:17 +00:00
Konstantin Belousov
f81e5b2d9b Fix several buffer overflows in realpath(3).
- The statement "left_len -= s - left;" does not take the slash into
  account if one was found. This results in the invariant
  "left[left_len] == '\0'" being violated (and possible buffer
  overflows). The patch replaces the variable "s" with a size_t
  "next_token_len" for more clarity.
- "slen" from readlink(2) can be 0 when encountering empty
  symlinks. Then, further down, "symlink[slen - 1]" underflows the
  buffer. When slen == 0, realpath(3) should probably return ENOENT
  (http://austingroupbugs.net/view.php?id=825,
  https://lwn.net/Articles/551224/).

Some other minor issues:
- The condition "resolved_len >= PATH_MAX" cannot be true.
- Similarly, "s - left >= sizeof(next_token)" cannot be true, as long
  as "sizeof(next_token) >= sizeof(left)".
- Return ENAMETOOLONG when a resolved symlink from readlink(2) is too
  long for the symlink buffer (instead of just truncating it).
- "resolved_len > 1" below the call to readlink(2) is always true as
  "strlcat(resolved, next_token, PATH_MAX);" always results in a
  string of length > 1. Also, "resolved[resolved_len - 1] = '\0';" is
  not needed; there can never be a trailing slash here.
- The truncation check for "strlcat(symlink, left, sizeof(symlink));"
  should be against "sizeof(symlink)" (the third argument to strlcat)
  instead of "sizeof(left)".

Submitted by:	Jan Kokemц╪ller <jan.kokemueller@gmail.com>
PR:	219154
MFC after:	2 weeks
2017-05-15 17:14:53 +00:00
Jilles Tjoelker
8f932310ff glob: Fix comment about collapsing asterisks after r317749.
After r317749, collapsing adjacent asterisks is still required, but for a
different reason.
2017-05-07 19:52:56 +00:00
Brooks Davis
f19351aad8 Provide a freebsd32 implementation of sigqueue()
The previous misuse of sys_sigqueue() was sending random register or
stack garbage to 64-bit targets.  The freebsd32 implementation preserves
the sival_int member of value when signaling a 64-bit process.

Document the mixed ABI implementation of union sigval and the
incompability of sival_ptr with pointer integrity schemes.

Reviewed by:	kib, wblock
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D10605
2017-05-05 18:49:39 +00:00
Conrad Meyer
9ac9bc28bb cpuset.2: Document new API options
A follow-up to r317756.  Adrian will chase up the userspace cpuset(1)
additions.

Reported by:	kib@
Sponsored by:	Dell EMC Isilon
2017-05-03 18:46:33 +00:00
Conrad Meyer
1365421f09 glob: Fix an overlong line
Trivial style(9) fix, no functional change.  There are also some 81
characters lines below, but I don't see a good way to shorten them.

Sponsored by:	Dell EMC Isilon
2017-05-03 16:34:22 +00:00
Conrad Meyer
241eb37e29 libc glob: Avoid pathological exponential behavior
Adapt glob's match() routine to use a greedy algorithm that avoids
exponential runtime in byzantine inputs.

While here, add a testcase for the byzantine input.

Prompted by:	https://research.swtch.com/glob
Authored by:	Yves Orton <demerphq at gmail.com>
Obtained from:	Perl (33252c318625f3c6c89b816ee88481940e3e6f95)
Sponsored by:	Dell EMC Isilon
2017-05-03 15:55:29 +00:00
Brooks Davis
9806ef7852 Correct an out-of-bounds read in regcomp when the RE is bad.
When passed the invalid regular expression "a**", the error is
eventually detected and seterr() is called. It sets p->error
appropriatly and p->next and p->end to nuls which is a never used char
nuls[10] which is zeros due to .bss initialization. Unfortunatly,
p_ere_exp() and p_simp_re() both have fall through cases where they set
the error, decrement p->next and access it which means a read from what
ever .bss variable comes before nuls.

Found with regex_test:repet_multi and CHERI bounds checking.

Reviewed by:	ngie, pfg, emaste
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D10541
2017-05-02 21:20:27 +00:00
Brooks Davis
efa2501ed6 Support clnt_raw's use of FD_SETSIZE as a fake file descriptor.
Accomplish this by allocating space for it in __svc_xports and allowing
it to be registered.  The failure to allocate space was causing an
out-of-bounds read in svc_getreq_common().  The failure to register
caused PR 211804.

The bug was found with CHERI bounds checking.

PR:		211804
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Reviewed by:	ngie
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10528
2017-05-01 20:04:07 +00:00
Konstantin Belousov
f7a6f6a2c0 Make semaphore names list mutex non-recursive.
The mutex is used in sem_open() and sem_close(), which cannot
recurse. The atfork handlers cannot collide with the open and close
code.

Reviewed by:	vangyzen
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D10545
2017-04-30 19:37:45 +00:00
Konstantin Belousov
e6a183a40e Restructure normal (non-error) control flow in sem_close().
Do not retest for the found semaphore after the loop to look it up.
Instead, handle both cases of last and non-last close simultaneously,
which allows to consolidate the list unlock and successful return.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-04-30 19:32:51 +00:00
Konstantin Belousov
3a1371626e Style.
- Use ANSI C function definitions.
- Remove redundand cast.
- Minor style compliance tweaks.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-04-30 10:47:59 +00:00
Ruslan Bukin
bbbb0b5544 Use unconditional jr (jump register) so cerror relocation offset fits.
This fixes libc build on riscv64sf.

Reviewed by:	jhb
Sponsored by:	DARPA, AFRL
2017-04-27 22:40:39 +00:00
Konstantin Belousov
76c239924e getpagesize(3) cannot fail.
Sponsored by:	The FreeBSD Foundation
2017-04-26 14:28:27 +00:00
Konstantin Belousov
db4a195744 getpagesize(3) cannot fail.
The sysctl(HW_PAGESIZE) call cannot fail on FreeBSD kernels at least.
And even if it failed for some improbable reason, PAGE_SIZE is a safe
value to return.

Discussed with:	jilles
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-04-26 14:25:01 +00:00
Brooks Davis
a7dc31283a Remove the NATM framework including the en(4), fatm(4), hatm(4), and
patm(4) devices.

Maintaining an address family and framework has real costs when we make
infrastructure improvements.  In the case of NATM we support no devices
manufactured in the last 20 years and some will not even work in modern
motherboards (some newer devices that patm(4) could be updated to
support apparently exist, but we do not currently have support).

With this change, support remains for some netgraph modules that don't
require NATM support code. It is unclear if all these should remain,
though ng_atmllc certainly stands alone.

Note well: FreeBSD 11 supports NATM and will continue to do so until at
least September 30, 2021.  Improvements to the code in FreeBSD 11 are
certainly welcome.

Reviewed by:	philip
Approved by:	harti
2017-04-24 21:21:49 +00:00
Pedro F. Giffuni
5f2bd3bdac scandir(3): promote arraysz to size_t to match numitems.
The internal array size goes through a loop and is compared with numitems
which at its limits makes can be unreachably higher than arraysz.
Prevent an hypothetical overflow by matching the types.

MFC after:	1 week
2017-04-24 14:56:41 +00:00
Pedro F. Giffuni
8d0f9a9364 regex: unsign and constify some variables.
Taking some hints from the regex variant in nvi(1) and higher-level
compiler warnings, update some types in our regex(3) implementation.

Joint work with:	Kyle Evans
MFC after:		2 weeks
2017-04-23 21:51:29 +00:00
Enji Cooper
3c3e9e1035 Note that getpagesize(3) can return -1 on failure
MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-23 03:17:32 +00:00
Sergey Kandaurov
b11ef6e971 Document kevent EVFILT_EMPTY.
Reviewed by:	hiren
X-MFC with:	r312277
2017-04-18 15:36:13 +00:00
Alexander Motin
f924326575 Optimize pathologic case of telldir() for Samba.
When application reads large directory, calling telldir() for each entry,
like Samba does, it creates exponential performance drop as number of
entries reach tenths to hundreds of thousands.  It is caused by full search
through the internal list, that never finds matches in that scenario, but
creates O(n^2) delays.  This patch optimizes that search, limiting it to
entries of the same buffer, turning time closer to O(n) in case of linear
directory scan.

PR:		218622
Reviewed by:	jhb, jilles
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D10408
2017-04-17 19:03:31 +00:00
Baptiste Daroussin
c48dc2a193 Fix strcoll_l disagreeing with strxfrm by reworking the forward order case in
wcscoll_l().

Illumos fixed this while grabbing back our patches:
https://www.illumos.org/rb/r/402/

This does not 100% fix what postgresql folks reported as there is still a
remaining issue: https://www.illumos.org/issues/7962, it improves the situation

The initial issue was reported in postgresql mailing lists:
https://www.postgresql.org/message-id/flat/111D0E27-A8F3-4A84-A4E0-B0FB703863DF@s24.com#111D0E27-A8F3-4A84-A4E0-B0FB703863DF@s24.com

Submitted by:	Yuri Pankov <yuri.pankov@nexenta.com>
Obtained from:	Illumos
MFC after:	2 weeks
2017-04-16 19:12:07 +00:00
Brooks Davis
8439a7220d Fix an out-of-bounds write when a zero-length buffer is passed.
Found with ttyname_test and CHERI bounds checking.

Reviewed by:	emaste
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D10377
2017-04-13 15:52:45 +00:00
Konstantin Belousov
f6ef11cc75 Report _SC_SEM_NSEMS_MAX and _SC_SEM_VALUE_MAX which show parameters
of the current usermode implementation of the POSIX semaphores.

For NSEMS_MAX, return -1 without changing errno, which indicates that
the variable has no limit.  Before, sysconf(3) returned parameters
queried from the ksem(9) legacy implementation, which apparently has
low defaults for NSEMS_MAX.

Reported and tested by:	jbeich
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-04-12 19:27:14 +00:00
Alexander Kabaev
07b49497db Do not use b.cs instruction to jump to cerror.
The conditional jump can only be performed to targets up to 1MB in
either direction and does not work too well when linker places cerror
further that that from the caller. In that case linker will complain
about relocation overflows.

Reviewed by: emaste, andrew
Differential Revision:  https://reviews.freebsd.org/D10305
2017-04-07 22:58:20 +00:00