Commit Graph

17510 Commits

Author SHA1 Message Date
Warner Losh
2c0e9e2a09 Make armv6 hard float abi by default. Kill armv6hf.
Allow CPUTYPE=soft to build the current soft-float abi libraries.
Add UPDATING entry to announce this.

Approved by: re@ (gjb)
2016-05-18 06:01:18 +00:00
Warner Losh
da019dfdd5 Add support for %S to libstand as well so /boot/loader and friends can
use it.
2016-05-17 21:23:13 +00:00
Konstantin Belousov
2a339d9e3d Add implementation of robust mutexes, hopefully close enough to the
intention of the POSIX IEEE Std 1003.1TM-2008/Cor 1-2013.

A robust mutex is guaranteed to be cleared by the system upon either
thread or process owner termination while the mutex is held.  The next
mutex locker is then notified about inconsistent mutex state and can
execute (or abandon) corrective actions.

The patch mostly consists of small changes here and there, adding
neccessary checks for the inconsistent and abandoned conditions into
existing paths.  Additionally, the thread exit handler was extended to
iterate over the userspace-maintained list of owned robust mutexes,
unlocking and marking as terminated each of them.

The list of owned robust mutexes cannot be maintained atomically
synchronous with the mutex lock state (it is possible in kernel, but
is too expensive).  Instead, for the duration of lock or unlock
operation, the current mutex is remembered in a special slot that is
also checked by the kernel at thread termination.

Kernel must be aware about the per-thread location of the heads of
robust mutex lists and the current active mutex slot.  When a thread
touches a robust mutex for the first time, a new umtx op syscall is
issued which informs about location of lists heads.

The umtx sleep queues for PP and PI mutexes are split between
non-robust and robust.

Somewhat unrelated changes in the patch:
1. Style.
2. The fix for proper tdfind() call use in umtxq_sleep_pi() for shared
   pi mutexes.
3. Removal of the userspace struct pthread_mutex m_owner field.
4. The sysctl kern.ipc.umtx_vnode_persistent is added, which controls
   the lifetime of the shared mutex associated with a vnode' page.

Reviewed by:	jilles (previous version, supposedly the objection was fixed)
Discussed with:	brooks, Martin Simmons <martin@lispworks.com> (some aspects)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2016-05-17 09:56:22 +00:00
Don Lewis
41cee4e41b Fix off by one error in index limit calculation
Reported by:	Coverity
CID:		1193826
2016-05-16 15:42:59 +00:00
Don Lewis
30f6480075 Set retval in the empty password case to avoid a path through the
code that fails to set retval before falling through to the final
return().

Reported by:	emaste
Reported by:	Coverity
CID:		1018711
MFC after:	1 week
2016-05-16 15:32:02 +00:00
Jilles Tjoelker
4992013f8f libthr(3): Fix xref to _umtx_op(2) now that we have it. 2016-05-16 13:39:04 +00:00
Don Lewis
653d2f366d Hoist the getpwnam() call outside the first if/else block in
pam_sm_chauthtok().  Set user = getlogin() inside the true
branch so that it is initialized for the following PAM_LOG()
call.  This is how it is done in pam_sm_authenticate().

Reported by:	Coverity
CID:		272498
MFC after:	1 week
2016-05-16 08:34:17 +00:00
Don Lewis
705458afae Don't call free_addrselectpolicy(&policyhead) before policyhead has been
initialized.

Reported by:	Coverity
CID:		1018727
2016-05-16 08:13:30 +00:00
Don Lewis
0ee6da55a6 Since rdata is only used as an argument to the immediately following
call to res_nopt_rdata(), revert r299879 and fix CID 603941 by moving
	rdata = &buf[n];
inside the if block.

Reported by:	Coverity
CID:		603941
2016-05-16 01:38:24 +00:00
Don Lewis
0abffcb5f8 Likely a false positive ... but make sure that -1 can't be used as an
array index by splitting up a test.

Reported by:	Coverity
CID:		603941
MFC after:	1 week
2016-05-16 01:30:32 +00:00
Konstantin Belousov
d21ea7daaa Add thr*.2 and _umtx_op.2 manpages to the build.
Sponsored by:	The FreeBSD Foundation
2016-05-14 09:43:28 +00:00
Xin LI
20f8619da0 MFV r299716: file 5.27
MFC after:	2 weeks
Relnotes:	yes
2016-05-14 08:52:37 +00:00
Konstantin Belousov
10a21ce6a9 Document the non-obsoleted kernel interfaces used by libthr.
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D6335
2016-05-14 08:36:37 +00:00
Eric van Gyzen
079171874c iconvctl(3): remove superfluous NULL pointer tests
convname and dst are guaranteed to be non-NULL by iconv_open(3).
src is an array. Remove these tests for NULL pointers.
While I'm here, eliminate a strlcpy with a correct but suspicious-looking
calculation for the third parameter (i.e. not a simple sizeof).
Compare the strings in-place instead of copying.

Found by:	bdrewery
Found by:	Coverity
CID:		1130050, 1130056
MFC after:	3 days
Sponsored by:	Dell Inc.
Differential Revision:	 https://reviews.freebsd.org/D6338
2016-05-14 00:35:35 +00:00
Enji Cooper
47d106f97b Remove NO_WERROR from libbsnmp/Makefile.inc
This has been compiling without warnings with clang/gcc for a while now

Tested with: clang 3.8.0, gcc 4.2.x, gcc 5.x
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-13 21:17:49 +00:00
Enji Cooper
32855711ef Read the contents of the snapshot files properly
- Use fgetln instead of fgets; localize complexity related to fgetln(3)
  inside the loop.
- Skip over blank lines.
- Skip over lines (properly) that start with a "#"

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-13 10:52:02 +00:00
Jason Evans
1f0a49e863 Update jemalloc to 4.2.0. 2016-05-13 04:03:20 +00:00
Don Lewis
4238b561f0 Use strlcpy() instead of strncpy() to ensure that qf->fsname is NUL
terminated.  Don't bother checking for truncation since the subsequent
stat() call should detect that and fail.

Reported by:	Coverity
CID:		1018189
MFC after:	1 week
2016-05-13 00:26:14 +00:00
Conrad Meyer
1deb20f631 libc: Actually export fopencookie(3)
A follow-up to r299456.

Sponsored by:	EMC / Isilon Storage Division
2016-05-12 21:30:22 +00:00
Martin Matuska
cdf63a700c MFV r299425:
Update libarchive to 3.2.0

New features:
- new bsdcat command-line utility
- LZ4 compression (in src only via external utility from ports)
- Warc format support
- 'Raw' format writer
- Zip: Support archives >4GB, entries >4GB
- Zip: Support encrypting and decrypting entries
- Zip: Support experimental streaming extension
- Identify encrypted entries in several formats
- New --clear-nochange-flags option to bsdtar tries to remove noschg and
  similar flags before deleting files
- New --ignore-zeros option to bsdtar to handle concatenated tar archives
- Use multi-threaded LZMA decompression if liblzma supports it
- Expose version info for libraries used by libarchive

Patched files (fixed compiler warnings):

contrib/libarchive/cat/bsdcat.c (vendor PR #702)
contrib/libarchive/cat/bsdcat.h (vendor PR #702)
contrib/libarchive/libarchive/archive_read_support_format_mtree.c (PR #701)
contrib/libarchive/libarchive_fe/err.c (vendor PR #703)

MFC after:	1 month
Relnotes:	yes
2016-05-12 10:16:16 +00:00
Don Lewis
77b822dbc0 Use strlcpy() instead of strncpy() to copy the string returned by
setlocale() so that static analyzers know that the string is NUL
terminated.  This was causing a false positive in Coverity even
though the longest string returned by setlocale() is ENCODING_LEN
(31) and we are copying into a 64 byte buffer.  This change is also
a bit of an optimization since we don't need the strncpy() feature
of padding the rest of the destination buffer with NUL characters.

Reported by:	Coverity
CID:		974654
2016-05-12 06:39:13 +00:00
Conrad Meyer
83095e1ee2 print_positional_test: Fix misuse of wchar APIs
These APIs take unit length, not byte length parameters.

Reported by:	Coverity
CIDs:		1338543, 1338544, 1338545
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 04:08:45 +00:00
Conrad Meyer
d0725e2250 libmp: Fix trivial buffer overrun
fgetln yields a non-NUL-terminated buffer and its length.  This routine
attempted to NUL-terminate it, but did not allocate space for the NUL.  So,
allocate space for the NUL.

Reported by:	Coverity
CID:		1017457
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 03:53:20 +00:00
Conrad Meyer
a03cc61df4 nss/gethostby_test: fix broken vector iteration of gethostbyaddr h_aliases
h_aliases is a NULL-terminated rather than fixed-length array.  nitems() is not
a valid way to determine its end; instead, check for NULL.

Reported by:	Coverity
CID:		1346578
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 02:32:23 +00:00
Conrad Meyer
877a840c08 libc: Add fopencookie(3) wrapper around funopen(3)
Reviewed by:	jhb, oshogbo
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D6282
2016-05-11 14:38:27 +00:00
Pedro F. Giffuni
f90a20b4b8 librpcsec_gss: remove redundant code.
We have identical code no matter the expression behind the if.
Avoid the desision altogether and keep doing what is expected.

Reviewed by:	dfr
CID:		1305689
2016-05-11 14:37:33 +00:00
Baptiste Daroussin
32fefb2495 Rename dprintf into dbg_printf to avoid collision with dprintf(3)
When dprintf(3) in 2009 was added a _WITH_DPRINTF guard has also been added.
This rename is made in preparation for the removal of this guard
2016-05-10 07:45:44 +00:00
Bryan Drewery
29df9f6b75 DIRDEPS_BUILD: Run the staged bootstrap-tools version of build-tools.
This avoids running target binaries.

Sponsored by:	EMC / Isilon Storage Division
2016-05-09 22:21:09 +00:00
Pedro F. Giffuni
89017bc259 libc/xdr: unsign some loop indexes.
Although usually small, values produced by nitems() are unsigned.
Unsign inxdeing variables related to nitems() macros to avoid
signed vs. unsigned comparisons.
2016-05-06 16:03:40 +00:00
Ed Maste
c43c22982e Limit Options.inc generation to desired targets
As mentioned in the Makefile there's an "atrocious" hack to generate a
different version of Options.inc.h, depending on the library being
built.

Remove the catch-all else case and limit it to specific libraries, so
that we don't accidentally use the Options.inc.h from clangdriver if a
future libary also uses Options.inc.h.

Reviewed by:	dim
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6209
2016-05-05 21:20:09 +00:00
Konstantin Belousov
321e2a0090 Do not leak THR_FLAGS_SUSPENDED from the previous suspend/resume
cycle.  The flag currently is cleared by the resumed thread.  If next
suspend request comes before the thread was able to clean the flag, in
which case suspender skip the thread.

Instead, clear the THR_FLAGS_SUSPEND flag in resume_common(), we do
not care how much code was executed in the resumed thread when the
pthread_resume_*np(s) functions returned.

PR:	209233
Reported by:	Lawrence Esswood <le277@cam.ac.uk>
MFC after:	1 week
2016-05-05 10:20:22 +00:00
Enji Cooper
430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Alan Somers
8907f744ff Improve performance and functionality of the bitstring(3) api
Two new functions are provided, bit_ffs_at() and bit_ffc_at(), which allow
for efficient searching of set or cleared bits starting from any bit offset
within the bit string.

Performance is improved by operating on longs instead of bytes and using
ffsl() for searches within a long. ffsl() is a compiler builtin in both
clang and gcc for most architectures, converting what was a brute force
while loop search into a couple of instructions.

All of the bitstring(3) API continues to be contained in the header file.
Some of the functions are large enough that perhaps they should be uninlined
and moved to a library, but that is beyond the scope of this commit.

sys/sys/bitstring.h:
        Convert the majority of the existing bit string implementation from
        macros to inline functions.

        Properly protect the implementation from inadvertant macro expansion
        when included in a user's program by prefixing all private
        macros/functions and local variables with '_'.

        Add bit_ffs_at() and bit_ffc_at(). Implement bit_ffs() and
        bit_ffc() in terms of their "at" counterparts.

        Provide a kernel implementation of bit_alloc(), making the full API
        usable in the kernel.

        Improve code documenation.

share/man/man3/bitstring.3:
        Add pre-exisiting API bit_ffc() to the synopsis.

        Document new APIs.

        Document the initialization state of the bit strings
        allocated/declared by bit_alloc() and bit_decl().

        Correct documentation for bitstr_size(). The original code comments
        indicate the size is in bytes, not "elements of bitstr_t". The new
        implementation follows this lead. Only hastd assumed "elements"
        rather than bytes and it has been corrected.

etc/mtree/BSD.tests.dist:
tests/sys/Makefile:
tests/sys/sys/Makefile:
tests/sys/sys/bitstring.c:
        Add tests for all existing and new functionality.

include/bitstring.h
	Include all headers needed by sys/bitstring.h

lib/libbluetooth/bluetooth.h:
usr.sbin/bluetooth/hccontrol/le.c:
        Include bitstring.h instead of sys/bitstring.h.

sbin/hastd/activemap.c:
        Correct usage of bitstr_size().

sys/dev/xen/blkback/blkback.c
        Use new bit_alloc.

sys/kern/subr_unit.c:
        Remove hard-coded assumption that sizeof(bitstr_t) is 1.  Get rid of
        unrb.busy, which caches the number of bits set in unrb.map.  When
        INVARIANTS are disabled, nothing needs to know that information.
        callapse_unr can be adapted to use bit_ffs and bit_ffc instead.
        Eliminating unrb.busy saves memory, simplifies the code, and
        provides a slight speedup when INVARIANTS are disabled.

sys/net/flowtable.c:
        Use the new kernel implementation of bit-alloc, instead of hacking
        the old libc-dependent macro.

sys/sys/param.h
        Update __FreeBSD_version to indicate availability of new API

Submitted by:   gibbs, asomers
Reviewed by:    gibbs, ngie
MFC after:      4 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D6004
2016-05-04 22:34:11 +00:00
Konstantin Belousov
6e745eeddd Correct wording.
Submitted by:	David A. Bright
MFC after:	2 weeks
2016-05-03 15:58:35 +00:00
Konstantin Belousov
c89e1b8739 Add EVFILT_VNODE open, read and close notifications.
While there, order EVFILT_VNODE notes descriptions alphabetically.

Based on submission, and tested by:	Vladimir Kondratyev <wulf@cicgroup.ru>
MFC after:	2 weeks
2016-05-03 15:17:43 +00:00
Konstantin Belousov
f7b71c8a5b Issue NOTE_EXTEND when a directory entry is added to or removed from
the monitored directory as the result of rename(2) operation.  The
renames staying in the directory are not reported.

Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>
MFC after:	2 weeks
2016-05-02 13:18:17 +00:00
Konstantin Belousov
ba55e112c2 As a reader service, explain NOTE_LINK reporting for the directories.
Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>
MFC after:	1 week
2016-05-01 20:54:29 +00:00
Pedro F. Giffuni
75f46cf6c8 lib: minor spelling fixes in comments.
No functional change.
2016-05-01 19:37:33 +00:00
Benedict Reuschling
8c231786f0 Provide an example to the kqueue man page, showing
a basic usage example.  Although it is an
untypical example for the use of kqueue, it is
better than nothing and should get people started.

PR:			196844
Submitted by:		fernando.apesteguia@gmail.com
Reviewed by:		kib
Approved by:		kib
MFC after:		5 days
Differential Revision:	https://reviews.freebsd.org/D6082
2016-05-01 18:09:34 +00:00
Ed Schouten
e33d251e8e Remove useless calls to basename().
There are a couple of places in the source three where we call
basename() on constant strings. This is bad, because the prototype
standardized by POSIX allows the implementation to use its argument as a
storage buffer.

This change eliminates some of these unportable calls to basename() in
cases where it was only added for cosmetical reasons, namely to trim
argv[0]. There's nothing wrong with setting argv[0] to the full path.

Reviewed by:	jilles
Differential Revision:	https://reviews.freebsd.org/D6093
2016-05-01 08:22:11 +00:00
Enji Cooper
8b4e5ab944 Don't leak PML4 in _amd64_initvtop(..) if kvm_read2(..) fails
MFC after: 1 week
Reported by: Coverity
CID: 1341474
Sponsored by: EMC / Isilon Storage Division
2016-04-30 09:32:19 +00:00
Enji Cooper
9bc9176923 Remove a -Wunused-but-set-variable variable -- pa
Reported by: gcc 5.x
Sponsored by: EMC / Isilon Storage Division
2016-04-30 09:31:01 +00:00
Enji Cooper
7aad67e9ca Remove kvm_getfiles(3)
This libcall has been broken since (at least) r174989/8.0-RELEASE.

Bump SHLIB_MAJOR for the change

Differential Revision: https://reviews.freebsd.org/D6052
Relnotes: yes
Reviewed by: jhb, markj
Sponsored by: EMC / Isilon Storage Division
2016-04-30 09:21:13 +00:00
Enji Cooper
68b68bf55d Fix memory allocation edgecases in kvm_argv(..)
- Don't leak nbufp on realloc failure in kvm_argv
- Catch malloc errors with bufp
- Set buflen last in the "buflen == 0" case to ensure that
  bufp/nbufp is properly reallocated on the next go around

Differential Revision: https://reviews.freebsd.org/D6051
MFC after: 1 week
Reviewed by: jhb, markj
Reported by: cppcheck
Sponsored by: EMC / Isilon Storage Division
2016-04-30 09:13:26 +00:00
Pedro F. Giffuni
32223c1b7d libc: spelling fixes.
Mostly on comments.
2016-04-30 01:24:24 +00:00
Glen Barber
49dae58b28 Fix including Kyuafile in packaged base system.
Fix a related typo while here.

Note, this change results in the Kyuafile inclusion in the runtime
package, which needs to be fixed, however addresses the PR as far
as I can tell in my tests.

PR:		209114
Submitted by:	ngie
Sponsored by:	The FreeBSD Foundation
2016-04-29 05:28:40 +00:00
Enji Cooper
2357dac430 Fix va_list handling
- Add missing va_end's after corresponding va_start's to cleanup state
- Eliminate questionable bzero'ing of va_list passed in to
  do_buff_decode(..) and do_encode(..) from buff_{de,en}code_visit(..)
  and csio_{de,en}code_visit(..). Make va_list a pointer instead and
  pass NULL into the underlying functions to handler this in a portable
  way.
- Do some minor style(9) clean up in affected functions.

Differential Revision: https://reviews.freebsd.org/D6072
MFC after: 3 days
Reported by: cppcheck, Coverity
CID: 1018500-1018503
Reviewed by: cem
Sponsored by: EMC / Isilon Storage Division
2016-04-28 18:41:55 +00:00
John Baldwin
88eb5c506d Add 'devctl delete' that calls device_delete_child().
'devctl delete' can be used to delete a device that is no longer present.
As an anti-foot-shooting measure, 'delete' will not delete a device
unless it's parent bus says it is no longer present.  This can be
overridden by passing the force ('-f') flag.

Note that this command should be used with care.  If a device is deleted
that is actually present it can't be resurrected unless the parent bus
device's driver supports rescans.

Differential Revision:	https://reviews.freebsd.org/D6019
2016-04-27 16:33:17 +00:00
John Baldwin
a907c6914c Add a new rescan method to the bus interface.
The BUS_RESCAN() method rescans a single bus device checking for devices
that have been added or removed from the bus.  A new 'rescan' command is
added to devctl(8) to trigger a rescan.

Differential Revision:	https://reviews.freebsd.org/D6016
2016-04-27 16:29:03 +00:00
Pedro F. Giffuni
1c5fd754bd libcuse: make more use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 01:20:16 +00:00