Commit Graph

18493 Commits

Author SHA1 Message Date
Alexander Kabaev
3b29339863 Add missing double quote to fix r316635 commit. 2017-04-09 03:50:48 +00:00
Xin LI
7250d89e54 Enable 16-bit longest_match for x86.
This gives a ~2% improvement in compression tests.

MFC after:	2 weeks
2017-04-08 06:39:13 +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
John Baldwin
5944f899a2 Rework r234502 to include a modified CFLAGS along with ACFLAGS.
On most architectures crt objects are compiled in a multiple-step process
so that sed can be run on the generated assembly.  As the final step,
the C compiler generates an object file from the modified assembly output.
Currently this last step uses $CC with only $ACFLAGS.  However, for other
uses in the tree, $ACFLAGS is meant to include assembly-specific compiler
flags that are in addition to $CFLAGS (see default .S.o rules
bsd.suffixes.mk).  In particular, external toolchains may require
additional flags to select a non-default target which will be present
in CFLAGS but not ACFLAGS.  To support this while still mitigating the
issue with CFLAGS described in r234502, include a modified CFLAGS that
excludes "-g" when assembling the modified assembly files.

Note that normally an assembler ($AS) is used to assemble .s flags to
object files (see bsd.suffixes.mk).  However, llvm-based toolchains do
not currently have a stand-alone assembler.

Reviewed by:	imp
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D10085
2017-04-07 19:53:14 +00:00
Enji Cooper
79a9c323e0 pmc_read(3): fix manlint error
Remove spurious trailing comma from last .Nm entry in NAME section.

MFC after:	2 months
Sponsored by:	Dell EMC Isilon
2017-04-07 06:06:55 +00:00
Enji Cooper
15cfc11d85 pmc.atomsilvermont(3): fix manlint warnings
Start new sentences on new lines.

Sentences affected by the change are wrapped at <80 columns. Other
potentially offending lines have been left alone to reduce churn.

MFC after:	2 months
Sponsored by:	Dell EMC Isilon
2017-04-07 06:00:19 +00:00
Enji Cooper
7a40330b95 pmc(3): add additional references for libpmc functions in the SEE ALSO section
These functions are already referenced throughout the manpage -- this makes their
presence more apparent.

MFC after:	2 months
Sponsored by:	Dell EMC Isilon
2017-04-07 05:46:45 +00:00
Toomas Soome
3949295f36 libstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memory
Current implementation of dosfs in libstand reads full File Allocation Table to
the RAM in the initialization code. In the extreme case of FAT32 filesystem,
this structure will take up to 256-1024 Mb of loader memory, depending on the
cluster size.

Proposed patch reduces libstands/dosfs memory requirements to 128 Kb for all
variants of dosfs filesystem. For FAT12 and FAT16 filesystems, File Allocation
Table is cached in full, as before. For FAT32, File Allocation Table is broken
into the equal blocks of 128 Kilobytes (32768 entries), and only current block
is cached.

Because per-filesystem context is now small, global FAT cache (for all
instances of dosfs filesystem) is replaced by local per-instance cache.

Submitted by:	Mikhail.Kupchik_gmail.com
Reviewed by:	tsoome, allanjude
Differential Revision:	https://reviews.freebsd.org/D9547
2017-04-06 20:12:39 +00:00
Toomas Soome
ffd08eb064 loader: want mechanism to avoid RA with bcache
While we have mechanisms in place to protect ourselves against the read
behind the disk end, there is still one corner case. As the GPT
partition table has backup table at the end of the disk, and we yet
do not know the size of the disk (if the wrong size is provided by the
firmware/bios), we need to limit the reads to avoid read ahead in such case.

Note: this update does add constant into stand.h, so the incremental build
will need to get local stand.h updated first.

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D10187
2017-04-06 15:57:53 +00:00
Ed Maste
df9489689d libnetbsd: add emalloc and friends
These are error-checked versions of memory allocation routines used by
NetBSD code, and are being added to facilitate updates to makefs.

Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D10291
2017-04-06 14:36:08 +00:00
Enji Cooper
0e6acb2653 Use __FBSDID instead of the license agreement to embed the $FreeBSD$ RCS keyword
Reminded by a comment made by markj w.r.t. using __FBSDID in .c files ala a
past Phabricator review.

MFC after:	2 months
Sponsored by:	Dell EMC Isilon
2017-04-06 05:36:35 +00:00
Enji Cooper
b824378b14 sbuf(3): add some basic functional tests for the library
Areas not covered still [positive functionality wise] are:
- sbuf_{clear,get,set}_flags
- sbuf_new (in particular, with fixed buffers, etc).

Some basic negative testing has been added, but more will be added in the
future.

This work was in part to validate work done by cem in r288223, and ian
before that.

MFC after:	2 months
Sponsored by:	Dell EMC Isilon
2017-04-06 05:29:28 +00:00
Enji Cooper
fa602b5bd0 sbuf(3): expose sbuf_{clear,get,set}_flags(3) via libsbuf
These functions were added to sbuf(9) in r279992, but never
exposed to userspace. Expose them now so they can be used/tested.

MFC after:	2 months
Sponsored by:	Dell EMC Isilon
2017-04-06 04:58:51 +00:00
John Baldwin
813b8a9e89 Add an implementation of __ffssi2() derived from __ffsdi2().
Newer versions of GCC include an __ffssi2() symbol in libgcc and the
compiler can emit calls to it in generated code.  This is true for at
least GCC 6.2 when compiling world for mips and mips64.

Reviewed by:	jmallett, dim
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D10086
2017-04-05 02:40:53 +00:00
Edward Tomasz Napierala
ab38e32db6 Fix typo.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-04-03 20:35:17 +00:00
Allan Jude
9f67bd210a Add explicit_bzero() to libstand, and switch GELIBoot to using it
Make sure sensitive memory is properly cleared when finished with it

Reviewed by:	Eric McCorkle <eric@metricspace.net>
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D9798
2017-03-31 00:04:32 +00:00
Tycho Nightingale
a4ba650262 Reorder includes to placate MIPS build.
Reported by:	markj
Sponsored by:	Dell EMC Isilon
2017-03-30 20:42:16 +00:00
Toomas Soome
cb83812c70 Remove OLD_NFSV2 from loader and libstand
We have parallel NFSv2 and NFSv3 reader implementations, only configurable at
build time, defaulting to v3. Remove v2.

Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D10206
2017-03-30 19:32:25 +00:00
Tycho Nightingale
86be94fca3 Add support for capturing 'struct ptrace_lwpinfo' for signals
resulting in a process dumping core in the corefile.

Also extend procstat to view select members of 'struct ptrace_lwpinfo'
from the contents of the note.

Sponsored by:	Dell EMC Isilon
2017-03-30 18:21:36 +00:00
Konstantin Belousov
9851b3400a Implement the memset_s(3) function as specified by the C11 ISO/IEC
9899:2011 Appendix K 3.7.4.1.

Other needed supporting types, defines and constraint_handler
infrastructure is added as specified in the C11 spec.

Submitted by:	Tom Rix <trix@juniper.net>
Sponsored by:	Juniper Networks
Discussed with:	ed
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D9903
Differential revision:	https://reviews.freebsd.org/D10161
2017-03-30 04:57:26 +00:00
Ed Maste
e3e9c656c9 libc: remove use of archaic __P() macro
Sponsored by:	The FreeBSD Foundation
2017-03-30 01:03:07 +00:00
Enji Cooper
33193da27e Fix up r316081 by using nitems(cam_errbuf) instead of sizeof(cam_errbuf)
Part of my original reasoning as far as converting the snprintf
calls was to permit switching over from char[] to wchar_t[] in the
future, as well as futureproof in case cam_errbuf's size was ever
changed.

Unfortunately, my approach was bugged because it conflated the
number of items with the size of the buffer, instead of the number of
elements being a fixed size != 1 byte.

Use nitems(..) instead which counts the quantity of items of a specific
type, as opposed to an unqualified sizeof(..) (which assumes that the
number of characters is equal to the buffer size).

MFC after:	2 months
Noted by:	cem
Sponsored by:	Dell EMC Isilon
2017-03-29 08:38:31 +00:00
Enji Cooper
c9bac21cc9 libcam: use __func__ instead of hardcoding the function name as func_name
MFC after:	3 days
Tested with:	`cam_device_copy(NULL, NULL)` // ;)..
Sponsored by:	Dell EMC Isilon
2017-03-28 22:32:11 +00:00
Enji Cooper
b0a39ef04d Apply r315689 to lib/libgcc_s as well to unbreak the gcc xtoolchain build
lib/libgcc_s consumes lib/libcompiler_rt/Makefile*. The NO_WERROR.gcc in
lib/libcompiler_rt/Makefile doesn't seem to have made a difference in being
able to build this, so sprinkle NO_WERROR.gcc here as well.

MFC after:	3 days
Reported by:	Jenkins (FreeBSD-head-amd64-gcc)
Tested with:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 19:01:01 +00:00
Enji Cooper
10f81a9b3b lib/libkvm: start adding basic tests for kvm(3)
- kvm_close: add a testcase to verify support for errno = EINVAL / -1
  (see D10065) when kd == NULL is provided to the libcall.
- kvm_geterr:
-- Add a negative testcase for kd == NULL returning "" (see D10022).
-- Add two positive testcases:
--- test the error case using kvm_write on a O_RDONLY descriptor.
--- test the "no error" case using kvm_read(3) and kvm_nlist(3) as
    helper routines and by injecting a bogus error message via
    _kvm_err (an internal API) _kvm_err was used as there isn't a
    formalized way to clear the error output, and because
    kvm_nlist always returns ENOENT with the NULL terminator today.
- kvm_open, kvm_open2:
-- Add some basic negative tests for kvm_open(3) and kvm_open2(3).
   Testing positive cases with a specific
   `corefile`/`execfile`/`resolver` requires more work and would require
   user intervention today in order to reliably test this out.

Reviewed by:	markj
MFC after:	2 months
Sponsored by:	Dell EMC Isilon
Differential Revision:	D10024
2017-03-28 17:37:49 +00:00
Martin Matuska
a7f7e457db MFV r316083,316094:
Sync libarchive with vendor

Vendor changes (FreeBSD-related):
- constify variables in several places
- unify platform ACL code in a single source file
- fix unused variable if compiling on FreeBSD without NFSv4 ACL support

MFC after:	3 days
X-MFC-with:	315636, 315876
2017-03-28 10:39:17 +00:00
Enji Cooper
7b7820a8e4 Use sizeof(cam_errbuf) instead of CAM_ERRBUF_SIZE in snprintf calls
Reindent snprintf calls' arguments to match style(9) guidelines with
respect to indentation.

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-03-28 08:24:16 +00:00
Enji Cooper
81321d0a4f Fix some localized style(9) issues and reword CAM_ERRBUF_SIZE description
The CAM_ERRBUF_SIZE description rewording fixes a typo by proxy.

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-03-28 08:19:51 +00:00
Adrian Chadd
f906f2025b [private] add libevent1 and sqlite3 include files for our private libraries.
This, like including ucl private headers, is useful for writing new base
system tools.  Yes, anyone using these libraries shouldn't assume ABI
compatibility.

Reviewed by:	bdrewery, bapt
Differential Revision:	https://reviews.freebsd.org/D10123
2017-03-27 22:34:43 +00:00
Robert Watson
5e386598a6 Merge OpenBSM 1.2-alpha5 from vendor branch to FreeBSD -CURRENT:
- Add a new "qsize" parameter in audit_control and the getacqsize(3) API to
  query it, allowing to set the kernel's maximum audit queue length.
- Add support to push a mapping between audit event names and event numbers
  into the kernel (where supported) using new A_GETEVENT and A_SETEVENT
  auditon(2) operations.
- Add audit event identifiers for a number of new (and not-so-new) FreeBSD
  system calls including those for asynchronous I/O, thread management, SCTP,
  jails, multi-FIB support, and misc. POSIX interfaces such as
  posix_fallocate(2) and posix_fadvise(2).
- On operating systems supporting Capsicum, auditreduce(1) and praudit(1) now
  run sandboxed.
- Empty "flags" and "naflags" fields are now permitted in audit_control(5).

Many thanks to Christian Brueffer for producing the OpenBSM release and
importing/tagging it in the vendor branch.  This release will allow improved
auditing of a range of new FreeBSD functionality, as well as non-traditional
events (e.g., fine-grained I/O auditing) not required by the Orange Book or
Common Criteria.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, AFRL
MFC after:	3 weeks
2017-03-26 21:14:49 +00:00
Michal Meloun
6fc9f4dbc8 Preserve VFP state across signal delivery.
We don't have enouch space to store full VFP context within mcontext
stucture. Due to this:
 - follow i386/amd64 way and store VFP state outside of the mcontext_t
   but point to it. Use the size of VFP state structure as an 'magic'
   indicator of the saved VFP state presence.
 - teach set_mcontext() about this external storage.
 - for signal delivery, store VFP state to expanded 'struct sigframe'.

Submited by:	Andrew Gierth (initial version)
PR:		217611
MFC after:	2 weeks
2017-03-26 08:36:56 +00:00
Michal Meloun
dfe5f22fd7 Cleanup structures related to VFP and/or mcontext_t.
- in mcontext_t, rename newer used 'union __vfp' to equaly sized 'mc_spare'.
  Space allocated by 'union __vfp' is too small and cannot hold full
  VFP context.
- move structures defined in fp.h to more appropriate headers.
- remove all unused VFP structures.

MFC after:	2 weeks
2017-03-24 11:46:49 +00:00
Martin Matuska
e46d471413 MFV r315875:
Sync libarchive with vendor.

Vendor changes (FreeBSD-related):
- store extended attributes with extattr_set_link() if no fd is provided
- add extended attribute tests to libarchive and bsdtar
- fix tar's test_option_acls
- support the UF_HIDDEN file flag

X-MFC with:	315636
2017-03-24 00:02:12 +00:00
Robert Watson
9612674f64 In libcasper, prefer to send a function index or service name over the IPC
channel to a zygote process, rather than sending a function pointer or
service pointer.  This avoids transfering pointers between address spaces,
which while robust in this case (due to the zygote being forked() from the
parent) is not generally a good idea, especially in the presence of
increasingly popular control-flow integrity and pointer protection
mitigation schemes.  With this change, ping(8) and other sandboxed tools
using libcasper for DNS resolution now work on architectures with tagged
memory again.

Reviewed by:	oshogbo
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2017-03-23 14:35:21 +00:00
Warner Losh
d780e0595c Fix a coverity-discovered NULL pointer dereference.
*** CID 1372598:  Null pointer dereferences  (FORWARD_NULL)
/lib/libefivar/efivar-dp-parse.c: 3612 in UefiDevicePathLibConvertTextToDeviceNode()
   Dereferencing null pointer "FromText".

When ported from Tiano core, I commented this out with an ifdef. That
was in error because we're supposed to fallback to a filepath when
nothing else patches. Instead, restore the original code, but fix
DevPathFromTextFilePath to cope with the conversion to narrow
strings. Also, fix the off-by-one error in the size of the memory it
allocates.

The off by one error is documented in Tiano core bug
https://bugzilla.tianocore.org/show_bug.cgi?id=441

CID: 1372598
Sponsored by: Netflix
2017-03-23 02:30:57 +00:00
Warner Losh
8af6a2c64e Define StrCmp in a funky was to be bug-compatible with EDK2 code.
Paper over a coverity issue:

*** CID 1372592:  API usage errors  (BAD_COMPARE)
/lib/libefivar/efivar-dp-parse.c: 2723 in DevPathFromTextiSCSI()
   Truncating the result of "strcmp" to "unsigned short" may cause it
   to be misinterpreted as 0. Note that "strcmp" may return an integer
   besides -1, 0, or 1.

We do this by making StrCmp return either 0 or 1 for equal or
not-equal.  There's a bug in the DevPathFromTextiSCSI cast of the
return value and this workaround will fix it without breaking other
users of StrCmp (all of which test for == 0).

https://bugzilla.tianocore.org/show_bug.cgi?id=440 has been filed
upstream to log this issue.

CID: 1372592
Sponsored by: Netflix
2017-03-23 02:30:52 +00:00
Warner Losh
62fd382c43 Simplify the code a little.
Submitted by: rppokala
Sponsored by: Netflix
2017-03-22 20:51:52 +00:00
Enji Cooper
c25e946c34 Unbreak world by adding sys/stat.h for stat(2)
X-MFC with:	r315733
Reported by:	O. Hartmann <ohartmann@walstatt.org>
Sponsored by:	Dell EMC Isilon
2017-03-22 19:23:13 +00:00
Enji Cooper
eea7b35fb9 style(9): sort #includes
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-22 19:17:13 +00:00
Warner Losh
37b5835028 Impelemnt ttys onifexists in init.
Implement a new init(8) option in /etc/ttys. If this option is present
on the entry in /etc/ttys, the entry will be active if and only if it
exists.  If the name starts with a '/', it will be considered an
absolute path. If not, it will be a path relative to /dev.

This allows one to turn off video console getty that aren't present
(while running a getty on them even when they aren't the system
console). Likewise with serial ports.

It differs from onifconsole in only requiring the device exist rather
than it be listed as one of the system consoles.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D10037
2017-03-22 19:00:41 +00:00
Mark Johnston
643fc6b26f Add initializations missed in r315728.
X-MFC With:	r315728
2017-03-22 18:33:29 +00:00
Mark Johnston
8440c5e621 Avoid accessing an uninitialized variable when vfork() fails.
Reported by:	Miles Ohlrich <miles.ohlrich@isilon.com>
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-22 18:31:44 +00:00
Mark Johnston
48da4e2024 Avoid double-closing an fd if elf_begin() fails.
Reported by:	Miles Ohlrich <miles.ohlrich@isilon.com>
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-22 18:14:55 +00:00
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
Dag-Erling Smørgrav
3869fb7832 Add options to capture stdout and / or stderr and pass the output on
to the user.  There is currently no buffering, so the result may be
somewhat unpredictable if the conversation function adds a newline,
like openpam_ttyconv() does.

Clean up and simplify the environment handling code, which triggered
an inexplicable bug on some systems.

MFC after:	2 weeks
2017-03-22 13:16:04 +00:00
Enji Cooper
25e76a1d57 libkvm: bump WARNS to 6 after recent commits done to resolve warnings issues
MFC after:	1 month
Tested with:	make tinderbox; clang 4.0.0 (amd64), gcc 4.2.1/6.3.0 (amd64)
Sponsored by:	Dell EMC Isilon
2017-03-22 02:44:39 +00:00
Enji Cooper
881b0edb8f libkvm: fix warning issues post-r291406
- Fix -Wunused warnings with *_native detection handlers by marking `kd`
  __unused, except with arm/mips, where a slightly more complicated scheme
  is required to handle the native case vs the non-native case.
- Fix -Wmissing-variable-declarations warnings by marking struct kvm_arch
  objects static.

Differential Revision:	D10071
MFC after:	1 week
Reviewed by:	vangyzen
Tested with:	WIP test code (D10024) // kgdb7121 (i386 crash/kernel on amd64)
Sponsored by:	Dell EMC Isilon
2017-03-22 02:42:00 +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
Dimitry Andric
d006dde2fd Gcc has incompatible internal declarations for __divtc3 and __multc3 as
defined in compiler-rt, but it has no option to silence its warning, so
make gcc warnings for libcompiler_rt non-fatal.

Noticed by:	lwhsu
MFC after:	3 days
2017-03-21 21:07:37 +00:00
Enji Cooper
0f5425a4fc kvm_write: fix -Wcast-qual warning in pointer arithmetic argument
Cast buf to `const char *` when doing arithmetic operation to match
`cp`'s type [1].

Differential Revision:	D10082
MFC after:	1 week
Reviewed by:	cem (earlier diff), vangyzen
Submitted by:	cem [1]
Sponsored by:	Dell EMC Isilon
2017-03-21 20:48:36 +00:00