219701 Commits

Author SHA1 Message Date
Simon J. Gerraty
2e01909b58 MFC bmake-20180222
PR:		226678
Submitted by:	sjg
2018-03-20 15:57:52 +00:00
Ed Maste
66d99b21a9 MFC r319510: xz: set noexec stack flag on FreeBSD 2018-03-20 02:54:32 +00:00
Dimitry Andric
c302e70cb9 Merge retpoline support from the upstream llvm, clang and lld 5.0
branches.  Upstream merge revisions:

  r324007: merging r323155 for llvm
  r324009: merging r323915 for llvm
  r324012: merging r323155 for clang
  r324025: merging r323155 for lld, with modifications to
           handle int3 fill
  r324026: merging r323288 for lld
  r325088: merging r324449 for llvm
  r325089: merging r324645 for llvm
  r325090: merging r325049 for llvm
  r325091: merging r325085 for llvm

Original commit messages:

r323155 (by Chandler Carruth):

  Introduce the "retpoline" x86 mitigation technique for variant #2 of
  the speculative execution vulnerabilities disclosed today,
  specifically identified by CVE-2017-5715, "Branch Target Injection",
  and is one of the two halves to Spectre.

  Summary:
  First, we need to explain the core of the vulnerability. Note that
  this is a very incomplete description, please see the Project Zero
  blog post for details:
  https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

  The basis for branch target injection is to direct speculative
  execution of the processor to some "gadget" of executable code by
  poisoning the prediction of indirect branches with the address of
  that gadget. The gadget in turn contains an operation that provides a
  side channel for reading data. Most commonly, this will look like a
  load of secret data followed by a branch on the loaded value and then
  a load of some predictable cache line. The attacker then uses timing
  of the processors cache to determine which direction the branch took
  *in the speculative execution*, and in turn what one bit of the
  loaded value was. Due to the nature of these timing side channels and
  the branch predictor on Intel processors, this allows an attacker to
  leak data only accessible to a privileged domain (like the kernel)
  back into an unprivileged domain.

  The goal is simple: avoid generating code which contains an indirect
  branch that could have its prediction poisoned by an attacker. In
  many cases, the compiler can simply use directed conditional branches
  and a small search tree. LLVM already has support for lowering
  switches in this way and the first step of this patch is to disable
  jump-table lowering of switches and introduce a pass to rewrite
  explicit indirectbr sequences into a switch over integers.

  However, there is no fully general alternative to indirect calls. We
  introduce a new construct we call a "retpoline" to implement indirect
  calls in a non-speculatable way. It can be thought of loosely as a
  trampoline for indirect calls which uses the RET instruction on x86.
  Further, we arrange for a specific call->ret sequence which ensures
  the processor predicts the return to go to a controlled, known
  location. The retpoline then "smashes" the return address pushed onto
  the stack by the call with the desired target of the original
  indirect call. The result is a predicted return to the next
  instruction after a call (which can be used to trap speculative
  execution within an infinite loop) and an actual indirect branch to
  an arbitrary address.

  On 64-bit x86 ABIs, this is especially easily done in the compiler by
  using a guaranteed scratch register to pass the target into this
  device.  For 32-bit ABIs there isn't a guaranteed scratch register
  and so several different retpoline variants are introduced to use a
  scratch register if one is available in the calling convention and to
  otherwise use direct stack push/pop sequences to pass the target
  address.

  This "retpoline" mitigation is fully described in the following blog
  post: https://support.google.com/faqs/answer/7625886

  We also support a target feature that disables emission of the
  retpoline thunk by the compiler to allow for custom thunks if users
  want them.  These are particularly useful in environments like
  kernels that routinely do hot-patching on boot and want to hot-patch
  their thunk to different code sequences. They can write this custom
  thunk and use `-mretpoline-external-thunk` *in addition* to
  `-mretpoline`. In this case, on x86-64 thu thunk names must be:
  ```
    __llvm_external_retpoline_r11
  ```
  or on 32-bit:
  ```
    __llvm_external_retpoline_eax
    __llvm_external_retpoline_ecx
    __llvm_external_retpoline_edx
    __llvm_external_retpoline_push
  ```

  And the target of the retpoline is passed in the named register, or
  in the case of the `push` suffix on the top of the stack via a
  `pushl` instruction.

  There is one other important source of indirect branches in x86 ELF
  binaries: the PLT. These patches also include support for LLD to
  generate PLT entries that perform a retpoline-style indirection.

  The only other indirect branches remaining that we are aware of are
  from precompiled runtimes (such as crt0.o and similar). The ones we
  have found are not really attackable, and so we have not focused on
  them here, but eventually these runtimes should also be replicated
  for retpoline-ed configurations for completeness.

  For kernels or other freestanding or fully static executables, the
  compiler switch `-mretpoline` is sufficient to fully mitigate this
  particular attack. For dynamic executables, you must compile *all*
  libraries with `-mretpoline` and additionally link the dynamic
  executable and all shared libraries with LLD and pass `-z
  retpolineplt` (or use similar functionality from some other linker).
  We strongly recommend also using `-z now` as non-lazy binding allows
  the retpoline-mitigated PLT to be substantially smaller.

  When manually apply similar transformations to `-mretpoline` to the
  Linux kernel we observed very small performance hits to applications
  running typical workloads, and relatively minor hits (approximately
  2%) even for extremely syscall-heavy applications. This is largely
  due to the small number of indirect branches that occur in
  performance sensitive paths of the kernel.

  When using these patches on statically linked applications,
  especially C++ applications, you should expect to see a much more
  dramatic performance hit. For microbenchmarks that are switch,
  indirect-, or virtual-call heavy we have seen overheads ranging from
  10% to 50%.

  However, real-world workloads exhibit substantially lower performance
  impact. Notably, techniques such as PGO and ThinLTO dramatically
  reduce the impact of hot indirect calls (by speculatively promoting
  them to direct calls) and allow optimized search trees to be used to
  lower switches. If you need to deploy these techniques in C++
  applications, we *strongly* recommend that you ensure all hot call
  targets are statically linked (avoiding PLT indirection) and use both
  PGO and ThinLTO. Well tuned servers using all of these techniques saw
  5% - 10% overhead from the use of retpoline.

  We will add detailed documentation covering these components in
  subsequent patches, but wanted to make the core functionality
  available as soon as possible. Happy for more code review, but we'd
  really like to get these patches landed and backported ASAP for
  obvious reasons. We're planning to backport this to both 6.0 and 5.0
  release streams and get a 5.0 release with just this cherry picked
  ASAP for distros and vendors.

  This patch is the work of a number of people over the past month:
  Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
  due to the time sensitive nature of landing this and the need to
  backport it. Huge thanks to everyone who helped out here, and
  everyone at Intel who helped out in discussions about how to craft
  this. Also, credit goes to Paul Turner (at Google, but not an LLVM
  contributor) for much of the underlying retpoline design.

  Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

  Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini,
  hiraditya, llvm-commits

  Differential Revision: https://reviews.llvm.org/D41723

r323915 (by Chandler Carruth):

  [x86] Make the retpoline thunk insertion a machine function pass.

  Summary:
  This removes the need for a machine module pass using some deeply
  questionable hacks. This should address PR36123 which is a case where
  in full LTO the memory usage of a machine module pass actually ended
  up being significant.

  We should revert this on trunk as soon as we understand and fix the
  memory usage issue, but we should include this in any backports of
  retpolines themselves.

  Reviewers: echristo, MatzeB

  Subscribers: sanjoy, mcrosier, mehdi_amini, hiraditya, llvm-commits

  Differential Revision: https://reviews.llvm.org/D42726

r323288 (by Rui Ueyama):

  Fix retpoline PLT header size for i386.

  Differential Revision: https://reviews.llvm.org/D42397

r324449 (by Chandler Carruth):

  [x86/retpoline] Make the external thunk names exactly match the names
  that happened to end up in GCC.

  This is really unfortunate, as the names don't have much rhyme or
  reason to them. Originally in the discussions it seemed fine to rely
  on aliases to map different names to whatever external thunk code
  developers wished to use but there are practical problems with that
  in the kernel it turns out. And since we're discovering this
  practical problems late and since GCC has already shipped a release
  with one set of names, we are forced, yet again, to blindly match
  what is there.

  Somewhat rushing this patch out for the Linux kernel folks to test
  and so we can get it patched into our releases.

  Differential Revision: https://reviews.llvm.org/D42998

r324645 (by David Woodhouse):

  [X86] Support 'V' register operand modifier

  This allows the register name to be printed without the leading '%'.
  This can be used for emitting calls to the retpoline thunks from
  inline asm.

r325049 (by Reid Kleckner):

  [X86] Use EDI for retpoline when no scratch regs are left

  Summary:
  Instead of solving the hard problem of how to pass the callee to the
  indirect jump thunk without a register, just use a CSR. At a call
  boundary, there's nothing stopping us from using a CSR to hold the
  callee as long as we save and restore it in the prologue.

  Also, add tests for this mregparm=3 case. I wrote execution tests for
  __llvm_retpoline_push, but they never got committed as lit tests,
  either because I never rewrote them or because they got lost in merge
  conflicts.

  Reviewers: chandlerc, dwmw2

  Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits

  Differential Revision: https://reviews.llvm.org/D43214

r325085 (by Reid Kleckner):

  [X86] Remove dead code from retpoline thunk generation

Differential Revision: https://reviews.freebsd.org/D14720
2018-03-19 18:36:43 +00:00
David Bright
1c65f9a729 MFC r331015:
Modify rc.d/fsck to handle new status from fsck/fsck_ffs

r328013 introduced a new error code from fsck_ffs that indicates that
it could not completely fix the file system; this happens when it
prints the message PLEASE RERUN FSCK. However, this status can happen
when fsck is run in "preen" mode and the rc.d/fsck script does not
handle that error code. Modify rc.d/fsck so that if "fsck -p"
("preen") returns the new status code (16) it will run "fsck -y", as
it currently does for a status code of 8 (the "standard error exit").

Reported by:    markj
Sponsored by:   Dell EMC
2018-03-19 17:37:51 +00:00
Marius Strobl
b87c55a1e6 MFC: r328834
o Let rtld(1) set up psABI user trap handlers prior to executing the
  objects' init functions instead of doing the setup via a constructor
  in libc as the init functions may already depend on these handlers
  to be in place. This gets us rid of:
  - the undefined order in which libc constructors as __guard_setup()
    and jemalloc_constructor() are executed WRT __sparc_utrap_setup(),
  - the requirement to link libc last so __sparc_utrap_setup() gets
    called prior to constructors in other libraries (see r122883).
  For static binaries, crt1.o still sets up the user trap handlers.
o Move misplaced prototypes for MD functions in to the MD prototype
  section of rtld.h.
o Sprinkle nitems().
2018-03-19 14:28:20 +00:00
Andrey V. Elsukov
07d7c22ed1 MFC r330792:
Do not try to reassemble IPv6 fragments in "reass" rule.

  ip_reass() expects IPv4 packet and will just corrupt any IPv6 packets
  that it gets. Until proper IPv6 fragments handling function will be
  implemented, pass IPv6 packets to next rule.

  PR:		170604
2018-03-19 09:52:16 +00:00
Eitan Adler
dfd60eec3c MFC r324860:
Modernise this man page somewhat.

1. Add a reference to a good 3rd party list of compatible cables, but
provide suggestions for 'known good' vendors.

2. Change IP-based USB host-host example to a modern Ethernet one which
works 'out of box' with current Linux systems.

3. Explain that USB 3.0 is host-host, even though point-to-point soft
Ethernet can be achieved.
2018-03-19 07:37:36 +00:00
Eitan Adler
6068217bb5 MFC r324858:
Add Prolific PL27A1 USB 3.0 Host-Host device to udbp(4).

Tested with a Plugable cable in VirtualBox against Linux 4.11.
2018-03-19 07:37:13 +00:00
Eitan Adler
027617a884 MFC r324806:
Use the .Fx macro consistently.

Sponsored by:	Spectra Logic Corp
2018-03-19 07:35:35 +00:00
Eitan Adler
03e9a73b78 MFC r322674:
Add Thunderbolt Apple interfaces to the bge(4) supported list.
Document message reported by kernel upon removal in DIAGNOSTIC section.
Document shortcomings in BUGS section.
2018-03-19 07:34:24 +00:00
Eitan Adler
92625aa1d8 MFC r320178:
Add some device IDs for Intel Denverton SoCs.
2018-03-19 07:33:12 +00:00
Eitan Adler
7b42266e9f MFC r320268,r320276:
ipfw: dummynet: Add 'G' and 'g' suffix for bandwidth configuration/display
2018-03-19 07:28:54 +00:00
Eitan Adler
43c4d418da MFC r322013:
Document -w flag is an extension to POSIX.

PR:		201937
2018-03-19 07:08:14 +00:00
Eitan Adler
e6ba55b5f7 MFC r320992,r320993:
Add a complete example to tsearch(3)
2018-03-19 07:07:03 +00:00
Eitan Adler
d6f43a6966 MFC r315986:
Fix 3 entries in mode tables related to mono and 90-column text modes.
Newer VGAs don't support any mono modes, but bugs in the tables created
2 virtual mono modes (#45 90x43 and #112 80x43) that behaved more
strangely than crashing.  90-column modes are tweaked 80-column ones
and also fail to work on newer VGAs.  #45 did crash (hang) on some
hardware.
2018-03-19 07:03:02 +00:00
Eitan Adler
0a1c65e828 MFC r313818:
Small inclusion guard comment fix.
2018-03-19 07:00:15 +00:00
Eitan Adler
6dd24c0296 MFC r325112:
Add P5010/P5010E for completeness
2018-03-19 06:57:41 +00:00
Eitan Adler
00d6e6ad87 MFC r325113:
Add Microchip 1-MBit SPI flash ID

Used on the AmigaOne X5000.
2018-03-19 06:56:30 +00:00
Eitan Adler
af72a002eb MFC r326183:
Add stdio.h to the synopsis for sysdecode functions that take a FILE *.
2018-03-19 06:55:26 +00:00
Eitan Adler
cbac25941f MFC r326356:
Replace a reference to a license in another file with the license text.

The relevant file was recently renamed, so the reference was stale.
In addition, explicit licenses are more typical in our sources.
2018-03-19 06:54:53 +00:00
Eitan Adler
e29cd18bc9 MFC r326437:
Correct history for Unix 2nd Edition through 6th Edition for the
system calls. Man pages are missing for v2 and v5, so any entries for
those versions were inferred by new implementations of these functions
in libc.
2018-03-19 06:54:16 +00:00
Eitan Adler
8a15c8d792 MFC r326859:
Add identifier for POWER9 CPU to CPU list

Without the identifier in the list booting FreeBSD results in printing the
following (from a PowerKVM boot):

cpu0: Unknown PowerPC CPU revision 0x1201, 2550.00 MHz

For now, add the same feature list as POWER8.  As new capabilities are added to
support POWER9 specific features, they will be added to this.

PR:		224344
2018-03-19 06:49:49 +00:00
Eitan Adler
1733f6eefe MFC r316422:
Remove checks that background (bg) colors are not bright and buggy
attempts to keep them that way.  The bg brightness bit is interpreted
as blinking in some modes, but it would barely be useful to disallow
setting it when it would give blinking in code which knew when that
is.  The old code mostly knew this wrong, and added handling errors.
It is in fact impossible to know, since future mode switches may
change the meaning of the bit many times on the screen and in history.

Old versions of vidcontrol disallowed bg color numbers >= 8 in all
cases.  This is very VGA/syscons-centric.  Syscons uses the VGA defaults
of blinking fg instead of bright bg in text mode and bright bg in
graphics mode.  On VGA, this is very easy to toggle at any time, and
vt blows away the VGA text mode default at boot time.

r146736 changed this to try to allow bg color numbers in graphics mode
only.  This is even more VGA/syscons-centric, and there are many bugs
in this, and many nearby bugs in the parser.  These are increased or
decreased by differences and bugs in vt and teken.

Perhaps the most obvious bug was that almost any vidcontrol command
which changes any color or the mode causes an error if the initial fg
color is bright.  E.g., in syscons text mode, after "vidcontrol
lightwhite" to make the fg bright, another "vidcontrol lightwhite" is
rejected and buggy fixup code changes the fg to white.  This is because
the bright fg color creates a bright bg color for the phantom reverse
video attribute, so was rejected.  (The reverse video attribute is
phantom because teken ignores the user's setting of it and simply
reverses the fg attributes to create the bg attributes.  Sometimes
some layer masks off the brightness/blinking bit, but not here.)

Perhaps the next most obvious one was that "vidcontrol lightgreen
lightblue" was misparsed as 2 settings of the fg instead of 1 setting
of the fg and 1 invalid setting of the bg.  This is because the
parser supports an undocumented syntax with many parsing bugs (an
ambiguity gives this one).

I recently fix bugs in teken that broke setting of bright fg's and
bg's in the normal way.  This gave more settings of then, so the old
bugs showed up more often.
2018-03-19 06:45:40 +00:00
Eitan Adler
86db3e9da1 MFC r327184:
Change the remaining files using my personnal email address to my freebsd one
2018-03-19 06:40:11 +00:00
Eitan Adler
bce8e6f7cf MFC r328300:
copyright.h: Update license text to 'THE AUTHOR'

This matches the license text at
https://www.freebsd.org/copyright/freebsd-license.html
2018-03-19 06:37:59 +00:00
Eitan Adler
8d5843b804 MFC r305306:
dhclient: add support for interface-mtu (26)

Make dhclient set interface MTU if it was provided.

This version implements MTU setting in dhclient itself before it runs
dhclient-script.

PR:		206721
2018-03-19 04:16:37 +00:00
Eitan Adler
b0172ea05b MFC r313264:
Avoid using Sun compiler-specific flags.
2018-03-19 04:08:22 +00:00
Eitan Adler
ad0763d0f9 MFC r328262:
This comment is bogus. This is a legit release.
2018-03-19 04:06:18 +00:00
Eitan Adler
17e8b8c7de MFC r328162:
Improve support for USB based 3G/4G/5G dongles from Huawei.

PR:		192345
2018-03-19 04:03:55 +00:00
Eitan Adler
de33879f6f MFC r328586:
Use more verbose panic messages.
2018-03-19 03:57:14 +00:00
Eitan Adler
9c638456c3 MFC r328785:
Use standard 2-clause license where copyright is held by the FreeBSD Foundation
2018-03-19 03:55:42 +00:00
Eitan Adler
38f3fc4c0d MFC r312887:
Hide unneeded message under bootverbose.
2018-03-19 03:53:46 +00:00
Eitan Adler
8b9814bc88 MFC r328640:
psm: Add a kludge to support 0x46 identity middle byte Synaptics touchpads

Most synaptics touchpads return 0x47 in middle byte in responce to identify
command as stated in p.4.4 of "Synaptics PS/2 TouchPad Interfacing Guide".
But some devices e.g. found on HP EliteBook 9470m return 0x46 here.
Allow them to be identified as Synaptics as well as 0x47.
ExtendedQueries return incorrect data on such a touchpads so we ignore
their result and set conservative defaults.

PR:		222667
2018-03-19 03:49:54 +00:00
Eitan Adler
de65032ead MFC r328638:
psm(4): Reduce psm watchdog verbosity

Modern touchpads do not issue interrupts on inactivity so "lost interrupt"
message became annoying spam nowadays. This change quiets the message
if debug.psm.loglevel=5 (or less) is set in /boot/loader.conf

Approved by:	gonzo
2018-03-19 03:47:46 +00:00
Eitan Adler
febf842b92 MFC r328636:
psm(4): Add support for HP EliteBook 1040 ForcePads.

ForcePads do not have any physical buttons, instead they detect click
based on finger pressure. Forcepads erroneously report button click
if there are 2 or more fingers on the touchpad breaking multifinger
gestures. To workaround this start reporting a click only after
4 consecutive single touch packets has been received. Skip these packets
in case more contacts appear.

PR:		223369
2018-03-19 03:46:12 +00:00
Eitan Adler
0ec90cc99a MFC r326249:
Update intro(6) - remove hint that doesn't work, add explicit list
of games instead, and mention the "bsdgames" port.
2018-03-19 03:44:19 +00:00
Eitan Adler
cff35fdbbb MFC r303812:
Use a more conventional spelling of "breakpoint".
2018-03-19 03:38:59 +00:00
Eitan Adler
f96355eafa MFC r326482:
lib/msun: remove trailing whitespace from e_pow.c
2018-03-19 03:37:00 +00:00
Eitan Adler
b3243c1137 MFC r314622:
As suggested by several people, note that I prefer to communicate by email.
2018-03-19 03:34:40 +00:00
Eitan Adler
947bf79216 MFC r326913:
Sync with NetBSD's /usr/share/dict/words, with the exception of quim
due to its vulgar nature.
2018-03-19 03:28:24 +00:00
Eitan Adler
aff7f693b6 MFC r320210:
join(1): Fix field ordering for -v output

Per POSIX, join(1) (in modes other than -o) is a concatenation of selected
character fields.  The joined field is first, followed by fields in the
order they occurred in the input files.

Our join(1) utility previously handled this correctly for lines with a match
in the other file.  But it failed to order output fields correctly for
unmatched lines, printed in -a and -v modes.

A simple test case is:

$ touch a
$ echo "2 1" > b
$ join -v2 -2 2 a b
1 2

PR:		217711
2018-03-19 03:22:43 +00:00
Eitan Adler
f9c99f9a10 MFC r303412:
Remove myself from kern_timeout.c yeah!
2018-03-19 03:20:35 +00:00
Eitan Adler
1157081961 MFC r325091:
Prefer using https over http
2018-03-19 03:19:29 +00:00
Eitan Adler
b48be7ff78 MFC r317798:
bnxt: Add support for new Broadcom 100Gb adapter BCM57454
2018-03-19 03:15:33 +00:00
Eitan Adler
85b2465588 MFC r317570:
editline.3: Add missing argument to H_SET description

The H_SET operation of the history() function takes an int argument which is
the position of the item to which the cursor should be moved to.
2018-03-19 03:13:42 +00:00
Eitan Adler
bbf077f8c7 MFC r304725:
Bring datasheet URL up to date.
2018-03-19 03:06:27 +00:00
Eitan Adler
0f53be494d MFC r314052:
Document what the different flags mean for locking.
2018-03-19 03:04:19 +00:00
Eitan Adler
e4914acb7e MFC r322991:
Fix a day-one typo in tty.4 - the sysctls in question are "tty", not "tk"
2018-03-19 02:46:17 +00:00
Eitan Adler
b68403d22e MFC r323135:
Spelling.
2018-03-19 02:44:42 +00:00
Eitan Adler
e2ee4e555f MFC r326601:
mdocml: Add IEEE Std 1003.1-2008, 2016 edition

Also document IEEE Std 1003.1-2008, 2013 edition in mdoc(7) (as well as the
2016 edition).
2018-03-19 02:43:20 +00:00