]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFC r322749:
cy [Mon, 28 Aug 2017 06:17:04 +0000 (06:17 +0000)]
MFC r322749:

Replace the include path using CURDIR with KRB5DIR. This is consistent
with the rest of the Makefiles in kerberos5/.

6 years agoMFC: r312641
marius [Sun, 27 Aug 2017 21:36:44 +0000 (21:36 +0000)]
MFC: r312641

Enable WOL features also for igb(4) class of devices.

PR: 208343
Submitted by: Kaho Tashikazu <kaho@elam.kais.kyoto-u.ac.jp>

6 years agoMFC: r308643, r312427
marius [Sun, 27 Aug 2017 18:18:01 +0000 (18:18 +0000)]
MFC: r308643, r312427

- Update WOL support for newer em(4) devices. [1]
- Add support for Kaby Lake generation i219 (4) and i219 (5) devices.

PR: 208343 [1]

6 years agoMFC r322720,r322723:
kib [Sun, 27 Aug 2017 11:27:27 +0000 (11:27 +0000)]
MFC r322720,r322723:
Simplify amd64 trap().

6 years agoMFC r322719:
kib [Sun, 27 Aug 2017 11:23:52 +0000 (11:23 +0000)]
MFC r322719:
Trim excessive 'extern' and remove unused declaration.

6 years agoMFC r322718:
kib [Sun, 27 Aug 2017 11:22:19 +0000 (11:22 +0000)]
MFC r322718:
Use ANSI C declaration for trap_pfault().  Style.

6 years agoMFC r322677: pw usermod: Properly deal with empty secondary group lists (-G '')
emaste [Sat, 26 Aug 2017 00:35:49 +0000 (00:35 +0000)]
MFC r322677: pw usermod: Properly deal with empty secondary group lists (-G '')

PR: 221417
Relnotes: Yes

6 years agoMFC r322683: ena.4: fix spelling of 'occurred'
emaste [Sat, 26 Aug 2017 00:30:59 +0000 (00:30 +0000)]
MFC r322683: ena.4: fix spelling of 'occurred'

PR: 331298

6 years agoMFC r322680: sa.4: fix spelling of 'suppresses'
emaste [Sat, 26 Aug 2017 00:30:13 +0000 (00:30 +0000)]
MFC r322680: sa.4: fix spelling of 'suppresses'

PR: 221302

6 years agosys/modules: don't build bxe,qlxgbe if the user objects to sourceless ucode
emaste [Sat, 26 Aug 2017 00:29:07 +0000 (00:29 +0000)]
sys/modules: don't build bxe,qlxgbe if the user objects to sourceless ucode

MFC of r322682 and r322684

Sponsored by: The FreeBSD Foundation

6 years agoMFC: r321689
rmacklem [Fri, 25 Aug 2017 22:58:54 +0000 (22:58 +0000)]
MFC: r321689
Add a new "-N" option to umount(8), that does a forced dismount of an NFS mount
point.

The new "-N" option does a forced dismount of an NFS mount point, but avoids
doing any checking of the mounted-on path, so that it will not get hung
when a vnode lock is held by another hung process on the mounted-on vnode.
The most common case of this is a "umount" with the "-f" option.
Other than avoiding checking the mounted-on path, it performs the same
forced dismount as a successful "umount -f" would do.

This commit includes a content change to the man page.

6 years agoMFC: r321688
rmacklem [Fri, 25 Aug 2017 22:52:40 +0000 (22:52 +0000)]
MFC: r321688
Add kernel support for the NFS client forced dismount "umount -N" option.

When an NFS mount is hung against an unresponsive NFS server, the "umount -f"
option can be used to dismount the mount. Unfortunately, "umount -f" gets
hung as well if a "umount" without "-f" has already been done. Usually,
this is because of a vnode lock being held by the "umount" for the mounted-on
vnode.
This patch adds kernel code so that a new "-N" option can be added to "umount",
allowing it to avoid getting hung for this case.
It adds two flags. One indicates that a forced dismount is about to happen
and the other is used, along with setting mnt_data == NULL, to handshake
with the nfs_unmount() VFS call.
It includes a slight change to the interface used between the client and
common NFS modules, so I bumped __FreeBSD_version to ensure both modules are
rebuilt.

6 years agoMFC: r321675
rmacklem [Fri, 25 Aug 2017 22:44:55 +0000 (22:44 +0000)]
MFC: r321675
Fix possible crash for the NFSv4.1 pNFS client.

If the nfsrpc_createlayoutrpc() call in nfsrpc_getcreatelayout() fails,
the code used nfhpp when it might be set NULL. This patch checks for
the error cases (laystat != 0) and avoids using nfhpp for the failure case.
This would only affect NFSv4.1 mounts with the "pnfs" option.
Found while testing the "umount -N" patch not yet in head.

6 years agoMFC: r321628
rmacklem [Fri, 25 Aug 2017 22:39:49 +0000 (22:39 +0000)]
MFC: r321628
Replace the checks for MNTK_UNMOUNTF with a macro that does the same thing.

This patch defines a macro that checks for MNTK_UNMOUNTF and replaces
explicit checks with this macro. It has no effect on semantics, but
prepares the code for a future patch where there will also be a
NFS specific flag for "forced dismount about to occur".

6 years agoMFC r321332:
asomers [Fri, 25 Aug 2017 14:42:11 +0000 (14:42 +0000)]
MFC r321332:

Implement SIGEV_THREAD notifications for lio_listio(2)

Our man pages have always indicated that this was supported, but in fact the
feature was never implemented for lio_listio(2).

Reviewed by: jhb, kib (earlier version)
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D11680

6 years agoMFC r321082:
asomers [Fri, 25 Aug 2017 14:37:23 +0000 (14:37 +0000)]
MFC r321082:

Add regression tests for bugs 220459 and 220398

Bug 220398 - lio_listio(2) never sends asynchronous notification if nent==0
Bug 220459 - lio_listio(2) doesn't support SIGEV_THREAD

PR: 220459
PR: 220398
Reviewed by: cem, jhb
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D11470

6 years agoMFC r320974-r320975, r321001, r321206
asomers [Fri, 25 Aug 2017 14:32:03 +0000 (14:32 +0000)]
MFC r320974-r320975, r321001, r321206

r320974:
Use ATF cleanup routines in aio_test.c

Remove aio_test's legacy timeout handling and cleanup routines.  Instead,
use ATF's builtin capabilities.  ATF automatically cleans up newly created
files, too, so we don't have to explicitly unlink them.  The only tests than
need a cleanup routine are the md(4) tests, which must destroy their md
device.

Reviewed by: jhb
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D11468

r320975:
Add tests for aio(4) completion notification via signals and threads

Reviewed by: jhb
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D11468

r321001:
Fix the build with GCC after r320975

Reported by: pfg
X-MFC-With: 320975
Sponsored by: Spectra Logic Corp

r321206:
Remove dead code that was killed by r320975

Reported by: Coverity
CID: 1377977
X-MFC-With: 320975
Sponsored by: Spectra Logic Corp

6 years agoMFC r320807:
asomers [Fri, 25 Aug 2017 14:28:36 +0000 (14:28 +0000)]
MFC r320807:

stdbuf(1): Add buffer definition "B" to the usage message

This option has been missing from the usage message ever since the program
was first imported.

Submitted by: shivansh
Reviewed by: asomers
Sponsored by: Google, Inc (GSoC 2017)
Differential Revision: https://reviews.freebsd.org/D11529

6 years agoMFC r320737, r320914
asomers [Fri, 25 Aug 2017 12:16:03 +0000 (12:16 +0000)]
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

6 years agoMFC r321846:
araujo [Fri, 25 Aug 2017 08:24:29 +0000 (08:24 +0000)]
MFC r321846:

Log when we have finished pushing users and groups.

Obtained from: OpenBSD (rev 1.4)

6 years agoMFC: r316627 (kan)
jkim [Fri, 25 Aug 2017 07:49:51 +0000 (07:49 +0000)]
MFC: r316627 (kan)

Use int to receive the return value of getopt function.

6 years agoMFC: r321601 (emaste)
jkim [Fri, 25 Aug 2017 07:42:48 +0000 (07:42 +0000)]
MFC: r321601 (emaste)

acpidump: add GIC ITS srat type

6 years agoMFC: r319365, r321670
jkim [Fri, 25 Aug 2017 05:49:37 +0000 (05:49 +0000)]
MFC: r319365, r321670

Merge ACPICA 20170728.

6 years agoMFC: r322803
jkim [Fri, 25 Aug 2017 05:41:28 +0000 (05:41 +0000)]
MFC: r322803

Fix size to copyout(9) for cpuset_getid(2).

6 years agoMFC r320269:
asomers [Fri, 25 Aug 2017 04:00:13 +0000 (04:00 +0000)]
MFC r320269:

style fixes in bin/echo/tests

Submitted by: shivansh
Reviewed by: asomers
X-MFC-With: 319626
Sponsored by: Google, Inc (GSoC 2017)
Differential Revision: https://reviews.freebsd.org/D11318

6 years agoMFC: r322726
marius [Thu, 24 Aug 2017 20:51:16 +0000 (20:51 +0000)]
MFC: r322726

Bring back the much more readable unified format for differences in
/etc/{group,master.passwd}. This was originally turned on for all of
/etc/{aliases,group,master.passwd} in r55196, but then backed out
only for the latter two in r56697, as the adaption of the sed(1)ing
done in r56308 was incorrect. This left us with inconsistent diff(1)
formats in the daily output of periodic(8) ever since, despite in
r56697 having been promised to be revisited. So properly adapt the
password hash filtering to the unified format and turn the later on
again for /etc/{group,master.passwd}, too.

6 years agoMFC r322408
davidcs [Thu, 24 Aug 2017 18:51:55 +0000 (18:51 +0000)]
MFC r322408
Performance enhancements to reduce CPU utililization for large number of
TCP connections (order of tens of thousands), with predominantly Transmits.

Submitted by: Vaishali.Kulkarni@cavium.com

6 years agoMFC r322331
davidcs [Thu, 24 Aug 2017 17:36:10 +0000 (17:36 +0000)]
MFC r322331
Provide compile option to choose receive processing in either Ithread or
Taskqueue Thread.

6 years agoMFC r322752:
gjb [Thu, 24 Aug 2017 16:49:34 +0000 (16:49 +0000)]
MFC r322752:
 Update the tests(7) manual page to note the test suite is installed
 by default as of 11.0-RELEASE.

Sponsored by: The FreeBSD Foundation

6 years agoMFC r322770, r322796:
gjb [Thu, 24 Aug 2017 13:37:22 +0000 (13:37 +0000)]
MFC r322770, r322796:

 r322770:
  Apply changes from bin/chmod/tests/chmod_test.sh, adding
  atf_expect_fail() before chflags(8) is invoked if the filesystem
  is ZFS, which does not support UF_IMMUTABLE.

 r322796:
  Revert part of r322770 in usr.sbin/chown/tests/chown_test.sh,
  which incorrectly adds atf_expect_fail() where there is no
  failure case.

Sponsored by: The FreeBSD Foundation

6 years agoMFC r322756:
kib [Thu, 24 Aug 2017 08:02:26 +0000 (08:02 +0000)]
MFC r322756:
Style.

6 years agoMFC r322544:
gjb [Wed, 23 Aug 2017 17:12:26 +0000 (17:12 +0000)]
MFC r322544:
 Always expand the full path to the configuration file specified
 with the '-c' flag.

Sponsored by: The FreeBSD Foundation

6 years agoMFC r322804:
benno [Wed, 23 Aug 2017 15:47:42 +0000 (15:47 +0000)]
MFC r322804:
 Correct typo in usage string.

 Submitted by: peterpakos (GitHub username)

6 years agoMFC r320146, r320170, 320842:
pfg [Wed, 23 Aug 2017 15:43:59 +0000 (15:43 +0000)]
MFC r320146, r320170, 320842:

Minor grammar changes and cleanups in order to facilitate future merges.

6 years agoMFC r322310:
ae [Wed, 23 Aug 2017 08:56:18 +0000 (08:56 +0000)]
MFC r322310:
  Add to if_enc(4) ability to capture packets via BPF after pfil processing.

  New flag 0x4 can be configured in net.enc.[in|out].ipsec_bpf_mask.
  When it is set, if_enc(4) additionally captures a packet via BPF after
  invoking pfil hook. This may be useful for debugging.

  Sponsored by: Yandex LLC

6 years agoMFC of 322298 noting MFC 322806 in UPDATING
mckusick [Wed, 23 Aug 2017 04:43:50 +0000 (04:43 +0000)]
MFC of 322298 noting MFC 322806 in UPDATING

6 years agoMFC of 322200, 322201, 322271, and 322297
mckusick [Wed, 23 Aug 2017 04:35:03 +0000 (04:35 +0000)]
MFC of 322200, 322201, 322271, and 322297

322200: Remove (broken) search for alternate superblocks
322201: Show differences when alternate superblock fails to match
322271: Cleanup for 322200.
322297: Restore fsck_ffs ability to find alternate superblocks

Discussed with: kib, imp
Differential Revision: https://reviews.freebsd.org/D11589

6 years agoAdd missing #include to fix build after r322761.
jhb [Tue, 22 Aug 2017 19:48:33 +0000 (19:48 +0000)]
Add missing #include to fix build after r322761.

Reported by: lwhsu
Pointy hat to: jhb

6 years agoMFC of 322179, 322463, and 322464:
mckusick [Tue, 22 Aug 2017 15:20:48 +0000 (15:20 +0000)]
MFC of 322179, 322463, and 322464:

322179: Correct ordering of bio's in gjournal queue
322463: Eliminate a variable that is set-only in g_journal.c
322464: Correct check for reads in gjournal

Submitted by: Dr. Andreas Longwitz <longwitz@incore.de>
Discussed with: kib

6 years agoMFC r321387:
ngie [Tue, 22 Aug 2017 15:16:09 +0000 (15:16 +0000)]
MFC r321387:

Don't use incorrect hardcoded path to ksh -- use /usr/bin/env
to find ksh instead

6 years agoMFC r322410:
ken [Tue, 22 Aug 2017 13:59:50 +0000 (13:59 +0000)]
MFC r322410:
  ------------------------------------------------------------------------
  r322410 | ken | 2017-08-11 12:43:52 -0600 (Fri, 11 Aug 2017) | 16 lines

  Add historical notes on QIC tape drives and fix a couple of issues in mt(1).

   o Density code 0x5 is also known as QIC-11, and should have a footnote
     reference.
   o Add notes on QIC tape drives from the bug report.  These may help anyone
     trying to use a QIC drive.
   o Take out a "more more" instance found by igor.
   o Bump the man page date.

  The PR is 14 years old, so it's past time to retire it.

  PR: doc/53596
  Submitted by: tedm@toybox.placo.com
  Reviewed by: bcr
  Sponsored by: Spectra Logic

  ------------------------------------------------------------------------

6 years agoMFC r321450: bsdgrep(1): Don't exit before processing every file
kevans [Tue, 22 Aug 2017 02:03:01 +0000 (02:03 +0000)]
MFC r321450: bsdgrep(1): Don't exit before processing every file

Given an empty pattern (i.e. grep "" A B), bsdgrep(1) would previously
exit() with the appropriate exit code upon encountering an empty file.
Likely intended as an optimization, but this behavior is technically
incorrect since an empty pattern should match every line.

PR: 220924
Approved by: emaste (mentor, blanket MFC)

6 years agoMerge r322321:
glebius [Mon, 21 Aug 2017 17:40:51 +0000 (17:40 +0000)]
Merge r322321:

  Plug uninitialized stack variable leak in sendfile(2).

Reported by: Ilja Van Sprundel <ivansprundel ioactive.com>
Submitted by: Domagoj Stolfa <domagoj.stolfa gmail.com>
Security: uninitialized stack variable leak

6 years agoMFC 322437: Reliably enable debug exceptions on all CPUs.
jhb [Mon, 21 Aug 2017 17:35:04 +0000 (17:35 +0000)]
MFC 322437: Reliably enable debug exceptions on all CPUs.

Previously, debug exceptions were only enabled on the boot CPU if
DDB was enabled in the dbg_monitor_init() function.  APs also called
this function, but since mp_machdep.c doesn't include opt_ddb.h, the
APs ended up calling an empty stub defined in <machine/debug_monitor.h>
instead of the real function.  Also, if DDB was not enabled in the kernel,
the boot CPU would not enable debug exceptions.

Fix this by adding a new dbg_init() function that always clears the OS
lock to enable debug exceptions which the boot CPU and the APs call.
This function also calls dbg_monitor_init() to enable hardware breakpoints
from DDB on all CPUs if DDB is enabled.  Eventually base support for
hardware breakpoints/watchpoints will need to move out of the DDB-only
debug_monitor.c for use by userland debuggers.

6 years agoMFC 322436: Don't panic for PT_GETFPREGS.
jhb [Mon, 21 Aug 2017 17:29:37 +0000 (17:29 +0000)]
MFC 322436: Don't panic for PT_GETFPREGS.

Only fetch the VFP state from the CPU if the thread whose registers are
being requested is the current thread.  If a stopped thread's registers
are being fetched by a debugger, the saved state in the PCB is already
valid.

6 years agoMFC r322667,r322706:
kib [Mon, 21 Aug 2017 15:11:58 +0000 (15:11 +0000)]
MFC r322667,r322706:
Improve i386 #UD low-level kdtrace hook.

6 years agoMFC r322627: arm64: return error instead of panic in unimplemented ptrace ops
emaste [Mon, 21 Aug 2017 12:23:11 +0000 (12:23 +0000)]
MFC r322627: arm64: return error instead of panic in unimplemented ptrace ops

We don't need a panic as a reminder that these need to be implemented.

Reported by: Shawn Webb
Sponsored by: The FreeBSD Foundation

6 years agoMFC r322434:
lwhsu [Mon, 21 Aug 2017 10:26:11 +0000 (10:26 +0000)]
MFC r322434:

Re-remove excess / for installing SYMLINKS

This excess / was introduced in r280129, and fixed in r295230, but got
re-introduced while merging another branch in r298107.

Approved by: gjb
Differential Revision: https://reviews.freebsd.org/D11995

6 years agoMFC r322496:
kib [Mon, 21 Aug 2017 09:52:15 +0000 (09:52 +0000)]
MFC r322496:
Print whole machine state on double fault.

6 years agoMFC r322495:
kib [Mon, 21 Aug 2017 09:04:43 +0000 (09:04 +0000)]
MFC r322495:
Add {rd,wr}{fs,gs}base C wrappers for instructions.

6 years agoMFC r321779:
ae [Mon, 21 Aug 2017 09:03:20 +0000 (09:03 +0000)]
MFC r321779:
  Add inpcb pointer to struct ipsec_ctx_data and pass it to the pfil hook
  from enc_hhook().

  This should solve the problem when pf is used with if_enc(4) interface,
  and outbound packet with existing PCB checked by pf, and this leads to
  deadlock due to pf does its own PCB lookup and tries to take rlock when
  wlock is already held.

  Now we pass PCB pointer if it is known to the pfil hook, this helps to
  avoid extra PCB lookup and thus rlock acquiring is not needed.
  For inbound packets it is safe to pass NULL, because we do not held any
  PCB locks yet.

  PR: 220217
  Sponsored by: Yandex LLC

6 years agoMFC r320578:
pfg [Sun, 20 Aug 2017 23:05:36 +0000 (23:05 +0000)]
MFC r320578:

ext2fs: be more verbose about unsupported ext2fs features.

It is useful to know exactly what features may be lacking when trying to
mount ext4 filesystems.

Submitted by: Fedor Uporov

6 years agoMFC r322527:
delphij [Sun, 20 Aug 2017 07:04:23 +0000 (07:04 +0000)]
MFC r322527:

Plug memory leak in arge_encap().

Reported by: Ilja Van Sprundel <ivansprundel ioactive.com>
Submitted by: Domagoj Stolfa <domagoj.stolfa gmail.com>
Reviewed by: adrian

6 years agoMFC r305626,r305629,r307863,r322447,r322448,r322449,r322450,r322451:
ngie [Sun, 20 Aug 2017 06:07:40 +0000 (06:07 +0000)]
MFC r305626,r305629,r307863,r322447,r322448,r322449,r322450,r322451:

r305626 (by oshogbo):

Move libcasper tests from regression/capsicum/libcasper/ to
lib/libcasper/service/${service_name}/tests.

r305629 (by jkim):

Add new directories added in r305626 to fix "make installworld".

r307863 (by emaste):

Set SHLIBDIR before .including src.opts.mk in libcapser services

bsd.own.mk (included from src.opts.mk) sets SHLIBDIR?=${LIBDIR}, so
SHLIBDIR must be set before including either one of them.

MFC with: 305626

r322447:

Fix result printing

- Flushing stdout prevents the buffer from being printed twice, fixing
  issues with stdout printing out the testplan, etc, twice.
- Don't print out raw source/line numbers; hide them behind comments.

r322448:

Make root-privileges a requirement for the test

Some of the testcases try to manipulate sysctls that require root privileges,
e.g., "kern.sync_on_panic". Make root-privileges a hard requirement so the
tests don't raise false positives due to privilege issues when calling
sysctlbyname(3) on writable sysctls.

r322449:

Use hardcoded IPv4/IPv6 addresses for google-public-dns-a.google.com instead
of freefall.freebsd.org to unbreak the DNS tests

The address allocations for freefall.freebsd.org have changed in the past 4 years.
Use a more stable set of hardcoded addresses for now to make the tests succeed
reliably.

The hostname should be resolved dynamically instead of hardcoding the addresses in
the future. This is just a bandaid.

r322450:

Integrate the tests moved in r305626 in to the FreeBSD test suite

The reachover Kyuafiles were never added, and thus the tests were installed
as standalone tests, and not integrated into the full suite.

MFC with: r305626, 305629, r307863, r322447, r322448, r322449

r322451:

TESTSDIR isn't required; remove it

MFC with: r322450

6 years agoMFC r320145:
pfg [Sun, 20 Aug 2017 01:27:33 +0000 (01:27 +0000)]
MFC r320145:
ext2fs: Add uninit_bg feature support.

From the linux tune2fs(8) manpage:
"Allow the kernel to initialize bitmaps and inode tables and keep a high
watermark for the unused inodes in a filesystem, to reduce e2fsck(8) time.
This first e2fsck run after enabling this feature will take the full time,
but subsequent e2fsck runs will take only a fraction of the original time,
depending on how full the file system is."

Submitted by: Fedor Uporov

6 years agoMFC r316341, r317779, r319071, r319077, r319557, r319558, r319827, r319829:
pfg [Sun, 20 Aug 2017 01:08:23 +0000 (01:08 +0000)]
MFC r316341, r317779, r319071, r319077, r319557, r319558, r319827, r319829:

ext2fs: add read-write support for Extended Attributes and linux ACLs.

Extended attributes and their particular implementation in linux are
different from FreeBSD so in this case we have started diverging from
the UFS EA implementation, which would be the natural reference.

Support for linux ext2fs posix-draft ACLs.

Submitted by: Fedor Uporov
Reviewed by: pfg
Include fixes from: cem, pluknet

6 years agoMFC r322427:
kib [Sat, 19 Aug 2017 09:38:43 +0000 (09:38 +0000)]
MFC r322427:
Improve standard compliance for memset_s() and abort_handler_s().

6 years agoMFC r321959:
ngie [Sat, 19 Aug 2017 01:49:09 +0000 (01:49 +0000)]
MFC r321959:

Annotate tests that require root privileges appropriately

This unbreaks running the tests with unprivileged users.

6 years agoMFC r321947:
ngie [Sat, 19 Aug 2017 01:45:02 +0000 (01:45 +0000)]
MFC r321947:

Require strings(1) with :o_flag_preparer and :o_flag_publisher

strings(1) might not be installed on the system, e.g., if MK_TOOLCHAIN == no

6 years agoMFC r321081:
ngie [Sat, 19 Aug 2017 01:43:02 +0000 (01:43 +0000)]
MFC r321081:

Sort the tests alphabetically before adding them to the Kyuafiles

This is being done to aid in debugging test runs, in the event the
output shifts due to refactored Makefiles, added tests, etc.

6 years agoMFC r321954:
ngie [Sat, 19 Aug 2017 01:40:30 +0000 (01:40 +0000)]
MFC r321954:

Delete comment above "__DEFAULT_DEPENDENT_OPTIONS" related to "meta mode options"

src.conf(5) should document which knobs are which and the dependency between each;
remove the comment so the variable can apply to non-"meta mode options".

6 years agoMFC r321080:
ngie [Sat, 19 Aug 2017 01:26:26 +0000 (01:26 +0000)]
MFC r321080:

Expose the ILP32/LP64 programming environments based on
__ILP32__/__LP64__ instead of by architecture.

The list was incomplete (previous commits purged invalid architectures,
like __alpha__, but failed to add new ones). It's best to base the symbol
presence on whether or not the architecture is ILP32 / LP64 capable, per
the compiler.

This fixes the ILP32/LP64 program environments on some architectures like
arm64, and by proxy fixes the tests on those architectures.

6 years agoMFC r322445:
ngie [Sat, 19 Aug 2017 01:25:07 +0000 (01:25 +0000)]
MFC r322445:

Hide `sccsid` under #if 0, per example in style(9)

This fixes a -Wunused warning with gcc 6.3.0/7.0.0.

6 years agoMFC r321949,r321950,r322101:
ngie [Sat, 19 Aug 2017 01:21:46 +0000 (01:21 +0000)]
MFC r321949,r321950,r322101:

r321949:

Add expected failures for ZFS

- :f_flag fails on ZFS because UF_IMMUTABLE isn't supported [1].
- :v_flag fails on ZFS because the mode for foo is [always] updated
  unnecessarily.

get_filesystem(..) (supporting function that was added to the test script)
is based on equivalent logic in usr.bin/extattr/tests/extattr_test.sh .

PR: 221189 [1], 221188 [2]

r321950:

Always use first parameter passed to get_filesystem(..) instead of discarding it
and using `.` instead.

MFC with: r321949
PR: 221189 [1], 221188 [2]

r322101:

Don't check result of chflags in f_flag_cleanup()

This will prevent false positives from occurring if the test is run on
ZFS since ZFS doesn't support fflags throbbing like UFS.

PR: 221189
MFC with: r321949

6 years agoMFC r322391:
markj [Fri, 18 Aug 2017 20:20:49 +0000 (20:20 +0000)]
MFC r322391:
Micro-optimize kmem_unback().

6 years agoMFC r321502, r321714, r321733, r321737, r321799, r322364:
ken [Fri, 18 Aug 2017 14:25:07 +0000 (14:25 +0000)]
MFC r321502, r321714, r321733, r321737, r321799, r322364:

  ------------------------------------------------------------------------
  r321502 | scottl | 2017-07-25 19:48:13 -0600 (Tue, 25 Jul 2017) | 2 lines

  Quiet a message that sounds far more dire than it really is.

  ------------------------------------------------------------------------
  r321714 | scottl | 2017-07-30 00:53:58 -0600 (Sun, 30 Jul 2017) | 13 lines

      Split the interrupt setup code into two parts: allocation and configuration.
      Do the allocation before requesting the IOCFacts message.  This triggers
      the LSI firmware to recognize the multiqueue should be enabled if available.
      Multiqueue isn't used by the driver yet, but this also fixes a problem with
      the cached IOCFacts not matching latter checks, leading to potential problems
      with error recovery.

      As a side-effect, fetch the driver tunables as early as possible.

  Reviewed by: slm
  Obtained from: Netflix
  Differential Revision: D9243

  ------------------------------------------------------------------------
  r321733 | scottl | 2017-07-30 16:34:24 -0600 (Sun, 30 Jul 2017) | 5 lines

  Change from using underbar function names to normal function names for
  the informational print functions.  Collapse the debug API a bit to be
  more generic and not require as much code duplication.  While here, fix
  a bug in MPS that was already fixed in MPR.

  ------------------------------------------------------------------------
  r321737 | scottl | 2017-07-30 18:05:49 -0600 (Sun, 30 Jul 2017) | 3 lines

      Don't re-parse PCI IDs in order to set card-specific flags, use
      the flags field in the PCIID table.

  ------------------------------------------------------------------------
  r321799 | scottl | 2017-07-31 10:55:56 -0600 (Mon, 31 Jul 2017) | 4 lines

  Fix a logic bug in the split PCI interrupt code that slipped through

  Reported by: Harry Schmalzbauer

  ------------------------------------------------------------------------
  r322364 | ken | 2017-08-10 08:59:17 -0600 (Thu, 10 Aug 2017) | 39 lines

  Changes to make mps(4) and mpr(4) handle reinit with reallocation.

  When the mps(4) and mpr(4) drivers need to reinitialize the
  firmware, they sometimes need to reallocate all of the memory
  allocated by the driver.  The reallocation happens whenever the IOC
  Facts change.  That should only happen after a firmware upgrade.

  If the reinitialization happens as a result of a timed out command
  sent to the card, the command that timed out and triggered the
  reinit may have been freed if iocfacts_allocate() reallocated all
  memory.  If the caller attempts to access the command after that,
  the kernel will panic because the caller will be dereferencing
  freed memory.

  The solution is to set a flag in the softc when we reallocate,
  and avoid dereferencing the command strucure if we've reallocated.

  The changes are largely the same in both drivers, since mpr(4) is a
  derivative of mps(4).

   o In iocfacts_allocate(), if the IOC Facts have changed and we
     need to reallocate, set the REALLOCATED flag in the softc.

   o Change wait_command() to take a struct mps_command ** instead of
     a struct mps_command *.  This allows us to NULL out the caller's
     command pointer if we have to reinit the controller and the data
     structures get reallocated.  (The REALLOCATED flag will be set
     in the softc if that has happened.)

   o In every place that calls wait_command(), make sure we handle
     the case where the command is NULL after the call.

   o The mpr(4) driver has mpr_request_polled() which can also
     reinitialize the card.  Also check for reallocation there.

  Reviewed by: scottl, slm
  Sponsored by: Spectra Logic

  ------------------------------------------------------------------------

6 years agoMFC r322550:
kib [Fri, 18 Aug 2017 07:00:00 +0000 (07:00 +0000)]
MFC r322550:
Typo, the '-6' option selects inet6.

6 years agobsdgrep: bump version number to 2.6.0 and update copyright information
kevans [Thu, 17 Aug 2017 17:17:28 +0000 (17:17 +0000)]
bsdgrep: bump version number to 2.6.0 and update copyright information

MFC r319132: bsdgrep: bump version number and add Kyle Evans copyright

The following changes have been made over the last couple of months:

Features:

 - With bsdgrep -r, the working directory is implied if no directory is
   specified
 - bsdgrep will now behave as bsdgrep -r does when it's named rgrep
 - bsdgrep now understands -z/--null-data to use \0 as EOL
 - GNU regex compatibility is now indicated with a "GNU compatible" in
   the version string

Fixes:

 - --mmap no longer hangs when coming across an EOF without an
   accompanying EOL
 - -o/--color matching generally improved, now produces earliest /
   longest matches
 - Context output now more closely aligns with GNU grep
 - Zero-length matches no longer exhibit broken behavior
 - Every output line now honors -b/-H/-n flags

Tests have been added for previous regressions as well as other
previously untested behaviors.

Various other fixes have been commited, and refactoring for further /
later improvements has taken place.

(The original submission changed the version string to 2.5.2, but I
decided to use 2.6.0 to reflect the addition of new features.)

MFC r320754: Update copyright e-mail address to @FreeBSD.org address

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r318916: bsdgrep: use safer sizeof() construct
kevans [Thu, 17 Aug 2017 17:13:15 +0000 (17:13 +0000)]
MFC r318916: bsdgrep: use safer sizeof() construct

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r322383:
markj [Thu, 17 Aug 2017 17:11:59 +0000 (17:11 +0000)]
MFC r322383:
Make vm_page_sunbusy() assert that the page is unlocked.

6 years agoMFC r318914: bsdgrep: correct assumptions to prepare for chunking
kevans [Thu, 17 Aug 2017 17:09:28 +0000 (17:09 +0000)]
MFC r318914: bsdgrep: correct assumptions to prepare for chunking

Correct a couple of minor BSD grep assumptions that are valid for line
processing but not future chunk-based processing.

Approved by: emaste (mentor, blanket MFC)

6 years agobsdgrep: fix build when linking against libgnuregex
kevans [Thu, 17 Aug 2017 13:48:46 +0000 (13:48 +0000)]
bsdgrep: fix build when linking against libgnuregex

MFC r322618: bsdgrep: cast pmatch.rm_so to fix build when linking against
libgnuregex

Approved by: emaste (mentor)

6 years agoMFC r322494:
kib [Thu, 17 Aug 2017 10:56:22 +0000 (10:56 +0000)]
MFC r322494:
Style.

6 years agoMFC r322493:
kib [Thu, 17 Aug 2017 10:48:56 +0000 (10:48 +0000)]
MFC r322493:
Remove confusion in the line explaining syntax of the msr read.
Specify words order in the display.

6 years agoMFC 322488
sephe [Thu, 17 Aug 2017 05:09:22 +0000 (05:09 +0000)]
MFC 322488
    hyperv: Update copyright for the files changed in 2017

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D11982

6 years agoMFC r318574: bsdgrep: Correct per-line line metadata printing
kevans [Thu, 17 Aug 2017 04:30:31 +0000 (04:30 +0000)]
MFC r318574: bsdgrep: Correct per-line line metadata printing

Metadata printing with -b, -H, or -n flags suffered from a few flaws:

1) -b/offset printing was broken when used in conjunction with -o

2) With -o, bsdgrep did not print metadata for every match/line, just
   the first match of a line

3) There were no tests for this

Address these issues by outputting this data per-match if the -o flag is
specified, and prior to outputting any matches if -o but not --color,
since --color alone will not generate a new line of output for every
iteration over the matches.

To correct -b output, fudge the line offset as we're printing matches.

While here, make sure we're using grep_printline in -A context.  Context
printing should *never* look at the parsing context, just the line.

The tests included do not pass with gnugrep in base due to it exhibiting
similar quirky behavior that bsdgrep previously exhibited.

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r318571: bsdgrep: emit more than MAX_LINE_MATCHES per line
kevans [Thu, 17 Aug 2017 04:26:04 +0000 (04:26 +0000)]
MFC r318571: bsdgrep: emit more than MAX_LINE_MATCHES per line

We should not set an arbitrary cap on the number of matches on a line,
and in any case MAX_LINE_MATCHES of 32 is much too low.  Instead, if we
match more than MAX_LINE_MATCHES, keep processing and matching from the
last match until all are found.

For the regression test, we produce 4096 matches (larger than we expect
we'll ever set MAX_LINE_MATCHES) and make sure we actually get 4096
lines of output with the -o flag.

We'll also make sure that every distinct line is getting its own line
number to detect line metadata not being printed as appropriate along
the way.

PR: 218811
Approved by: emaste (mentor, blanket MFC)

6 years agobsdgrep: fix segfault with --mmap and add relevant test
kevans [Thu, 17 Aug 2017 04:18:31 +0000 (04:18 +0000)]
bsdgrep: fix segfault with --mmap and add relevant test

MFC r318565: bsdgrep: fix segfault with --mmap

r313948 partially fixed --mmap behavior but was incomplete.  This commit
generally reverts it and does it the more correct way- by just consuming
the rest of the buffer and moving on.

MFC r318908: bsdgrep: add --mmap tests

Basic sanity tests as well as coverage for the bug fixed in r318565.

PR: 219402
Approved by: emaste (mentor, blanket MFC)

6 years agobsdgrep: Don't allow negative context flags, add more tests
kevans [Thu, 17 Aug 2017 04:04:42 +0000 (04:04 +0000)]
bsdgrep: Don't allow negative context flags, add more tests

MFC r318302: bsdgrep: don't allow negative -A / -B / -C

Previously, when given a negative -A/-B/-C argument bsdgrep would
overflow the respective context flag(s) and exhibited surprising
behavior.

Fix this by removing unsignedness of Aflag/Bflag and erroring out if
we're given a value < 0.  Also adjust the type used to track 'tail'
context in procfile() so that it accurately reflects the Aflag value
rather than overflowing and losing trailing context.

This also fixes an inconsistency previously existing between -n and
-C "n" behavior.  They are now both limited to LLONG_MAX, to be
consistent.

Add some test cases to make sure grep errors out properly for both
negative context values as well as non-numeric context values rather
than giving bogus matches.

MFC r318317: bsdgrep: add more tests for different binary flags

The existing 'binary' test in netbsd-tests/ does a basic check of the
default treatment for binary behavior, but not much more than that.
Given some opportunity for breakage recently that did not trigger any
failures, add some tests to cover the three different binary file
behaviors (a, -I, -U) and their --binary-files= equivalent values.

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r318004 (ngie): Remove expected failure that no longer fails with gnu
kevans [Thu, 17 Aug 2017 03:56:42 +0000 (03:56 +0000)]
MFC r318004 (ngie): Remove expected failure that no longer fails with gnu
grep in base

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC 322483,322485-322487
sephe [Thu, 17 Aug 2017 03:48:50 +0000 (03:48 +0000)]
MFC 322483,322485-322487

322483
    hyperv/hn: Update VF's ibytes properly under transparent VF mode.

    While, I'm here add comment about why updating VF's imcast stat is
    not necessary.

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D11948

322485
    hyperv/hn: Fix/enhance receiving path when VF is activated.

    - Update hn(4)'s stats properly for non-transparent mode VF.
    - Allow BPF tapping to hn(4) for non-transparent mode VF.
    - Don't setup mbuf hash, if 'options RSS' is set.
      In Azure, when VF is activated, TCP SYN and SYN|ACK go through hn(4)
      while the rest of segments and ACKs belonging to the same TCP 4-tuple
      go through the VF.  So don't setup mbuf hash, if a VF is activated
      and 'options RSS' is not enabled.  hn(4) and the VF may use neither
      the same RSS hash key nor the same RSS hash function, so the hash
      value for packets belonging to the same flow could be different!
    - Disable LRO.
      hn(4) will only receive broadcast packets, multicast packets, TCP
      SYN and SYN|ACK (in Azure), LRO is useless for these packet types.
      For non-transparent, we definitely _cannot_ enable LRO at all, since
      the LRO flush will use hn(4) as the receiving interface; i.e.
      hn_ifp->if_input(hn_ifp, m).

    While I'm here, remove unapplied comment and minor style change.

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D11978

322486
    hyperv/hn: Minor cleanup

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D11979

322487
    hyperv/hn: Re-set datapath after synthetic parts reattached.

    Do this even for non-transparent mode VF. Better safe than sorry.

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D11981

6 years agoMFC r322356: Mark PROFILE option as broken when targetting mips64
emaste [Thu, 17 Aug 2017 01:31:37 +0000 (01:31 +0000)]
MFC r322356: Mark PROFILE option as broken when targetting mips64

The assembly in sys/mips/include/profile.h will only work for o32 ABI.

Submitted by: Alexander Richardson

6 years agoMFC r317705: bsdgrep: avoid use of magic number for REG_NOSPEC
kevans [Wed, 16 Aug 2017 22:00:56 +0000 (22:00 +0000)]
MFC r317705: bsdgrep: avoid use of magic number for REG_NOSPEC

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r322280:
kp [Wed, 16 Aug 2017 19:52:31 +0000 (19:52 +0000)]
MFC r322280:
pf_get_sport(): Prevent possible endless loop when searching for an unused nat port

This is an import of Alexander Bluhm's OpenBSD commit r1.60,
the first chunk had to be modified because on OpenBSD the
'cut' declaration is located elsewhere.

Upstream report by Jingmin Zhou:
https://marc.info/?l=openbsd-pf&m=150020133510896&w=2

OpenBSD commit message:
 Use a 32 bit variable to detect integer overflow when searching for
 an unused nat port.  Prevents a possible endless loop if high port
 is 65535 or low port is 0.
 report and analysis Jingmin Zhou; OK sashan@ visa@
Quoted from: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/net/pf_lb.c

PR: 221201
Submitted by: Fabian Keil <fk@fabiankeil.de>
Obtained from: OpenBSD via ElectroBSD

6 years agobsdgrep: fix -w flag matching with an empty pattern
kevans [Wed, 16 Aug 2017 18:00:32 +0000 (18:00 +0000)]
bsdgrep: fix -w flag matching with an empty pattern

MFC r317703: bsdgrep: fix -w flag matching with an empty pattern

-w flag matching with an empty pattern was generally 'broken', allowing
matches to occur on any line whether or not it actually matches -w
criteria.

This fix required a good amount of refactoring to address.  procline()
is altered to *only* process the line and return whether it was a match
or not, necessary to be able to short-circuit the whole function in case
of this matchall flag. -m flag handling is moved out as well because it
suffers from the same fate as context handling if we bypass any actual
pattern matching.

The matching context (matches, mostly) didn't previously exist outside
of procline(), so we go ahead and create context object for file
processing bits to pass around.  grep_printline() was created due to
this, for the scenarios where the matches don't actually matter and we
just want to print a line or two, a la flushing the context queue and
no -o or --color specified.

Damage from this broken behavior would have been mitigated by the fact
that it is unlikely users would invoke grep -w with an empty pattern.

This was identified while checking PR 105221 for problems it this may
cause in BSD grep, but PR 105221 is *not* a report of this behavior.

MFC r317741: bsdgrep: correct uninitialized variable introduced in r317703

MFC r317842: bsdgrep: don't ouptut matches with -c, -l, -L

Refactoring done in r317703 broke -c, -l, and -L flags implying
suppression of match printing.  Fortunately this is just a matter of not
doing any printing of the resulting matches and context printing was not
broken in this refactoring.

Add some regression tests since this area may still see further
refactoring, include different context flags as well even though they
were not broken in this case.

PR: 219077
Approved by: emaste (mentor, blanket MFC)

6 years agobsdgrep: fix escape map building when using TRE (BSD_GREP_FASTMATCH)
kevans [Wed, 16 Aug 2017 17:54:29 +0000 (17:54 +0000)]
bsdgrep: fix escape map building when using TRE (BSD_GREP_FASTMATCH)

MFC r317700: bsdgrep: use calloc where appropriate in grep's tre-fastmatch

Also apply style(9) to a related NULL check.

MFC r317701: bsdgrep: correct test sense from r317700

Kyle's change in review D10098 was correct. I introduced the error when
extracting a portion of that change.

MFC r317704: bsdgrep: fix escape map building for multibyte strings

In BSD grep, fix escape map building in the regex parser. It was
previously using memory not explicitly initialized, and the MBS escape
map was being built based on a version of the pattern with escapes
already parsed out.

This is Kyle's change, but I restored the broken style that already
exists in this file.

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r317678: bsdgrep: Add GNU compatible version string indicator
kevans [Wed, 16 Aug 2017 17:46:45 +0000 (17:46 +0000)]
MFC r317678: bsdgrep: Add GNU compatible version string indicator

As reported in r218614 it's useful to have an indication of whether or not
BSD grep was built with GNU_GREP_COMPAT.

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r317665: bsdgrep: fix -w -v matching improperly with certain patterns
kevans [Wed, 16 Aug 2017 17:42:39 +0000 (17:42 +0000)]
MFC r317665: bsdgrep: fix -w -v matching improperly with certain patterns

-w and -v flag matching was mostly functional but had some minor
problems:

1. -w flag processing only allowed one iteration through pattern
   matching on a line. This was problematic if one pattern could match
   more than once, or if there were multiple patterns and the earliest/
   longest match was not the most ideal, and

2. Previous work "fixed" things to not further process a line if the
   first iteration through patterns produced no matches. This is clearly
   wrong if we're dealing with the more restrictive -w matching.

#2 breakage could have also occurred before recent broad rewrites, but
it would be more arbitrary based on input patterns as to whether or not
it actually affected things.

Fix both of these by forcing a retry of the patterns after advancing
just past the start of the first match if we're doing more restrictive
-w matching and we didn't get any hits to start with. Also move -v flag
processing outside of the loop so that we have a greater change to match
in the more restrictive cases. This wasn't strictly wrong, but it could
be a little more error prone.

While here, introduce some regressions tests for this behavior and fix
some excessive wrapping nearby that hindered readability. GNU grep
passes these new tests.

PR: 218467, 218811
Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r317254: bsdgrep: add BSD_GREP_FASTMATCH knob for built-in fastmatch
kevans [Wed, 16 Aug 2017 17:38:37 +0000 (17:38 +0000)]
MFC r317254: bsdgrep: add BSD_GREP_FASTMATCH knob for built-in fastmatch

Bugs have been found in the fastmatch implementation as used in bsdgrep.
Some have been fixed (r316495) while fixes for others are in review
(D10098).

In comparison with the fastmatch implementation, Kyle Evans found that:

- regex(3)'s performance with literal expressions offers a speed
  improvement over fastmatch

- regex(3)'s performance, both with simple BREs and EREs, seems to be
  comparable

The regex implementation was imported in r226035, and the commit message
reports:

    This is a temporary solution until the whole regex library is
    not replaced so that BSD grep development can continue and the
    backported code gets some review and testing. This change only
    improves scalability slightly, there is no big performance boost
    yet but several minor bugs have been found and fixed.

Introduce a WITH_/WITHOUT_BSD_GREP_FASTMATCH knob to support testing
of both approaches.

Regenerate src.conf(5) as per the original commit

PR: 175314, 194823
Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r303444 (ed): Call basename() in a portable way.
kevans [Wed, 16 Aug 2017 13:06:26 +0000 (13:06 +0000)]
MFC r303444 (ed): Call basename() in a portable way.

Pull a copy of the filename string before calling basename(). Change the
loop to not return on its own, so we can put a free() statement at the
bottom.

Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r322328:
ae [Wed, 16 Aug 2017 12:01:22 +0000 (12:01 +0000)]
MFC r322328:
  Make user supplied data checks a bit stricter.

  key_msg2sp() is used for parsing data from setsockopt(IP[V6]_IPSEC_POLICY)
  call. This socket option is usually used to configure IPsec bypass for
  socket. Only privileged user can set this socket option.
  The message syntax is described here
   http://www.kame.net/newsletter/20021210/

  and our libipsec is usually used to create the correct request.
  Add additional checks:
  * that sadb_x_ipsecrequest_len is not out of bounds of user supplied buffer
  * that src/dst's sa_len is the same
  * that 2*sa_len is not out of bounds of user supplied buffer
  * that 2*sa_len fits into bounds of sadb_x_ipsecrequest

  Reported by: Ilja van Sprundel

6 years agoMFC r322309, r322316:
mav [Wed, 16 Aug 2017 10:30:23 +0000 (10:30 +0000)]
MFC r322309, r322316:
Use "Ibex Peak" codename for "5 Series/3400 Series" chipsets.

This is shorter and unifies naming with later chipsets.

6 years agoMFC r322308: Add new Intel Lewisburg and Union Point chipset PCI IDs.
mav [Wed, 16 Aug 2017 10:28:34 +0000 (10:28 +0000)]
MFC r322308: Add new Intel Lewisburg and Union Point chipset PCI IDs.

While there, polish some old AHCI ones, since they are still reused.

6 years agoMFC r321899
truckman [Wed, 16 Aug 2017 07:59:57 +0000 (07:59 +0000)]
MFC r321899

Lower the amd64 shared page, which contains the signal trampoline,
from the top of user memory to one page lower on machines with the
Ryzen (AMD Family 17h) CPU.  This pushes ps_strings and the stack
down by one page as well.  On Ryzen there is some sort of interaction
between code running at the top of user memory address space and
interrupts that can cause FreeBSD to either hang or silently reset.
This sounds similar to the problem found with DragonFly BSD that
was fixed with this commit:
  https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b48dd28447fc8ef62fbc963accd301557fd9ac20
but our signal trampoline location was already lower than the address
that DragonFly moved their signal trampoline to.  It also does not
appear to be related to SMT as described here:
  https://www.phoronix.com/forums/forum/hardware/processors-memory/955368-some-ryzen-linux-users-are-facing-issues-with-heavy-compilation-loads?p=955498#post955498

  "Hi, Matt Dillon here. Yes, I did find what I believe to be a
   hardware issue with Ryzen related to concurrent operations. In a
   nutshell, for any given hyperthread pair, if one hyperthread is
   in a cpu-bound loop of any kind (can be in user mode), and the
   other hyperthread is returning from an interrupt via IRETQ, the
   hyperthread issuing the IRETQ can stall indefinitely until the
   other hyperthread with the cpu-bound loop pauses (aka HLT until
   next interrupt). After this situation occurs, the system appears
   to destabilize. The situation does not occur if the cpu-bound
   loop is on a different core than the core doing the IRETQ. The
   %rip the IRETQ returns to (e.g. userland %rip address) matters a
   *LOT*. The problem occurs more often with high %rip addresses
   such as near the top of the user stack, which is where DragonFly's
   signal trampoline traditionally resides. So a user program taking
   a signal on one thread while another thread is cpu-bound can cause
   this behavior. Changing the location of the signal trampoline
   makes it more difficult to reproduce the problem. I have not
   been because the able to completely mitigate it. When a cpu-thread
   stalls in this manner it appears to stall INSIDE the microcode
   for IRETQ. It doesn't make it to the return pc, and the cpu thread
   cannot take any IPIs or other hardware interrupts while in this
   state."
since the system instability has been observed on FreeBSD with SMT
disabled.  Interrupts to appear to play a factor since running a
signal-intensive process on the first CPU core, which handles most
of the interrupts on my machine, is far more likely to trigger the
problem than running such a process on any other core.

Also lower sv_maxuser to prevent a malicious user from using mmap()
to load and execute code in the top page of user memory that was made
available when the shared page was moved down.

Make the same changes to the 64-bit Linux emulator.

PR: 219399
Reported by: nbe@renzel.net
Reviewed by: kib
Reviewed by: dchagin (previous version)
Tested by: nbe@renzel.net (earlier version)
Differential Revision: https://reviews.freebsd.org/D11780

6 years agobsdgrep: Use implied working directory for -r if no directories are passed
kevans [Wed, 16 Aug 2017 01:45:53 +0000 (01:45 +0000)]
bsdgrep: Use implied working directory for -r if no directories are passed

MFC r317050: bsdgrep: for -r, use the working directory if none specified

This is more sensible than the previous behaviour of grepping stdin,
and matches newer GNU grep behaviour.

MFC r317300 (ngie): Only expect :grep_r_implied to pass with bsdgrep(1)

The test fails with gnu grep from base and ports.

MFC r319002 (ngie): :rgrep : use atf-check to check the exit code/save the
output of grep -r instead of calling grep -r without it, and saving the
output to a file

This ensures that any errors thrown via grep -r are caught, not lost, and
uses existing atf-sh idioms for saving files.

PR: 216307
Approved by: emaste (mentor, blanket MFC)
Relnotes: yes

6 years agoMFC r317051: bsdgrep: remove output separators between overlapping segments
kevans [Wed, 16 Aug 2017 01:03:04 +0000 (01:03 +0000)]
MFC r317051: bsdgrep: remove output separators between overlapping segments

Make bsdgrep more sensitive to context overlaps.  If it's printing
context that either overlaps or is immediately adjacent to another bit
of context, don't print a separator.

- Non-overlapping segments no longer have two separators between them

- Overlapping segments no longer have separators between them with
  overlapping sections repeated

Approved by: emaste (mentor, blanket MFC)

6 years agobsdgrep: Revise tests based on recent fixes and future changes
kevans [Wed, 16 Aug 2017 00:55:56 +0000 (00:55 +0000)]
bsdgrep: Revise tests based on recent fixes and future changes

MFC r317297: Remove the expected failures for :context and :context2 with
bsdgrep(1)

They're no longer needed after recent fixes made to bsdgrep(1).

MFC r317299: Add more sanity tests for grep, egrep, and fgrep

The test suite currently lacks basic sanity checks to ensure that egrep,
fgrep, and grep are actually matching the right expression types, i.e.
passing the right flags to regcomp(3). Amend the test suite to make sure
that not only are the individual versions doing the right thing, but also
that we don't have some kind of frankenregex situation happening where egrep
is accepting a BRE or grep an ERE.

I've chosen to not expand the 'basic' test but to add the 'grep_sanity'
checks to their own test case since this is testing for more than just
'grep matches things', but actual expression types.

MFC r317694: bsdgrep: revise test case which will soon become a failure

Work in progress (D10315) is going to make egrep_empty_invalid an
actually invalid regex, to be consistent with the equivalent BRE "{"
behavior, when using regex(3).

Any non-0 exit value is acceptable, depending on how the installed grep
interprets the expression. GNU grep interprets it as non-matching, and
in the future BSD grep will interpret it is an error.

Approved by: emaste (mentor, blanket MFC)

6 years agobsdgrep: add -z/--null-data support and update NLS catalogs accordingly
kevans [Wed, 16 Aug 2017 00:47:53 +0000 (00:47 +0000)]
bsdgrep: add -z/--null-data support and update NLS catalogs accordingly

MFC r317049: bsdgrep: add -z/--null-data support

-z treats input and output data as sequences of lines terminated by a
zero byte instead of a newline. This brings it more in line with GNU grep
and brings us closer to passing the current tests with BSD grep.

MFC r317679: bsdgrep: correct nls usage data after r317049

r317049 added -z/--null-data to BSD grep but missed the update to nls
catalogs.

Approved by: emaste (mentor, blanket MFC)
Relnotes: yes

6 years agoMFC r316542: bsdgrep: Handle special case of single-byte NUL pattern
kevans [Wed, 16 Aug 2017 00:42:51 +0000 (00:42 +0000)]
MFC r316542: bsdgrep: Handle special case of single-byte NUL pattern

PR: 202022
Approved by: emaste (mentor, blanket MFC)

6 years agoMFC r316495: bsdgrep(1): Fix errors with invalid expressions
kevans [Wed, 16 Aug 2017 00:40:13 +0000 (00:40 +0000)]
MFC r316495: bsdgrep(1): Fix errors with invalid expressions

Invalid expressions with an ultimate compiled pattern length of 0 (e.g.,
"grep -E {") were not taken into account and caused a segfault while trying
to fill in the good suffix table.

Approved by: emaste (mentor, blanket MFC)