Commit Graph
8292 Commits
Author SHA1 Message Date
Konstantin Belousov 8f502a188d MFC r323597:
Handle freeaddrinfo(NULL).
2017-09-21 10:16:25 +00:00
Pedro F. Giffuni 5866b32fa3 MFC r322925:
libc: minor indent(1) cleanups.

Illumos and Schillix are adopting some of the locale code and our style(9)
sometimes matches the Solaris cstyle, so the changes are also useful as a
way to reduce diffs.

No functional change.
2017-09-13 16:21:11 +00:00
Konstantin Belousov afcf1d7c61 MFC 322763:
Optimize libc to get and set TLS using the RDFSBASE and RDGSBASE
instructions, if supported both by CPU and kernel.
2017-09-13 11:29:48 +00:00
Alan Somers 4144cd5dfb MFC r320255
(note that part of 320255 was erroneously MFCed by 322889)

Clarify usage of aio(4) with kqueue(2)

Reviewed by:    jhb
MFC after:      3 weeks
Differential Revision:  https://reviews.freebsd.org/D11299
2017-08-28 18:40:26 +00:00
Alan Somers f92c1b8ae1 MFC r320737, r320914
r320737:
Fix cleanup in lib/libc/gen/setdomainname_test

ATF cleanup routines run in separate processes from the tests themselves, so
they can't share global variables.

Also, setdomainname_test needs to be is_exclusive because the test cases
access a global resource.

PR:		219967
Reviewed by:	ngie
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D11188

r320914:
Remove an extraneous strlen from t_setdomainname.c

Reported by:	Coverity
CID:		1377568
X-MFC-With:	320737
Sponsored by:	Spectra Logic Corp
2017-08-25 12:16:03 +00:00
Konstantin Belousov 2f90ec7e83 MFC r322427:
Improve standard compliance for memset_s() and abort_handler_s().
2017-08-19 09:38:43 +00:00
Konstantin Belousov 4e8a169f0c MFC r322456:
On i386 with CPUID but without SSE2, set lfence_works to LMB_NONE
instead of looping.
2017-08-15 09:44:18 +00:00
Konstantin Belousov a49e3fc4d7 MFC r322426:
Fix indent.
2017-08-15 09:40:57 +00:00
Pedro F. Giffuni e8e1f0cb36 MFC r322368, r322371:
fnmatch(3): improve POSIX conformance.

In a recent interpretation[1], "\\" shall return a non-zero value
(indicating either no match or an error).

The fix involves a change over r254091 and now the behavior matches the
Sun/IBM/HP closed source implementations and also likely musl libc.

Submitted by:	Joerg Schilling <joerg at schily.net>

[1] http://austingroupbugs.net/view.php?id=806
2017-08-15 00:54:16 +00:00
Konstantin Belousov 23d16411d6 MFC r321608:
Use MFENCE to serialize RDTSC on non-Intel CPUs.
2017-08-10 09:00:15 +00:00
Konstantin Belousov 19315d39ea MFC r321652:
Simplify flow control.
2017-08-04 08:12:19 +00:00
Konstantin Belousov 15f6c778cb MFC r314319 (by oshogbo):
Don't try to open devices in the gettc() function  which will always
fail in the Capability mode. Instead silently fallback to the syscall
method, which is done for example in the gettimeofday(2) function.

MFC r314320 (by oshogbo):
Remove unneeded variable initialization from r314319.

MFC r321461:
Fix indent.
2017-07-28 10:30:59 +00:00
Konstantin Belousov 4000ed3557 MFC r319875:
Add ptrace(PT_GET_SC_ARGS) command to return debuggee' current syscall
arguments.
2017-07-21 18:12:35 +00:00
Enji Cooper 9646ee041b MFC note: content changes of r317315 were reversed. .Dd is being updated
for diff reduction purposes.

MFC r317315,r317437:

r317315:

Note that getpagesize(3) can return -1 on failure

r317437 (by kib):

getpagesize(3) cannot fail.
2017-07-19 20:58:45 +00:00
Mark Johnston 46c1d577f1 MFC r320895:
Don't dlclose NSS modules from nss_atexit().
2017-07-18 23:02:34 +00:00
Enji Cooper 822f2dae85 MFC r318706:
localeconv(3): start sentences on new lines
2017-07-18 18:37:50 +00:00
Enji Cooper 8c0f888533 MFC r318712:
xdr(3): add missing comma after xdr_sizeof(3) in SYNOPSIS

This unbreaks the .Nm declaration
2017-07-18 18:36:44 +00:00
Enji Cooper ec2851ba12 MFC r318703:
__iconv_get_list: separate .Nm entries with commas
2017-07-18 18:35:46 +00:00
Enji Cooper 26a07e8fbd MFC r318707:
sctp_send(3): start sentences on new lines
2017-07-18 18:34:09 +00:00
Enji Cooper bc669ea59b MFC r318704,r318708,r318709:
r318704:

posix1e(3): reference using the section (3) when referencing libbsm with .Xr

r318708:

acl_create_entry(3): separate .Nm entries with commas in SYNOPSIS

r318709:

acl_to_text(3): start sentences on new lines
2017-07-18 18:23:56 +00:00
Enji Cooper 92e835c023 MFC r318710:
quick_exit(3): delete trailing whitespace in licensing tort
2017-07-18 18:20:56 +00:00
Enji Cooper c30f4d6448 MFC r318715,r318717,r318718,r318719,r318720,r318721:
r318715:

_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.

r318717:

cap_enter(2): fix manlint issues

- Sort SEE ALSO section appropriately.
- Correct section for sysctl(9).

r318718:

rctl_add_rule(2): fix manlint warnings

- Fix commas (either missing or misused) after .Nm entries in SYNOPSIS

r318719:

open(2): fix manlint warnings

- Sort SEE ALSO .Xr entries.
- Sort sections (HISTORY comes after STANDARDS).

r318720:

ptrace(2): clean up trailing whitespace

r318721:

kill(2): add missing section for sysctl(9)
2017-07-18 18:15:28 +00:00
Enji Cooper 7674f9d7ba MFC r319048,r319049,r319051,r319054:
r319048:

Push `snapshot_file` copying down into run_tests function, and mark snapshot_file
const char *.

This fixes a bogus set of errors from gcc about strdup not being allowed a NULL
argument.

r319049:

Bump WARNS from 1 to 3 after recent commits to fix warnings in the
directory.

Tested with:	clang 4.0, gcc 4.2.1, gcc 6.3.0

r319051:

hostent_test_getnameinfo_eq(..): initialize found_a_host to false

CID:		1368943

r319054:

hostent_test_getaddrinfo_eq(..): call freeaddrinfo on `ai` when done

This plugs a leak of memory allocated via getaddrinfo.

CID:		1346866
2017-07-18 18:09:16 +00:00
Enji Cooper f2f3a7817f MFC r318701,r319842:
r318701:

tcsendbreak(3): delete spurious blank line at the end of the man page

r319842:

getbsize(3): clarify that underflow/overflow warnings in regard to $BLOCKSIZE
gets output via warnx(3)

This helps set expectations for how one might deal with those messages, i.e.,
mute output from /dev/stderr today, since that's where vwarn(3) outputs messages
to today.
2017-07-18 08:53:54 +00:00
Enji Cooper fa6b80853b MFC r318695:
err(3): use `NULL`, aka `(void*)0` per POSIX instead of `(FILE *)0`

This is being done to aid humans and static analysis checkers.
2017-07-18 08:50:43 +00:00
Enji Cooper b24b1a387d MFC r318705,r318711:
r318705:

fopen(3): make manlint fixes

- Break on new lines.
- Use .Dv with NULL.
- Rewrap lines as necessary/when possible.

r318711:

fopencookie(3): declare function pointers in SYNOPSIS correctly

Add obligatory `*` in declarations.
2017-07-18 08:33:07 +00:00
Konstantin Belousov d5e6294347 MFC r320868:
Fix warnings, adjust style.
2017-07-17 06:14:48 +00:00
Konstantin Belousov 2dc5f0f1a4 MFC r320472,r320508,r320509:
Make stdio deferred cancel-safe.
2017-07-13 09:27:11 +00:00
Konstantin Belousov 192f9d4dba MFC r320801:
Simplify language.
2017-07-11 05:33:07 +00:00
Konstantin Belousov a56a34fe31 MFC r320570:
Correct signatures of several pthreads stubs.
2017-07-09 03:54:10 +00:00
Konstantin Belousov 2110f0a42c Add MAP_GUARD and use it for stack grow area protection.
Bump __FreeBSD_version.

MFC r320317:
Implement address space guards.

MFC r320338:
Remove stale part of the comment.

MFC r320339:
Correctly handle small MAP_STACK requests.

MFC r320344:
For now, allow mprotect(2) over the guards to succeed regardless of
the requested protection.

MFC r320430:
Treat the addr argument for mmap(2) request without MAP_FIXED flag as
a hint.

MFC r320560 (by alc):
Modify vm_map_growstack() to protect itself from the possibility of the
gap entry in the vm map being smaller than the sysctl-derived stack guard
size.
2017-07-05 06:18:00 +00:00
Xin LI 55a6cc0cea MFC r320494: Fix double free by reverting r300385 and r300624 which was
false positive reported by cppcheck.

releng/11.1 candidate.
2017-07-03 02:11:14 +00:00
Konstantin Belousov 0be68c4afe MFC r320314:
Remove the description of MAP_HASSEMAPHORE.

Approved by:	re (marius)
2017-06-27 10:09:00 +00:00
Konstantin Belousov cde34cd00f MFC r320313:
Fix typo.

Approved by:	re (marius)
2017-06-27 09:42:56 +00:00
Xin LI a705a1ffe2 MFC r320216: Fix use-after-free introduced in r300388.
In r300388, endnetconfig() was called on nc_handle which would release
the associated netconfig structure, which means tmpnconf->nc_netid
would be a use-after-free.

Solve this by doing endnetconfig() in return paths instead.

Reported by:	jemalloc via kevlo
Reviewed by:	cem, ngie (earlier version)
Approved by:	re (kib)
2017-06-25 17:42:27 +00:00
Konstantin Belousov b26a805a0b MFC r320052:
Do not leak syslog_mutex on cancellation.

Approved by:	re (marius)
2017-06-24 14:41:57 +00:00
John Baldwin e0fc433218 MFC 319490: Remove stale cap_rights_get(2) manpage.
The documentation moved to section 3 several years ago, but
'man cap_rights_get' pulls up cap_rights_limit(2) (which is
MLINKed to cap_rights_get.2) instead of cap_rights_get(3).

Approved by:	re (gjb)
2017-06-20 15:55:15 +00:00
Konstantin Belousov c17118ea44 MFC r320035:
Move the description of kern.kq_calloutmax sysctl into a new paragraph
for better presentation.

Approved by:	re (delphij)
2017-06-19 07:15:47 +00:00
Konstantin Belousov 543da4d086 MFC r320034:
Start a new sentence on the new line.

Approved by:	re (delphij)
2017-06-19 06:48:21 +00:00
Allan Jude 68c019041c MFC r318765:
Allow cpuset_{get,set}affinity in capabilities mode

Approved by:	re (marius)
2017-06-11 02:04:39 +00:00
Edward Tomasz Napierala 7538684aaf MFC r318816:
Don't end up manpage titles with a full stop.

Approved by:	re (marius)
2017-06-06 09:23:12 +00:00
Xin LI 539882b22f MFC r319369:
* limit size of buffers to RPC_MAXDATASIZE
 * don't leak memory
 * be more picky about bad parameters

From:

https://raw.githubusercontent.com/guidovranken/rpcbomb/master/libtirpc_patch.txt
https://github.com/guidovranken/rpcbomb/blob/master/rpcbind_patch.txt

via NetBSD.

Approved by:	re (kib)
2017-06-06 07:21:33 +00:00
Eric van Gyzen c2aabae2a5 MFC r318582
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.

Sponsored by:	Dell EMC
2017-06-01 16:03:01 +00:00
Eric van Gyzen bfccc82170 MFC r318539 r318580 r318581 r318584 r318749 r318952 r318953 r318955
libthr: fix warnings at WARNS=6

Fix warnings about the following when WARNS=6 (which I will commit soon):

- casting away const
- no previous 'extern' declaration for non-static variable
- others as explained by #pragmas and comments
- unused parameters

libthr: disable thread-safety warnings

These warnings don't make sense for code that implements
the locking primitives.

libthr: change CHECK_AND_INIT_RWLOCK to an inline function

This was prompted by a compiler warning about 'ret' shadowing
a local variable in the callers of the macro.

libthr: Use CLI flags instead of pragmas to disable warnings

People tweaking the build system or compilers tend to look into
the Makefile and not into the source.  Having some warning controls
in the Makefile and some in the source code is surprising.

Pragmas have the advantage that they leave the warnings enabled
for more code, but that advantage isn't very relevant in these cases.

libthr: fix warnings from GCC when WARNS=6

Fix warnings about:
- redundant declarations
- a local variable shadowing a global function (dlinfo)
- an old-style function definition (with an empty parameter list)
- a variable that is possibly used uninitialized

libthr: prevent setcontext() from masking SIGTHR

__thr_setcontext() mistakenly tested for the presence of SIGCANCEL
in its local ucontext_t instead of the parameter. Therefore,
if a thread calls setcontext() with a context whose signal mask
contains SIGTHR (a.k.a. SIGCANCEL), that signal will be blocked,
preventing the thread from being cancelled or suspended.

Sponsored by:	Dell EMC
2017-06-01 14:49:53 +00:00
Konstantin Belousov af68e5af60 MFC r318450:
Add tests for some cases in r318298.

PR:	219154
2017-06-01 13:20:47 +00:00
Konstantin Belousov 65c662158f MFC r319086:
Mention that the basep argument to getdirentries(2) can be NULL.
2017-05-31 09:23:21 +00:00
Enji Cooper 6321504b1d MFC r319027,r319028,r319029,r319030,r319031,r319033,r319034,r319035,r319036,r319037,r319038,r319039,r319040,r319041,r319042,r319043,r319044,r319045,r319046:
r319027:

lib/libc/tests/nss: use calloc appropriately

The pattern used prior to this commit was `calloc(1, n * sizeof(type))`;
the pattern that should be used however is `calloc(n, sizeof(type))`.

r319028:

Sort make variables to suit style.Makefile(5)

This is being done prior to functional changes.

r319029:

Staticize functions and remove unused variables to aid with bumping WARNS

r319030:

Fix -Wsign-compare warnings

r319031:

getusershell_test: staticize run_tests(..) to fix warnings

r319033:

getserv_test: fix -Wsign-compare and -Wmissing-prototypes warnings

r319034:

getaddrinfo_test: fix -Wsign-compare warnings

r319035:

getrpc_test: fix -Wmissing-prototypes and -Wsign-compare warnings

r319036:

getproto_test: fix -Wmissing-prototypes and -Wsign-compare warnings

r319037:

getaddrinfo_test: mark unused function parameters __unused to fix -Wunused
warnings

r319038:

getusershell_test: mark mdata parameter in compare_usershell __unused

r319039:

getserv_test: mark unused parameters __unused to fix corresponding
warnings

r319040:

getrpc_test: fix -Wunused warnings

- Mark unused function parameters unused.
- Remove an unused function prototype.

r319041:

getproto_test: fix -Wunused warnings

Mark unused parameters __unused in functions.

r319042:

gethostby_test: fix multiple warning types

- Fix -Wmissing-declaration warning by staticizing run_tests.
- Fix -Wsign-compare warnings by casting size_t types to int
  for comparisons.

Reindent some of the code in sdump_hostent(..) to accomodate the
overall changes.

r319043:

getpw_test: fix -Wunused warnings

- Mark unused parameters __unused.
- Put dump_passwd under DEBUG as it's only used in that case.

r319044:

getgr_test: fix -Wunused warnings

r319045:

Fix -Wunused and -Wshadow warnings

r319046:

Fix a -Wunused-but-set-variable warning reported by gcc 6.3.0
2017-05-31 08:32:05 +00:00
Xin LI 4e19e4c1ec MFC r304106:
Add timingsafe_bcmp and timingsafe_memcmp.

Obtained from:	OpenBSD
Reviewed by:	trasz
2017-05-31 06:47:56 +00:00
Xin LI c2abfab509 MFC r318514-r318515, r318517, r318917
r318514:
Use size_t.

Inspired by:	OpenBSD src/lib/libc/stdlib/qsort.c,v 1.11

r318515:
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

r318517:
Sync qsort.c with userland r318515.

(Note that MIN macro is removed in favor of sys/param.h's version).

PR:		213922

r318917:
Disconnect heimdal version of qsort.c from build because we are already
using libc's version of qsort.

PR:		bin/213922
2017-05-31 05:52:32 +00:00
Xin LI 0e55484fe5 MFC r315272, r315370
r315272:
Implement INHERIT_ZERO for minherit(2).

INHERIT_ZERO is an OpenBSD feature.

When a page is marked as such, it would be zeroed
upon fork().

This would be used in new arc4random(3) functions.

PR:	182610
Reviewed by:	kib (earlier version)
Differential Revision:	https://reviews.freebsd.org/D427

r315370:
The adj_free and max_free values of new_entry will be calculated and
assigned by subsequent vm_map_entry_link(), therefore, remove the
pointless copying.

Submitted by:	alc
2017-05-31 05:10:03 +00:00