Commit Graph

18524 Commits

Author SHA1 Message Date
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
6002d46737 msun: Remove trailing space in Sunsoft copyright statement.
Submittedby:	kargl
2017-04-23 22:31:12 +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
f06b2368bf Minor style(9) fixups
Delete trailing whitespace and sort headers.

Leave libgeom.h's placement alone, per reasoning in r317289.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-23 03:36:03 +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
Enji Cooper
3bacccb6f1 Fix type for pagesize to match the return type for getpagesize(3)
to fix the build

MFC after:	5 weeks
X-MFC with:	r317311
Pointyhat to:	ngie
Sponsored by:	Dell EMC Isilon
2017-04-23 01:50:47 +00:00
Enji Cooper
2cebfa7bbf Check for failures from getpagesize(3)
Return errno on failure, similar to the open(2) call above it.

MFC after:	5 weeks
Reported by:	Coverity
CID:		1193753
Sponsored by:	Dell EMC Isilon
2017-04-23 01:47:51 +00:00
Enji Cooper
ae0cf296c9 Minor style(9) fixups
Delete trailing whitespace and sort headers.

Leave libgeom.h's placement alone, per reasoning in r317289.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-23 01:17:59 +00:00
Enji Cooper
e976502216 libgeom(3): note that stdio.h is required when referencing gctl_dump(3)
gctl_dump(3) is only exposed when stdio.h is #include'd first, per its
addition in r112510. The reasoning noted for the conditional "exposure"
of the function was to "limit #include pollution".

This addresses an issue I found with the documentation when looking at
bug 218809, which in turn addresses a -Wimplicit-function-declaration
compiler warning in `tools/regression/geom_gpt/test.c` (it uses
gctl_dump(3)).

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 19:32:23 +00:00
Enji Cooper
ef8f85c6b9 libgeom(3): apply minor polish
- Use .Dv when mentioning NULL per mdoc(7).
- Reword `g_device_path`, `g_open_by_ident`, and `g_providername`'s descriptions
  so they're less wordy.
- Fix a typo in `g_device_path` (can not -> cannot).

MFC after:	5 weeks
Tested with:	igor, make manlint
Sponsored by:	Dell EMC Isilon
2017-04-22 19:11:37 +00:00
Pedro F. Giffuni
efa8af7c73 lib: initial use of reallocarray(3).
Make some use of reallocarray, attempting to limit it to cases where the
parameters are unsigned and there is some theoretical chance of overflow.

MFC afer:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D9980
2017-04-21 19:27:33 +00:00
Pedro F. Giffuni
8413ef5798 libthread_db: unbreak build due to sign/unsigned comparison.
Reported by:	lwshu
2017-04-20 21:01:59 +00:00
Dimitry Andric
bcfe4c376c Add function and data sections when building llvm, clang, lld and lldb,
and allow the linker to garbage collect them.  This shaves off up to a
few MB from the final executables.

MFC after:	3 days
2017-04-20 21:00:09 +00:00
Dimitry Andric
c83fca58fa Turn off llvm/clang's ENABLE_BACKTRACES setting, since it never worked
properly anyway.  (Upstream has reorganized this somewhat in the mean
time, but for proper backtraces we would need llvm-symbolizer in base.)

MFC after:	3 days
2017-04-20 21:00:04 +00:00
Pedro F. Giffuni
3876a56282 libpthread_db: undo the memset size change.
I inadvertedly soubled the size of the memset without noticing the
start address had changed. The size for the memset in pt_map_thread()
shouldn't actually match the reallocarray() so undo that part of r317200.

This is a re-commit of r317201 to clarify the log.

X-MFC with:	r317200
2017-04-20 17:58:27 +00:00
Pedro F. Giffuni
171fcb3069 Revert r317201 to fix the log. 2017-04-20 17:54:59 +00:00
Pedro F. Giffuni
febd54ebb7 libpthread_db: leave the memset size from unchanged.
The size for the memset in pt_map_thread() shouldn't actually match the
reallocarray() so undo that part of r317200.

X-MFC with:	r317200
2017-04-20 17:49:37 +00:00
Pedro F. Giffuni
1f2b051d84 libthread_db: unsign map_len and use reallocarray(3).
Lengths are not negative, so map_len should be unsigned. Unsign the
corresponding indexes too and bring a small use of reallocarray(3).

Reorder the memset to be consistent with the realloc: it appears we
were only clearing half the memory in pt_map_thread().

MFC after:	2 weeks
2017-04-20 17:43:25 +00:00
Sergey Kandaurov
b11ef6e971 Document kevent EVFILT_EMPTY.
Reviewed by:	hiren
X-MFC with:	r312277
2017-04-18 15:36:13 +00:00
Ed Maste
a3422d96bd libelftc: bump version number for r317075 2017-04-17 23:57:42 +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
Pedro F. Giffuni
6fd94039ef libjail: make allocation in jailparam_all() somewhat more robust.
Unsign some variables involved in allocation as they will never be
negative anyways. Provide some bounds checking through reallocarray(3).

This is all very unlikely to have any visible effect.

Reviewed by:	jamie
MFC after:	3 weeks
2017-04-16 19:23:10 +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
Baptiste Daroussin
e229090553 Import zstandard 1.1.4 in base
zstandard is a new compression library/tool which is very fast at
compression/decompression

For now import as a private library
2017-04-15 20:05:22 +00:00
Baptiste Daroussin
a19eddc34b Import zstd 1.1.4 2017-04-15 19:47:16 +00:00
Adrian Chadd
8ac09f3993 [lib80211] fix a missing cleanup path.
PR:		lib/218655
Reported by:	<valentin.vergez@stormshield.eu>
2017-04-14 20:10:18 +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
Brooks Davis
72f0a13e60 Correct an out of bounds read with HN_AUTOSCALE and very large numbers.
The maximum scale is 6 (K, M, G, T, P, E) (B is 0).

Overly large explict scales were checked correctly, but for sufficently
large numbers HN_AUTOSCALE would get to 7 resulting in an out of bounds
read.

Found with humanize_number_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/D10376
2017-04-13 15:49:32 +00:00
Andrey V. Elsukov
4e0e8f3107 Add large replay widow support to setkey(8) and libipsec.
When the replay window size is large than UINT8_MAX, add to the request
the SADB_X_EXT_SA_REPLAY extension header that was added in r309144.

Also add support of SADB_X_EXT_NAT_T_TYPE, SADB_X_EXT_NAT_T_SPORT,
SADB_X_EXT_NAT_T_DPORT, SADB_X_EXT_NAT_T_OAI, SADB_X_EXT_NAT_T_OAR,
SADB_X_EXT_SA_REPLAY, SADB_X_EXT_NEW_ADDRESS_SRC, SADB_X_EXT_NEW_ADDRESS_DST
extension headers to the key_debug that is used by `setkey -x`.

Modify kdebug_sockaddr() to use inet_ntop() for IP addresses formatting.
And modify kdebug_sadb_x_policy() to show policy scope and priority.

Reviewed by:	gnn, Emeric Poupon
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10375
2017-04-13 14:44:17 +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
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