Commit Graph

8373 Commits

Author SHA1 Message Date
Conrad Meyer
0a8ff54eb1 scandir: Fix NULL dereference, uninitialized value use in error case
If opendir succeeds but malloc fails, numitems was used uninitialized in
error handling under the 'fail' label.  If it happened to have a non-zero
value, the NULL 'names' was dereferenced.

Reported by:	Coverity
CIDs:		1329566, 1372625
Sponsored by:	Dell EMC Isilon
2017-03-22 17:37:47 +00:00
Eric van Gyzen
16fe28bb9f clock_gettime.2: add some clock IDs
Add the CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID clock_id
values to the clock_gettime(2) man page.  Reformat the excessively
long paragraph (sentence!) into a tag list.

Reported by:	jilles in https://reviews.freebsd.org/D10020
MFC after:	3 days
Sponsored by:	Dell EMC
2017-03-22 00:50:36 +00:00
Enji Cooper
fd752a71ce Don't build/install lib/libc/io_test anymore
The failing test requires the zh_TW.Big5 locale, which is no longer
installed as of r315568.

Add a note/pointer just in case someone considers re-adding it.

Reported by:	Jenkins
Sponsored by:	Dell EMC Isilon
2017-03-20 03:50:22 +00:00
Xin LI
73065ae826 Make space style consistent with earlier entries.
X-MFC with:	r315526
2017-03-20 03:47:15 +00:00
Eric van Gyzen
3f8455b090 Add clock_nanosleep()
Add a clock_nanosleep() syscall, as specified by POSIX.
Make nanosleep() a wrapper around it.

Attach the clock_nanosleep test from NetBSD. Adjust it for the
FreeBSD behavior of updating rmtp only when interrupted by a signal.
I believe this to be POSIX-compliant, since POSIX mentions the rmtp
parameter only in the paragraph about EINTR. This is also what
Linux does. (NetBSD updates rmtp unconditionally.)

Copy the whole nanosleep.2 man page from NetBSD because it is complete
and closely resembles the POSIX description. Edit, polish, and reword it
a bit, being sure to keep any relevant text from the FreeBSD page.

Reviewed by:	kib, ngie, jilles
MFC after:	3 weeks
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D10020
2017-03-19 00:51:12 +00:00
Ed Maste
01dc206b22 libc: add reference to two-way algorithm and bad shift table in memmem/strstr
Requested by:	ed
2017-03-18 00:53:24 +00:00
Ed Maste
88521634e9 libc: Use musl's O(n) memmem and strstr
It is O(n) in the length of the haystack (big) string, and has special
cases for short needle (little) strings, of one to four bytes, to avoid
excessive overhead.

There are a small set of nearly trivial cases where the startup overhead
of the musl implementation makes it slightly slower -- for example, a 31
byte needle that matches the beginning of the haystack.  It's faster for
non-trivial cases, and significantly so for inputs that trigger worst-
case behaviour of the previous implementation.  As an example, in my
tests a 16K needle that matches the end of a 64K haystack is nearly
2000x faster with this implementation.

Reviewed by:	bapt (earlier), ed (earlier)
Obtained from:	musl (snapshot at commit c718f9fc)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D2601
2017-03-18 00:51:39 +00:00
Brooks Davis
d6aa8a03f2 Replace SOFTFLOAT with __mips_soft_float, which gcc/clang define for us.
D8376 extended softfloat/hardfloat support, but used a macro that never
actually gets set except in libc and msun's Makefile.inc.  So libc and libm
got built correctly, but any program including fenv.h itself assumed it was
on a hardfloat systen and emitted inline fpu instructions for
fedisableexcept() and friends.

Using __mips_soft_float makes everything work in all cases, since it's a
compiler-internal macro that is always set correctly for the target

PR:		217845
Submitted by:	Dan Nelson <dnelson_1901@yahoo.com>
MFC after:	1 week
2017-03-16 21:05:21 +00:00
Maxim Konovalov
a6c1047fce More trap_enotcap spelling fixes.
PR:		217839
Submitted by:	tobik
2017-03-16 13:19:38 +00:00
Maxim Konovalov
f24fc4834a Spell kern.trap_enotcap.
PR:		217836
Submitted by:	tobik
2017-03-16 12:16:23 +00:00
Xin LI
78d7964b46 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)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D427
2017-03-14 17:10:42 +00:00
Xin LI
91868665a9 Discard first 3072 bytes of RC4 keystream, this is a bandaid
that allows us to work on switching to a more modern PRNG.

Submitted by:	Steven Chamberlain <steven pyro eu org>
Approved by:	so
2017-03-14 06:00:44 +00:00
Pedro F. Giffuni
e449183c70 Minor libc cleanup: let calloc(3) do the multiplication.
MFC after:	3 days
2017-03-13 04:14:03 +00:00
Pedro F. Giffuni
9f36610f9e libc: provide some bounds-checking through reallocarray(3).
reallocarray(3) is a non portable extension that originated in OpenBSD.
Given that it is already in FreeBSD's libc it is useful for the cases
where reallocation involves a multiplication.

MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D9955
2017-03-12 16:03:34 +00:00
Pedro F. Giffuni
97721eb583 libc: small cleanup.
Initialize newsize in the code section so we avoids asigning the
value if we exit early.
2017-03-12 03:50:13 +00:00
Pedro F. Giffuni
3c72899a8e libc: small cleanups.
Remove unused initialization: "num" is properly defined before use.

Reviewed by:	ngie
MFC after:	3 days
2017-03-12 03:29:23 +00:00
Pedro F. Giffuni
ada469063f libc: small cleanups.
Unsign setlen: it is local and will never be negative. Having one more bit
for growth is beneficial and it avoids a cast when it's going to be used
for allocation.

Reviewed by:	ngie
MFC after:	3 days
2017-03-12 03:26:25 +00:00
Pedro F. Giffuni
56362c6f81 libc: small cleanups.
Rename nitems to numitems: it shares the anme with an existing macro in
sys/params.h. Also initialize the value later which avoids asigning the
value if we exit early.

Reviewed by:	ngie
MFC after:	3 days
2017-03-12 03:22:18 +00:00
Alan Somers
5a5a9018dc Increase WARNS for nss tests
ATF tests have a default WARNS of 0, unlike other usermode programs.

Reviewed by:  ngie
MFC after:    3 weeks
Sponsored by: Spectra Logic Corporation
Differential Revision:        https://reviews.freebsd.org/D9933
2017-03-11 00:03:41 +00:00
Alan Somers
b08fc26cbd Increase WARNS for iconv tests
ATF tests have a default WARNS of 0, unlike other usermode programs.

Reviewed by:	ngie
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corporation
Differential Revision:	https://reviews.freebsd.org/D9933
2017-03-11 00:02:05 +00:00
Enji Cooper
13876dc982 style(9): sort the #includes
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-09 09:25:11 +00:00
Enji Cooper
7532a6570b Move ATF_TC_WITHOUT_HEAD(getgrent) near the testcase it annotates
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-06 22:46:49 +00:00
Conrad Meyer
8844cec8f3 fts: Fix a potential memory leak in error case
Dan Krejsa reports a potential memory leak in an fts_build error case,
detected by Coverity.  (It doesn't seem to show up in Coverity Scan, so I
don't have a CID to point to.)

I don't know whether it is actually possible to arrive in this case with a
non-empty 'head' list.  The cost is low, though.  One additional branch in a
terminal error case isn't the end of the world.

PR:		217125
Submitted by:	Dan Krejsa <dan.krejsa at gmail.com>
2017-03-04 20:46:57 +00:00
Dimitry Andric
ed085b68ab Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
4.0.0 (branches/release_40 296509).  The release will follow soon.

Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.

Also note that as of 4.0.0, lld should be able to link the base system
on amd64 and aarch64.  See the WITH_LLD_IS_LLD setting in src.conf(5).
Though please be aware that this is work in progress.

Release notes for llvm, clang and lld will be available here:
<http://releases.llvm.org/4.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/4.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/4.0.0/tools/lld/docs/ReleaseNotes.html>

Thanks to Ed Maste, Jan Beich, Antoine Brodin and Eric Fiselier for
their help.

Relnotes:	yes
Exp-run:	antoine
PR:		215969, 216008
MFC after:	1 month
2017-03-02 20:49:40 +00:00
Brooks Davis
af4157ef72 Garbage collect unused gdtoa related files on mips.
Reviewed by:	emase, imp, jhb
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9841
2017-03-02 17:08:37 +00:00
Brooks Davis
13f2393362 Correct an misunderstanding of MDSRCS.
MDSRCS it intended to allow assembly versions of funtions with C
implementations listed in MISRCS. The selection of the correct
machdep_ldis?.c for a given architecture does not follow this pattern
and the file should be added to SRCS directly.

Reviewed by:	emaste, imp, jhb
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9841
2017-03-02 17:07:28 +00:00
Brooks Davis
9fe44df287 Correct MDSRCS use in <arch>/string/Makefile.inc.
- Remove .c files which duplicate entries in MISRCS.
- Use the same, less merge conflict prone style in all cases.
- Use MDSRCS for mips (.c and .S files both ended up in SRCS).
- Remove pointless sparc64 Makefile.inc.
- Remove uninformative foreign VCS ID entries.

Reviewed by:	emaste, imp, jhb
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9841
2017-03-02 17:05:52 +00:00
Dimitry Andric
348238dbd4 Merge ^/head r314420 through r314481. 2017-03-01 08:22:51 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Eric van Gyzen
81027fa594 Sort declaration of sem_clockwait_np
Also mention <time.h> in sem_timedwait(3), because POSIX does,
and because the user will need it for clockid_t, struct timespec,
and TIMER_ABSTIME.

Reported by:	bde
MFC after:	9 days
X-MFC with:	r314179
Sponsored by:	Dell EMC
2017-02-28 21:47:00 +00:00
Dimitry Andric
be64968040 Merge ^/head r314270 through r314419. 2017-02-28 21:30:26 +00:00
Gleb Smirnoff
efe3b0de14 Remove SVR4 (System V Release 4) binary compatibility support.
UNIX System V Release 4 is operating system released in 1988. It ceased
to exist in early 2000-s.
2017-02-28 05:14:42 +00:00
Mariusz Zaborski
b62c1f2b18 Remove unneeded variable initialization from r314319.
Pointed out by:	kib
2017-02-26 22:15:39 +00:00
Mariusz Zaborski
ba1b663656 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.

Reviewed by:	kib
2017-02-26 22:07:26 +00:00
Dimitry Andric
d630701f86 Merge ^/head r314178 through r314269. 2017-02-25 15:04:19 +00:00
Eric van Gyzen
b215ceaaec Add sem_clockwait_np()
This function allows the caller to specify the reference clock
and choose between absolute and relative mode.  In relative mode,
the remaining time can be returned.

The API is similar to clock_nanosleep(3).  Thanks to Ed Schouten
for that suggestion.

While I'm here, reduce the sleep time in the semaphore "child"
test to greatly reduce its runtime.  Also add a reasonable timeout.

Reviewed by:	ed (userland)
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D9656
2017-02-23 19:36:38 +00:00
Dimitry Andric
6ae9acde63 Merge ^/head r313896 through r314128. 2017-02-23 07:45:58 +00:00
Eric van Gyzen
90c1b723a5 Make several improvements and corrections in the kenv(2) man page
MFC after:	3 days
Sponsored by:	Dell EMC
2017-02-21 19:51:41 +00:00
Dimitry Andric
a3906ca572 Merge ^/head r313644 through r313895. 2017-02-17 20:19:38 +00:00
Michal Meloun
d98d230378 Publish fp[get][set]sticky() for ARMv6.
Although fp[get][set]sticky() functions are obsolete, they are still
required for GNU fortran49 library.

MFC after: 2 months
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D9634
2017-02-17 13:49:46 +00:00
Michal Meloun
cd9bdb7362 Publish __aeabi_uidiv and __aeabi_idiv as compatible symbols from libc.
Due to bug[1] in libcompiler_rt, all symbols declared by
DEFINE_AEABI_FUNCTION_ALIAS() are not hidden. All these but two
are explicitly exported from libc and don't causes problems.

Remaining two, __aeabi_uidiv and __aeabi_idiv, infecting all
non-versioned shared libraries. And these symbols are consumed
by many (if not all) packages[2].

As workaround, export these from libc as compatible symbols,
in global namespace. With this, these are still visible for
rtld, but static linker doesn't use then.

[1]
DEFINE_AEABI_FUNCTION_ALIAS() macro uses '.set' directive for
declaration of aliased symbol. Unfortunately, '.set' doesn't
inherit visibility of base symbol, and macro don't explicitly
sets visibility for aliased one.

[2]
Given symbols are exported from non-versioned libraries only if
library itself uses them. So, if world is built for CPU with
HW divide, these function are not used and given symbols are
not exported. By this, contents of these libraries is not stable,
and all packages fails to run.

Note: Due to r313823 I'm forced to commit this too early, without
leave enough time for proper review.

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D9632
2017-02-17 11:16:19 +00:00
Ed Schouten
8eb15797b1 Remove unnecessary #includes from the kqueue(2) man page.
Now that <sys/event.h> can be included on its own, adjust the manual
page accordingly. Remove both unnecessary #include statements from the
synopsis and the example code.

While there, also add a note to the BUGS section to mention that
previous versions of this header file still depend on <sys/types.h>.

Reviewed by:	ngie, vangyzen
Differential Revision:	https://reviews.freebsd.org/D9605
2017-02-16 06:52:53 +00:00
Mark Johnston
661c4fe512 Fix indentation in nss_configure().
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-02-14 21:55:50 +00:00
Mark Johnston
888e46a99b Register nss_atexit() before parsing nsswitch.conf for the first time.
NSS modules are loaded when nsswitch.conf is parsed and may register their
own atexit handlers with libc. nss_atexit() unloads any dynamically loaded
NSS modules, so it should run only after the modules' atexit handlers have
been invoked.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-02-14 21:51:19 +00:00
Dimitry Andric
c9117188c5 For now, compile all of contrib/gdtoa without requiring strict aliasing,
since it is using type punning of union members, and clang does not yet
support gcc's extensions which allow this (refer to
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Type%2dpunning
for more information).

This should fix strtod(3) return values for the lang/julia port, so it
does not fail on an assertion during its build.

PR:		216770
2017-02-13 20:13:29 +00:00
Konstantin Belousov
987ff18184 Consistently handle negative or wrapping offsets in the mmap(2) syscalls.
For regular files and posix shared memory, POSIX requires that
[offset, offset + size) range is legitimate.  At the maping time,
check that offset is not negative.  Allowing negative offsets might
expose the data that filesystem put into vm_object for internal use,
esp. due to OFF_TO_IDX() signess treatment.  Fault handler verifies
that the mapped range is valid, assuming that mmap(2) checked that
arithmetic gives no undefined results.

For device mappings, leave the semantic of negative offsets to the
driver.  Correct object page index calculation to not erronously
propagate sign.

In either case, disallow overflow of offset + size.

Update mmap(2) man page to explain the requirement of the range
validity, and behaviour when the range becomes invalid after mapping.

Reported and tested by:	royger (previous version)
Reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2017-02-12 21:05:44 +00:00
Enji Cooper
99b33ca4ec Manipulate OBJDIR with :H when referencing dso directory
This reduces path lengths, etc in memory with make by a minimal value

Sponsored by:	Dell EMC Isilon
2017-02-11 20:14:50 +00:00
Enji Cooper
a678f77962 MFhead@r313380 2017-02-07 06:04:13 +00:00
Enji Cooper
9a41ce4a69 Expect :int_within_limits to fail when ptrdiff_t/*intmax_t differ in base type
The %t{d,u} (ptrdiff_t) tests fail for the following reasons:
- ptrdiff_t is by definition int32_t on !LP64 architectures and int64_t on
  LP64 architectures.
- intmax_t is by definition fixed to int64_t on all architectures.
- Some of the code in lib/libc/stdio/... is promoting ptrdiff_t to *intmax_t
  when parsing/representing the value.

PR:		191674
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-02-07 05:39:00 +00:00
Enji Cooper
1eca9a9a49 Wrap strcmp/wcscmp calls with ATF_CHECK_MSG and drop atf_tc_fail use
The reasoning here was the same as what was done in r313376:
- Gather as many results as possible instead of failing early and
  not testing the rest of the cases.
- Simplify logic when checking test inputs vs outputs and printing
  test result.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-02-07 04:25:21 +00:00