]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFC r306657, r306673, r306726, r307737, r309366, r310135, r323990, r324414
ian [Fri, 23 Mar 2018 16:15:07 +0000 (16:15 +0000)]
MFC r306657, r306673, r306726, r307737, r309366, r310135, r323990, r324414

r306657:
libcapsicum: introduce Capsicum helpers

Capsicum helpers are a set of inline functions which goal is to reduce
duplicated patterns used to Capsicumize applications.

Reviewed by: cem, AllanJude, bapt, ed, emaste
Differential Revision: https://reviews.freebsd.org/D8013

r306673:
libcapsicum: limit stderr

Don't limit stdout twice, instead limit stderr.

Pointed out by: rpokala@

r306726:
Add man pages for Capsicum helpers.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D8154

r307737:
Fix few sentence in the man page.

Pointed out by: wblock

r309366:
capsicum_helpers: Squash errors from closed fds

Squash EBADF from closed stdin, stdout, or stderr in caph_limit_stdio().
Any program used during special shell scripts may commonly be forked
from a parent process with closed standard stream.  Do the common sense
thing for this common use.

Reported by: Iblis Lin <iblis AT hs.ntnu.edu.tw>
Reviewed by: oshogbo@ (earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D8657

r310135:
capsicum_helpers: Add LOOKUP flag

Add a helper routine for opening a directory that is restricted to being
used for opening relative files as stdio streams.

I think this will really help basic adaptation of multi-file programs to
Capsicum. Rather than having each program initialize a rights object and
ioctl/fcntl arrays for their root fd for relative opens, consolidate in the
logical place.

Reviewed by: oshogbo@
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D8743

r323990:
capsicum_helpers: Add SEEK to default stdio rights set

PR: 219173
Sponsored by: Dell EMC Isilon

r324414:
capsicum_helpers: Add EVENT to default stdio rights set

Without it, calling caph_limit_stdio(3) breaks Irssi.

Reviewed by: oshogbo
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D12622

6 years agoMFC r331333: Fix kernel memory disclosure in drm_infobufs
emaste [Fri, 23 Mar 2018 02:37:08 +0000 (02:37 +0000)]
MFC r331333: Fix kernel memory disclosure in drm_infobufs

drm_infobufs() has a structure on the stack, fills it out and copies it
to userland.  There are 2 elements in the struct that are not filled out
and left uninitialized.  This will leak uninitialized kernel stack data
to userland.

Submitted by: Domagoj Stolfa <ds815@cam.ac.uk>
Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Security: Kernel memory disclosure (798)

6 years agoMFC r331339: Correct signedness bug in drm_modeset_ctl
emaste [Fri, 23 Mar 2018 02:33:30 +0000 (02:33 +0000)]
MFC r331339: Correct signedness bug in drm_modeset_ctl

drm_modeset_ctl() takes a signed in from userland, does a boundscheck,
and then uses it to index into a structure and write to it.  The
boundscheck only checks upper bound, and never checks for nagative
values.  If the int coming from userland is negative [after conversion]
it will bypass the boundscheck, perform a negative index into an array
and write to it, causing memory corruption.

Note that this is in the "old" drm driver; this issue does not exist
in drm2.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Reviewed by: cem
Sponsored by: The FreeBSD Foundation

6 years agoFix VERSATILEPB boot after r331402
gonzo [Fri, 23 Mar 2018 01:43:27 +0000 (01:43 +0000)]
Fix VERSATILEPB boot after r331402

r331402 MFCed switch from custom DTS to upstream one. stable/11 version
still has main bus compatibility as "arm,amba-bus" while in Linux and HEAD
it has been changed to "simple-bus". simplebus(4) supports only the latter
so VERSATILEPB boot was broken by r331402. To fix this make manual change
to stable/11 version of versatile-ab.dts

6 years agoMFC r316370-r316371
gonzo [Fri, 23 Mar 2018 01:37:31 +0000 (01:37 +0000)]
MFC r316370-r316371

r316370:
[versatilepb] Convert VERSATILEPB kernel to INTRNG and switch to upstream DTB

Scope of this change is somewhat larger than just converting to INTRNG.
The reason for this is that INTRNG support required switching from custom
to upstream DTS because custom DTS didn't have interrup routing information.
This switch caused rewrite of PCI and CLCD drivers and adding SCM module.
List of changes in this commit:

- Enable INTRNG and switch to versatile-pb.dts

- Add SCM driver that controls various peripheral devices like LCD or
  PCI controller. Previously registers required for power-up and
  configuring peripherals were part of their respective nodes. Upstream
  DTS has dedicated node for SCM

- Convert PL190 driver to INTRNG

- Convert Versatile SIC (secondary interrupt controller) to INTRNG

- Refactor CLCD driver to use SCM API to power up and configuration

- Refactor PCI driver to use SCM API to enable controller

- Refactor PCI driver to use interrupt map provided in DTS for
  interrupt routing. As a result it fixes broken IRQ routing and
  it's no longer required to run QEMU with "-global versatile_pci.broken-irq-mapping=1"
  command-line arguments

r316371:
[versatilepb] Fix keyboard driver after switching to upstream DTS

FreeBSD's DTS contained only one PL050 node and driver considered it to
be PS/2 keyboard. In reality PL050 is a PS/2 port that pushes bytes to/from
the periphers connected to it. New DTS contains two nodes and QEMU emulates
keyboard connected to port #0 and mouse connected to port #1. Since there
is no way to say what's connected to port by checking DTS we hardcode
this knowledge in the driver: it assumes keyboard on port #0 and ignores
port #1 altogether.

Also QEMU defaults emulated keyboard to scan code set 2 while driver used
to work with scan code set 1 so when initializing driver make sure keyboard
is switched to scan code set 1

6 years agoMFC r329694: MFV r324198: 8081 Compiler warnings in zdb
mav [Thu, 22 Mar 2018 23:58:05 +0000 (23:58 +0000)]
MFC r329694: MFV r324198: 8081 Compiler warnings in zdb

illumos/illumos-gate@3f7978d02b206a6ebc5652c91aa9f42da6fbe00c
https://github.com/illumos/illumos-gate/commit/3f7978d02b206a6ebc5652c91aa9f42da6fbe00c

https://www.illumos.org/issues/8081
  zdb(8) is full of minor problems that generate compiler warnings. On FreeBSD,
  which uses -WError, the only way to build it is to disable all compiler
  warnings. This makes it much harder to detect newly introduced bugs. We should
  cleanup all the warnings.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Alan Somers <asomers@gmail.com>

6 years agoMFC r329691: MFV r322231:
mav [Thu, 22 Mar 2018 23:56:53 +0000 (23:56 +0000)]
MFC r329691: MFV r322231:
8430 dir_is_empty_readdir() doesn't properly handle error from fdopendir()

illumos/illumos-gate@ba6e7e6505150388de6dc6a88741164118a421bf
https://github.com/illumos/illumos-gate/commit/ba6e7e6505150388de6dc6a88741164118a421bf

https://www.illumos.org/issues/8430
  we should close dirfd if fdopendir() fails.

Reviewed by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Sowrabha Gopal <sowrabha.gopal@delphix.com>

6 years agoMFC r329690: MFV r319737: 6939 add sysevents to zfs core for commands
mav [Thu, 22 Mar 2018 23:56:17 +0000 (23:56 +0000)]
MFC r329690: MFV r319737: 6939 add sysevents to zfs core for commands

illumos/illumos-gate@ce1577b04976f1d8bb5f235b6eaaab15b46a3068
https://github.com/illumos/illumos-gate/commit/ce1577b04976f1d8bb5f235b6eaaab15b46a3068

https://www.illumos.org/issues/6939
  Originally created https://smartos.org/bugview/OS-4489
       sysevents should be fired in the kernel from ZFS whenever a command
       is run that is logged in zpool history.
  Example output
  Terminal 1
  root - gz sunos ~ # zfs create zones/foobar
  root - gz sunos ~ # zfs set quota=10g zones/foobar
  root - gz sunos ~ # zfs destroy zones/foobar
  Terminal 2
  root - gz sunos ~ # sysevent EC_zfs
  nvlist version: 0
      date = 2016-04-28T14:50:08.964Z
      vendor = SUNW
      publisher = zfs
      class = EC_zfs
      subclass = ESC_ZFS_history_event
      pid = 0
      data = (embedded nvlist)
      nvlist version: 0
          pool_name = zones
          pool_guid = 0x40c964e8f9a7a694
          history_record = (embedded nvlist)
          nvlist version: 0
              dsname = zones/foobar
              dsid = 0x1525
              history internal str =
              internal_name = create
              history txg = 0x4c4ef3

Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Reviewed by: Josh Wilsdon <jwilsdon@joyent.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed by: Alan Somers <asomers@gmail.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
Author: Dave Eddy <dave@daveeddy.com>

6 years agoMFC r329683: MFV r319736: 6396 remove SVM
mav [Thu, 22 Mar 2018 23:55:00 +0000 (23:55 +0000)]
MFC r329683: MFV r319736: 6396 remove SVM

illumos/illumos-gate@5f10ef697f250374b7b917e10961c4e02d4e3112
https://github.com/illumos/illumos-gate/commit/5f10ef697f250374b7b917e10961c4e02d4e3112

https://www.illumos.org/issues/6396
  LVM = SVM = Solaris Volume Manager
  dead code and not using with ZFS based platform.

Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: Yuri Pankov <yuri.pankov@nexenta.com>

6 years agoMFC r329681: MFV r318941: 7446 zpool create should support efi system partition
mav [Thu, 22 Mar 2018 23:54:14 +0000 (23:54 +0000)]
MFC r329681: MFV r318941: 7446 zpool create should support efi system partition

illumos/illumos-gate@7855d95b30fd903e3918bad5a29b777e765db821
https://github.com/illumos/illumos-gate/commit/7855d95b30fd903e3918bad5a29b777e765db821

https://www.illumos.org/issues/7446
  Since we support whole-disk configuration for boot pool, we also will need
  whole disk support with UEFI boot and for this, zpool create should create efi-
  system partition.
  I have borrowed the idea from oracle solaris, and introducing zpool create -
  B switch to provide an way to specify that boot partition should be created.
  However, there is still an question, how big should the system partition be.
  For time being, I have set default size 256MB (thats minimum size for FAT32
  with 4k blocks). To support custom size, the set on creation "bootsize"
  property is created and so the custom size can be set as: zpool create B -
  o bootsize=34MB rpool c0t0d0
  After pool is created, the "bootsize" property is read only. When -B switch is
  not used, the bootsize defaults to 0 and is shown in zpool get output with
  value ''. Older zfs/zpool implementations are ignoring this property.
  https://www.illumos.org/rb/r/219/

Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Reviewed by: Yuri Pankov <yuri.pankov@gmail.com>
Approved by: Dan McDonald <danmcd@kebe.com>
Author: Toomas Soome <tsoome@me.com>

This commit makes no sense for FreeBSD, that is why I blocked the option,
but it should be good to stay closer to upstream.

6 years agoMFC r329668: MFV r316918:
mav [Thu, 22 Mar 2018 23:53:18 +0000 (23:53 +0000)]
MFC r329668: MFV r316918:
7990 libzfs: snapspec_cb() does not need to call zfs_strdup()

illumos/illumos-gate@d8584ba6fb7a5e46da1725845b99ae5fab5a4baf
https://github.com/illumos/illumos-gate/commit/d8584ba6fb7a5e46da1725845b99ae5fab5a4baf

https://www.illumos.org/issues/7990
  The snapspec_cb() callback function in libzfs does not need to call zfs_strdup().

Reviewed by: Yuri Pankov <yuri.pankov@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
Author: Marcel Telka <marcel@telka.sk>

6 years agoMFC r329667: MFV r316902:
mav [Thu, 22 Mar 2018 23:52:37 +0000 (23:52 +0000)]
MFC r329667: MFV r316902:
7745 print error if lzc_* is called before libzfs_core_init

illumos/illumos-gate@7c13517fff71be473e47531ef4330160c042bedc
https://github.com/illumos/illumos-gate/commit/7c13517fff71be473e47531ef4330160c042bedc

https://www.illumos.org/issues/7745
  The problem is that consumers of `libZFS_Core` that forget to call
  `libzfs_core_init()` before calling any other function of the library
  are having a hard time realizing their mistake. The library's internal
  file descriptor is declared as global static, which is ok, but it is not
  initialized explicitly; therefore, it defaults to 0, which is a valid
  file descriptor. If `libzfs_core_init()`, which explicitly initializes
  the correct fd, is skipped, the ioctl functions return errors that do
  not have anything to do with `libZFS_Core`, where the problem is
  actually located.
  Even though assertions for that existed within `libZFS_Core` for debug
  builds, they were never enabled because the `-DDEBUG` flag was missing
  from the compiler flags.
  This patch applies the following changes:
  1. It adds `-DDEBUG` for debug builds of `libZFS_Core` and `libzfs`,
         to enable their assertions on debug builds.
  2. It corrects an assertion within `libzfs`, where a function had
         been spelled incorrectly (`zpool_prop_unsupported()`) and nobody
         knew because the `-DDEBUG` flag was missing, and the preprocessor
         was taking that part of the code away.
  3. The library's internal fd is initialized to `-1` and `VERIFY`
         assertions have been placed to check that the fd is not equal to
         `-1` before issuing any ioctl. It is important here to note, that
         the `VERIFY` assertions exist in both debug and non-debug builds.
  4. In `libzfs_core_fini` we make sure to never increment the
         refcount of our fd below 0, and also reset the fd to `-1` when no
         one refers to it. The reason for this, is for the rare case that
         the consumer closes all references but then calls one of the
         library's functions without using `libzfs_core_init()` first, and
         in the mean time, a previous call to `open()` decided to reuse
         our previous fd. This scenario would have passed our assertion in

Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>

6 years agoMFC r329665: MFV r316901:
mav [Thu, 22 Mar 2018 23:51:39 +0000 (23:51 +0000)]
MFC r329665: MFV r316901:
7730 libzfs`add_config() leaks config nvl when reading spare/l2cache devices

illumos/illumos-gate@105686550ee9cbf5d033166a8a2a5a763667d436
https://github.com/illumos/illumos-gate/commit/105686550ee9cbf5d033166a8a2a5a763667d436

https://www.illumos.org/issues/7730
  antares:root:~# mdb /usr/sbin/zpool
  > ::sysbp _exit
  > ::run import
     pool: data
       id: 2093977168778024605
    state: ONLINE
   action: The pool can be imported using its name or numeric identifier.
   config:

          data        ONLINE
            c6t0d0    ONLINE
            c6t1d0    ONLINE
          cache
            c6t2d0
  mdb: stop on entry to _exit
  mdb: target stopped at:
  0xfee556ba:     nop
  mdb: You've got symbols!
  Loading modules: [ ld.so.1 libumem.so.1 libc.so.1 libtopo.so.1 libavl.so.1
  libnvpair.so.1 ]
  > ::findleaks -d
  BYTES             LEAKED VMEM_SEG CALLER
  4096                  10 fda7b000 MMAP
  8192                   1 fea8d000 MMAP
  8192                   1 fe76d000 MMAP
  8192                   1 fe66e000 MMAP
  4096                   1 fe570000 MMAP
  8192                   1 fe470000 MMAP
  4096                   1 fe372000 MMAP
  4096                   1 fe273000 MMAP

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Serapheim Dimitropoulos <serapheim@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Yuri Pankov <yuri.pankov@nexenta.com>

6 years agoMFC r329664: MFV r316893:
mav [Thu, 22 Mar 2018 23:50:43 +0000 (23:50 +0000)]
MFC r329664: MFV r316893:
7604 if volblocksize property is the default, it displays as "-" rather than 8K

illumos/illumos-gate@4d86c0eab246bdfddc2dd52410ba808433bd6266
https://github.com/illumos/illumos-gate/commit/4d86c0eab246bdfddc2dd52410ba808433bd6266

https://www.illumos.org/issues/7604
  If a zvol has the default setting for the "volblocksize" property, it is
  8KB. However, it is displayed as "-" (not present), rather than "8K".
  The problem was introduced by:
  commit 25228e830e86924a41243343b1de9daf2d7dd43a
      Author: Matthew Ahrens &lt;mahrens@delphix.com&gt;
      Date:   Thu Nov 17 14:37:24 2016 -0800
  7571 non-present readonly numeric ZFS props do not have default value
  which changed changed get_numeric_property() to indicate that readonly
  default properties are not present. However, zfs_prop_readonly() returns
  TRUE for both readonly and set-once properties (e.g. volblocksize).
  Amusingly, that commit essentially reverted:
  6900484 default volblocksize is no longer being reported correctly
  from November 2009. However, that change was not correct either; the
  correct solution is to only do this check for "truly readonly" (i.e. not
  setonce) properties.
  $ zfs list -t volume -o name,volblocksize
      NAME
  VOLBLOCK
      domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
  archive            -
      domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
  datafile           -
      domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
  external           -
      rpool/dump
  128K
      rpool/swap
  4K
      rpool/swap1
  ===============================================================================

Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Matthew Ahrens <mahrens@delphix.com>

6 years agoMFC r329663: MFV r316876: 7542 zfs_unmount failed with EZFS_UNSHARENFSFAILED
mav [Thu, 22 Mar 2018 23:49:54 +0000 (23:49 +0000)]
MFC r329663: MFV r316876: 7542 zfs_unmount failed with EZFS_UNSHARENFSFAILED

illumos/illumos-gate@09c9e6dc9b69d10b771bb87e01040ec320a0bfd3
https://github.com/illumos/illumos-gate/commit/09c9e6dc9b69d10b771bb87e01040ec320a0bfd3

https://www.illumos.org/issues/7542
  libshare keeps a cached copy of the sharetab listing in memory, which can
  become out of date if shares are destroyed or created while leaving a libzfs
  handle open. This results in a spurious unmounting failure when an NFS share
  exists but isn't in the stale libshare cache.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matt Amdur <matt.amdur@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Chris Williamson <chris.williamson@delphix.com>

6 years agoMFC r329661: MFV r316875: 7336 vfork and O_CLOEXEC causes zfs_mount EBUSY
mav [Thu, 22 Mar 2018 23:48:07 +0000 (23:48 +0000)]
MFC r329661: MFV r316875: 7336 vfork and O_CLOEXEC causes zfs_mount EBUSY

illumos/illumos-gate@873c4903a52d089cd8234b79d24f5a3fc3bccc82
https://github.com/illumos/illumos-gate/commit/873c4903a52d089cd8234b79d24f5a3fc3bccc82

https://www.illumos.org/issues/7336
  We can run into a problem where we call into zfs_mount, which in turn calls
  is_dir_empty, which opens the directory to try and make sure it's empty. The
  issue with the current approach is that it holds the directory open while it
  traverses it with readdir, which, due to subtle interaction with the Java JVM,
  vfork, and exec can cause a tricky race condition resulting in zfs_mount
  failures.
  The approach to resolving the issue in this patch is to drop the usage of
  readdir altogether, and instead rely on the fact that ZFS stores the number of
  entries contained in a directory using the st_size field of the stat structure.
  Thus, if the directory in question is a ZFS directory, we can check to see if
  it's empty by calling stat() and inspecting the st_size field of structure
  returned.
  ===============================================================================
  The root cause appears to be an interesting race between vfork, exec, and
  zfs_mount's usage of O_CLOEXEC when calling openat. Here's what is going on:
  1. We call zfs_mount, and this in turn calls openat to check if the directory
  is empty, which results in opening the directory we're trying to mount onto,
  and increment v_count.
  2. As we're in the middle of reading the directory, vfork is called by the JVM
  and proceeds to exec the jspawnhelper utility. As a result of the vfork, we
  take an additional hold on the directory, which increments v_count a second
  time. The semantics of vfork mean the parent process will wait for the child
  process to exit or exec before the parent can continue; at this point the
  parent is in the middle of zfs_mount, reading the directory to determine if
  it's empty or not.
  3. The child process exec-ing jspawnhelper gets to the relvm call within
  exec_args (which is called by exec_common). relvm is the function that releases
  the parent process, allowing the parent to proceed. The problem is, at this
  point of calling relvm, the child hasn't yet called close_exec which is
  responsible for closing the file descriptors inherited from the parent process

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Author: Prakash Surya <prakash.surya@delphix.com>

6 years agoMFC r329659: MFV r316873: 7233 dir_is_empty should open directory with CLOEXEC
mav [Thu, 22 Mar 2018 23:47:04 +0000 (23:47 +0000)]
MFC r329659: MFV r316873: 7233 dir_is_empty should open directory with CLOEXEC

illumos/illumos-gate@d420209d9c807f782c1d31f5683be74798142198
https://github.com/illumos/illumos-gate/commit/d420209d9c807f782c1d31f5683be74798142198

https://www.illumos.org/issues/7233
  This fixes a race where one thread is executing zfs_mount() while another
  thread forks and execs. If the fork occurs while the directory is open, the
  child process will inherit (but not necessarily close immediately) the open fd
  for the directory, preventing the mount.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Alex Reece <alex@delphix.com>

6 years agoMFC r329658: MFV r316872: 7502 ztest should run zdb with -G (debug mode)
mav [Thu, 22 Mar 2018 23:45:46 +0000 (23:45 +0000)]
MFC r329658: MFV r316872: 7502 ztest should run zdb with -G (debug mode)

illumos/illumos-gate@c3c65d17f7b6689bbd6568a1a1fcc0c4a3bac127
https://github.com/illumos/illumos-gate/commit/c3c65d17f7b6689bbd6568a1a1fcc0c4a3bac127

https://www.illumos.org/issues/7502
  Right now ztest executes zdb without -G, so when it has errors, the messages
  are often not very helpful:
  Executing zdb -bccsv -d -U /rpool/tmp/zpool.cache ztest
  zdb: can't open 'ztest': Operation not supported
  ztest: '/usr/sbin/amd64/zdb -bccsv -d -U /rpool/tmp/zpool.cache ztest' exit
  code 1
  With -G, we'd have:
  /usr/sbin/amd64/zdb -bccsv -d -U /rpool/tmp/zpool.cache -G ztest
  zdb: can't open 'ztest': Operation not supported

  ZFS_DBGMSG(zdb):
  spa_open_common: opening ztest
  spa_load(ztest): LOADING
  spa_load(ztest): FAILED: unable to parse config [error=48]
  spa_load(ztest): UNLOADING
  Which indicates where the error came from

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Approved by: Gordon Ross <gordon.w.ross@gmail.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFC r329657 (by asomers): Fix memory leaks in zdb introduced by r329508
mav [Thu, 22 Mar 2018 23:45:01 +0000 (23:45 +0000)]
MFC r329657 (by asomers): Fix memory leaks in zdb introduced by r329508

Reported by:    Coverity
CID:            1386185

6 years agoMFC r329628: MFC r316910: 7812 Remove gender specific language
mav [Thu, 22 Mar 2018 23:43:48 +0000 (23:43 +0000)]
MFC r329628: MFC r316910: 7812 Remove gender specific language

illumos/illumos-gate@48bbca816818409505a6e214d0911fda44e622e3
https://github.com/illumos/illumos-gate/commit/48bbca816818409505a6e214d0911fda44e622e3

https://www.illumos.org/issues/7812
  This change removes all gendered language that did not refer specifically
  to an individual person or pet. The convention taken was to use
  variations on "they" when referring to users and/or human beings, while
  using "it" when referring to code, functions, and/or libraries.
  Additionally, we took the liberty to fix up any whitespace issues that
  were found in any files that were already being modified.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Steve Gonczi <steve.gonczi@delphix.com>
Reviewed by: Chris Williamson <chris.williamson@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Daniel Hoffman <dj.hoffman@delphix.com>

6 years agoMFC r329625: MFV r307315:
mav [Thu, 22 Mar 2018 23:43:05 +0000 (23:43 +0000)]
MFC r329625: MFV r307315:
7301 zpool export -f should be able to interrupt file freeing

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Author: Alek Pinchuk <alek@nexenta.com>

Closes #175

6 years agoMFC r329623: MFV r302649: 7016 arc_available_memory is not 32-bit safe
mav [Thu, 22 Mar 2018 23:41:26 +0000 (23:41 +0000)]
MFC r329623: MFV r302649: 7016 arc_available_memory is not 32-bit safe

illumos/illumos-gate@0dd053d7d890618ea1fc697b07de364e69eb4190
https://github.com/illumos/illumos-gate/commit/0dd053d7d890618ea1fc697b07de364e69eb4190

https://www.illumos.org/issues/7016
  upstream DLPX-39446 arc_available_memory is not 32-bit safe
  https://github.com/delphix/delphix-os/commit/
  6b353ea3b8a1610be22e71e657d051743c64190b
  related to this upstream:
  DLPX-38547 delphix engine hang
  https://github.com/delphix/delphix-os/commit/
  3183a567b3e8c62a74a65885ca60c86f3d693783
  DLPX-38547 delphix engine hang (fix static global)
  https://github.com/delphix/delphix-os/commit/
  22ac551d8ef085ad66cc8f65e51ac372b12993b9
  DLPX-38882 system hung waiting on free segment
  https://github.com/delphix/delphix-os/commit/
  cdd6beef7548cd3b12f0fc0328eeb3af540079c2

Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Gordon Ross <gordon.ross@nexenta.com>
Author: Prakash Surya <prakash.surya@delphix.com>

6 years agoMFC r329508: MFV r324198: 8081 Compiler warnings in zdb
mav [Thu, 22 Mar 2018 23:39:49 +0000 (23:39 +0000)]
MFC r329508: MFV r324198: 8081 Compiler warnings in zdb

illumos/illumos-gate@3f7978d02b206a6ebc5652c91aa9f42da6fbe00c
https://github.com/illumos/illumos-gate/commit/3f7978d02b206a6ebc5652c91aa9f42da6fbe00c

https://www.illumos.org/issues/8081
  zdb(8) is full of minor problems that generate compiler warnings. On FreeBSD,
  which uses -WError, the only way to build it is to disable all compiler
  warnings. This makes it much harder to detect newly introduced bugs. We should
  cleanup all the warnings.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Alan Somers <asomers@gmail.com>

6 years agoMFC r329505: MFV r323911:
mav [Thu, 22 Mar 2018 23:38:03 +0000 (23:38 +0000)]
MFC r329505: MFV r323911:
8502 illumos#7955 broke delegated datasets when libshare is not present

illumos/illumos-gate@1c18e8fbd8db41a9fb39bd3ef7a18ee71ece20da
https://github.com/illumos/illumos-gate/commit/1c18e8fbd8db41a9fb39bd3ef7a18ee71ece20da

https://www.illumos.org/issues/8502
  The code in lib/libzfs/common/libzfs_mount.c already basically handles
  the case when libshare is not installed. We just need to not fail in
  zfs_init_libshare_impl.  I tested this in lx and things work as
  expected. I also tested there trying to set sharenfs and sharesmb on
  the delegated dataset. Neither is allowed from within a zone.  The
  spew of msgs from a native zone is not ZFS specific. I see the same
  spew simply running the share command.

Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Jerry Jelinek <jerry.jelinek@joyent.com>

6 years agoMFC r322794:
gjb [Thu, 22 Mar 2018 17:46:38 +0000 (17:46 +0000)]
MFC r322794:
 Use py-google-compute-engine instead for releasing Google Compute
 Engine (GCE) images with an updated version of Google's tools.

PR: 221714
Sponsored by: The FreeBSD Foundation

6 years agoMFC r325047: dma: fix use-after-free
emaste [Thu, 22 Mar 2018 11:48:14 +0000 (11:48 +0000)]
MFC r325047: dma: fix use-after-free

Sponsored by: The FreeBSD Foundation

6 years agoMFC r322281:
garga [Thu, 22 Mar 2018 10:57:51 +0000 (10:57 +0000)]
MFC r322281:

Add missing parenthesis on error message

Approved by: loos
Sponsored by: Rubicon Communications, LLC (Netgate)

6 years agoMFC r330668: bktr: correct Japan IF frequency
emaste [Thu, 22 Mar 2018 00:54:13 +0000 (00:54 +0000)]
MFC r330668: bktr: correct Japan IF frequency

PR: 36451
Submitted by: Hijiri Umemoto <hijiri at umemoto.org>

6 years agoMFC r330963: Increase ABOUT FIRMWARE command timeout to 5s.
mav [Thu, 22 Mar 2018 00:45:48 +0000 (00:45 +0000)]
MFC r330963: Increase ABOUT FIRMWARE command timeout to 5s.

It seems default timeout of 100ms is not enough for my 2694L card,
while it was perfectly fine for others, even for full-height 2694.

6 years agoFix kernel memory disclosure in svr4_sys_getdents64
emaste [Wed, 21 Mar 2018 23:45:48 +0000 (23:45 +0000)]
Fix kernel memory disclosure in svr4_sys_getdents64

svr4_sys_getdents64() copies a dirent structure to userland.  When
calculating the record length for any given dirent entry alignment is
performed.  However, the aligned bytes are not cleared, this will
trigger an info leak.

Direct commit to stable/11; this code does not exist in HEAD.  This
change to be merged from stable/11 to stable/10.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
MFC after: 3 days
Security: Kernel memory disclosure (797)
Sponsored by: The FreeBSD Foundation

6 years agoMFC 328158,330708: Update kgdb for PTI.
jhb [Wed, 21 Mar 2018 21:10:49 +0000 (21:10 +0000)]
MFC 328158,330708: Update kgdb for PTI.

328158:
Recognize mchk_calltrap as a trapframe generator.

Should have been included in r328157.

330708:
Use the trapframe unwinder for "fast_syscall_common".

6 years agoMFC r328087 (by fabient):
kib [Wed, 21 Mar 2018 19:33:00 +0000 (19:33 +0000)]
MFC r328087 (by fabient):
Fix pmcstat exit from kernel introduced by r325275.

PR: 223689

6 years agoMFC r330929: pkgbase: Fix post-install script for kernel packages
kevans [Wed, 21 Mar 2018 15:43:57 +0000 (15:43 +0000)]
MFC r330929: pkgbase: Fix post-install script for kernel packages

kernel.ucl uses a hardcoded boot/kernel for kldxref, which is the incorrect
directory when we're installing extra kernels that aren't the "default"
kernel (placed at boot/kernel).

Fix this by instead using a new %KERNELDIR% that we now replace in
Makefile.inc1 with "kernel" for the default kernel and "kernel.${_kernel}"
for these extra kernels so that, e.g. /boot/kernel.SHIVA, will get properly
kldxref'd upon update and avoid outdated linker.hints.

6 years agoMFC r330891: ubldr: Bump heap size from 512K to 1M
kevans [Wed, 21 Mar 2018 15:42:29 +0000 (15:42 +0000)]
MFC r330891: ubldr: Bump heap size from 512K to 1M

lualoader in itself only uses another ~200K, but there seems to be no reason
not to bump it a little higher to give us some more wiggle room.

With this, I can boot using a menu-enabled lualoader, no problem and
reasonably fast. Some heap usage datapoints from the review:

forthloader, no menus, kernel loaded:
heap base at 0x1203d5b0, top at 0x1208e000, used 330320

lualoader, no menus, kernel loaded:
heap base at 0x42050028, top at 0x420ab000, used 372696

lualoader, menus, kernel loaded:
heap base at 0x42050028, top at 0x420d5000, used 544728

Since then, the no menu case for lualoader should have decreased slightly as
I've made some changes to make sure that it no longer loads any of th emenu
bits with beastie disabled.

While here, split heap size out into a HEAP_SIZE macro.

6 years agoMFC r330793: fix r297857, do not modify CPU extension bits under virtual machines
avg [Wed, 21 Mar 2018 15:09:41 +0000 (15:09 +0000)]
MFC r330793: fix r297857, do not modify CPU extension bits under virtual machines

PR: 213155

6 years agoMFC r330592: MFV r330591: 8984 fix for 6764 breaks ACL inheritance
avg [Wed, 21 Mar 2018 15:07:26 +0000 (15:07 +0000)]
MFC r330592: MFV r330591: 8984 fix for 6764 breaks ACL inheritance

PR: 216886

6 years agoMFC r330374: db_script_exec: use a saved script name when reporting commands executed
avg [Wed, 21 Mar 2018 15:05:08 +0000 (15:05 +0000)]
MFC r330374: db_script_exec: use a saved script name when reporting commands executed

6 years agoMFC 330105:
kp [Wed, 21 Mar 2018 09:57:05 +0000 (09:57 +0000)]
MFC 330105:

pf: Do not flush on reload

pfctl only takes the last '-F' argument into account, so this never did what
was intended.

Moreover, there is no reason to flush rules before reloading, because pf keeps
track of the rule which created a given state. That means that existing
connections will keep being processed according to the rule which originally
created them. Simply reloading the (new) rules suffices. The new rules will
apply to new connections.

PR: 127814
Submitted by: Andreas Longwitz <longwitz at incore.de>

6 years agoMFC r330108:
kp [Wed, 21 Mar 2018 09:55:19 +0000 (09:55 +0000)]
MFC r330108:

pf: Apply $pf_flags when verifying the pf.conf file

When checking the validity of the pf.conf file also include the user supplied
pf_flags. These flags might overrule macros or specify anchors, which we will
apply when actually applying the pf.conf file, so we must also take them into
account when verifying the validity.

Submitted by: Andreas Longwitz <longwitz at incore.de>

6 years agoMFC r330745:
ian [Tue, 20 Mar 2018 21:02:42 +0000 (21:02 +0000)]
MFC r330745:

Make root mount timeout logic work for filesystems other than ufs.

The vfs.mountroot.timeout tunable and .timeout directive in a mount.conf(5)
file allow specifying a wait timeout for the device(s) hosting the root
filesystem to become usable.  The current mechanism for waiting for devices
and detecting their availability can't be used for zfs-hosted filesystems.
See the comment #20 in the PR for some expanded detail on these points.

This change adds retry logic to the actual root filesystem mount.  That is,
insted of relying on device availability using device name lookups, it uses
the kernel_mount() call itself to detect whether the filesystem can be
mounted, and loops until it succeeds or the configured timeout is exceeded.

These changes are based on the patch attached to the PR, but it's rewritten
enough that all mistakes belong to me.

PR: 208882

6 years agoMFC r330023, r330028: Add MAXWAIT for configuring pxeboot timeout
kevans [Tue, 20 Mar 2018 17:41:54 +0000 (17:41 +0000)]
MFC r330023, r330028: Add MAXWAIT for configuring pxeboot timeout

r330023: libsa: Add MAXWAIT to net for establishing max total timeout

Current timeout behavior is to progress in timeout values from MINTMO to
MAXTMO in MINTMO steps before finally timing out. This results in a fairly
long time before operations finally timeout, which may not be ideal for some
use-cases.

Add MAXWAIT that may be configured along with MINTMO/MAXTMO. If we attempt
to start our send/recv cycle over again but MAXWAIT > 0 and MAXWAIT seconds
have already passed, then go ahead and timeout.

This is intended for those that just want to say "timeout after 180 seconds"
rather than calculate and tweak MINTMO/MAXTMO to get their desired timeout.
The default is 0, or "progress from MINTMO to MAXTMO with no exception."

This has been modified since review to allow for it to be defined via CFLAGS
and doing appropriate error checking. Future work may add some Makefile foo
to respect LOADER_NET_MAXWAIT if it's specified in the environment and pass
it in as MAXWAIT accordingly.

r330028: libsa: Partially revert r330023

The removal of tmo >= MAXTMO check should not have been done; this is
specifically what handles timeout if MAXWAIT == 0.

6 years agoMFC r330612: stand/ficl: Fix testmain
kevans [Tue, 20 Mar 2018 17:39:50 +0000 (17:39 +0000)]
MFC r330612: stand/ficl: Fix testmain

testmain is a userland application intended to be built with standard
headers and whatnot, which we broke.

Fix it by having the testmain build clobber cflags, reducing it to just the
set of defines/includes it needs to build.

6 years agoMFC r330675
sbruno [Tue, 20 Mar 2018 17:27:00 +0000 (17:27 +0000)]
MFC r330675

Update tcp_lro with tested bugfixes from Netflix and LLNW:

    rrs - Lets make the LRO code look for true dup-acks and window update acks
          fly on through and combine.
    rrs - Make the LRO engine a bit more aware of ack-only seq space. Lets not
          have it incorrectly wipe out newer acks for older acks when we have
          out-of-order acks (common in wifi environments).
    jeggleston - LRO eating window updates

Based on all of the above I think we are RFC compliant doing it this way:

https://tools.ietf.org/html/rfc1122

section 4.2.2.16

"Note that TCP has a heuristic to select the latest window update despite
possible datagram reordering; as a result, it may ignore a window update with
a smaller window than previously offered if neither the sequence number nor the
acknowledgment number is increased."

Submitted by: Kevin Bowling <kevin.bowling@kev009.com>
Sponsored by: NetFlix and Limelight Networks

6 years agoMFC bmake-20180222
sjg [Tue, 20 Mar 2018 15:57:52 +0000 (15:57 +0000)]
MFC bmake-20180222

PR: 226678
Submitted by: sjg

6 years agoMFC r319510: xz: set noexec stack flag on FreeBSD
emaste [Tue, 20 Mar 2018 02:54:32 +0000 (02:54 +0000)]
MFC r319510: xz: set noexec stack flag on FreeBSD

6 years agoMerge retpoline support from the upstream llvm, clang and lld 5.0
dim [Mon, 19 Mar 2018 18:36:43 +0000 (18:36 +0000)]
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

6 years agoMFC r331015:
dab [Mon, 19 Mar 2018 17:37:51 +0000 (17:37 +0000)]
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

6 years agoMFC: r328834
marius [Mon, 19 Mar 2018 14:28:20 +0000 (14:28 +0000)]
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().

6 years agoMFC r330792:
ae [Mon, 19 Mar 2018 09:52:16 +0000 (09:52 +0000)]
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

6 years agoMFC r324860:
eadler [Mon, 19 Mar 2018 07:37:36 +0000 (07:37 +0000)]
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.

6 years agoMFC r324858:
eadler [Mon, 19 Mar 2018 07:37:13 +0000 (07:37 +0000)]
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.

6 years agoMFC r324806:
eadler [Mon, 19 Mar 2018 07:35:35 +0000 (07:35 +0000)]
MFC r324806:

Use the .Fx macro consistently.

Sponsored by: Spectra Logic Corp

6 years agoMFC r322674:
eadler [Mon, 19 Mar 2018 07:34:24 +0000 (07:34 +0000)]
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.

6 years agoMFC r320178:
eadler [Mon, 19 Mar 2018 07:33:12 +0000 (07:33 +0000)]
MFC r320178:

Add some device IDs for Intel Denverton SoCs.

6 years agoMFC r320268,r320276:
eadler [Mon, 19 Mar 2018 07:28:54 +0000 (07:28 +0000)]
MFC r320268,r320276:

ipfw: dummynet: Add 'G' and 'g' suffix for bandwidth configuration/display

6 years agoMFC r322013:
eadler [Mon, 19 Mar 2018 07:08:14 +0000 (07:08 +0000)]
MFC r322013:

Document -w flag is an extension to POSIX.

PR: 201937

6 years agoMFC r320992,r320993:
eadler [Mon, 19 Mar 2018 07:07:03 +0000 (07:07 +0000)]
MFC r320992,r320993:

Add a complete example to tsearch(3)

6 years agoMFC r315986:
eadler [Mon, 19 Mar 2018 07:03:02 +0000 (07:03 +0000)]
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.

6 years agoMFC r313818:
eadler [Mon, 19 Mar 2018 07:00:15 +0000 (07:00 +0000)]
MFC r313818:

Small inclusion guard comment fix.

6 years agoMFC r325112:
eadler [Mon, 19 Mar 2018 06:57:41 +0000 (06:57 +0000)]
MFC r325112:

Add P5010/P5010E for completeness

6 years agoMFC r325113:
eadler [Mon, 19 Mar 2018 06:56:30 +0000 (06:56 +0000)]
MFC r325113:

Add Microchip 1-MBit SPI flash ID

Used on the AmigaOne X5000.

6 years agoMFC r326183:
eadler [Mon, 19 Mar 2018 06:55:26 +0000 (06:55 +0000)]
MFC r326183:

Add stdio.h to the synopsis for sysdecode functions that take a FILE *.

6 years agoMFC r326356:
eadler [Mon, 19 Mar 2018 06:54:53 +0000 (06:54 +0000)]
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.

6 years agoMFC r326437:
eadler [Mon, 19 Mar 2018 06:54:16 +0000 (06:54 +0000)]
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.

6 years agoMFC r326859:
eadler [Mon, 19 Mar 2018 06:49:49 +0000 (06:49 +0000)]
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

6 years agoMFC r316422:
eadler [Mon, 19 Mar 2018 06:45:40 +0000 (06:45 +0000)]
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.

6 years agoMFC r327184:
eadler [Mon, 19 Mar 2018 06:40:11 +0000 (06:40 +0000)]
MFC r327184:

Change the remaining files using my personnal email address to my freebsd one

6 years agoMFC r328300:
eadler [Mon, 19 Mar 2018 06:37:59 +0000 (06:37 +0000)]
MFC r328300:

copyright.h: Update license text to 'THE AUTHOR'

This matches the license text at
https://www.freebsd.org/copyright/freebsd-license.html

6 years agoMFC r305306:
eadler [Mon, 19 Mar 2018 04:16:37 +0000 (04:16 +0000)]
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

6 years agoMFC r313264:
eadler [Mon, 19 Mar 2018 04:08:22 +0000 (04:08 +0000)]
MFC r313264:

Avoid using Sun compiler-specific flags.

6 years agoMFC r328262:
eadler [Mon, 19 Mar 2018 04:06:18 +0000 (04:06 +0000)]
MFC r328262:

This comment is bogus. This is a legit release.

6 years agoMFC r328162:
eadler [Mon, 19 Mar 2018 04:03:55 +0000 (04:03 +0000)]
MFC r328162:

Improve support for USB based 3G/4G/5G dongles from Huawei.

PR: 192345

6 years agoMFC r328586:
eadler [Mon, 19 Mar 2018 03:57:14 +0000 (03:57 +0000)]
MFC r328586:

Use more verbose panic messages.

6 years agoMFC r328785:
eadler [Mon, 19 Mar 2018 03:55:42 +0000 (03:55 +0000)]
MFC r328785:

Use standard 2-clause license where copyright is held by the FreeBSD Foundation

6 years agoMFC r312887:
eadler [Mon, 19 Mar 2018 03:53:46 +0000 (03:53 +0000)]
MFC r312887:

Hide unneeded message under bootverbose.

6 years agoMFC r328640:
eadler [Mon, 19 Mar 2018 03:49:54 +0000 (03:49 +0000)]
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

6 years agoMFC r328638:
eadler [Mon, 19 Mar 2018 03:47:46 +0000 (03:47 +0000)]
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

6 years agoMFC r328636:
eadler [Mon, 19 Mar 2018 03:46:12 +0000 (03:46 +0000)]
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

6 years agoMFC r326249:
eadler [Mon, 19 Mar 2018 03:44:19 +0000 (03:44 +0000)]
MFC r326249:

Update intro(6) - remove hint that doesn't work, add explicit list
of games instead, and mention the "bsdgames" port.

6 years agoMFC r303812:
eadler [Mon, 19 Mar 2018 03:38:59 +0000 (03:38 +0000)]
MFC r303812:

Use a more conventional spelling of "breakpoint".

6 years agoMFC r326482:
eadler [Mon, 19 Mar 2018 03:37:00 +0000 (03:37 +0000)]
MFC r326482:

lib/msun: remove trailing whitespace from e_pow.c

6 years agoMFC r314622:
eadler [Mon, 19 Mar 2018 03:34:40 +0000 (03:34 +0000)]
MFC r314622:

As suggested by several people, note that I prefer to communicate by email.

6 years agoMFC r326913:
eadler [Mon, 19 Mar 2018 03:28:24 +0000 (03:28 +0000)]
MFC r326913:

Sync with NetBSD's /usr/share/dict/words, with the exception of quim
due to its vulgar nature.

6 years agoMFC r320210:
eadler [Mon, 19 Mar 2018 03:22:43 +0000 (03:22 +0000)]
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

6 years agoMFC r303412:
eadler [Mon, 19 Mar 2018 03:20:35 +0000 (03:20 +0000)]
MFC r303412:

Remove myself from kern_timeout.c yeah!

6 years agoMFC r325091:
eadler [Mon, 19 Mar 2018 03:19:29 +0000 (03:19 +0000)]
MFC r325091:

Prefer using https over http

6 years agoMFC r317798:
eadler [Mon, 19 Mar 2018 03:15:33 +0000 (03:15 +0000)]
MFC r317798:

bnxt: Add support for new Broadcom 100Gb adapter BCM57454

6 years agoMFC r317570:
eadler [Mon, 19 Mar 2018 03:13:42 +0000 (03:13 +0000)]
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.

6 years agoMFC r304725:
eadler [Mon, 19 Mar 2018 03:06:27 +0000 (03:06 +0000)]
MFC r304725:

Bring datasheet URL up to date.

6 years agoMFC r314052:
eadler [Mon, 19 Mar 2018 03:04:19 +0000 (03:04 +0000)]
MFC r314052:

Document what the different flags mean for locking.

6 years agoMFC r322991:
eadler [Mon, 19 Mar 2018 02:46:17 +0000 (02:46 +0000)]
MFC r322991:

Fix a day-one typo in tty.4 - the sysctls in question are "tty", not "tk"

6 years agoMFC r323135:
eadler [Mon, 19 Mar 2018 02:44:42 +0000 (02:44 +0000)]
MFC r323135:

Spelling.

6 years agoMFC r326601:
eadler [Mon, 19 Mar 2018 02:43:20 +0000 (02:43 +0000)]
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).

6 years agoMFC r328525:
eadler [Mon, 19 Mar 2018 02:38:07 +0000 (02:38 +0000)]
MFC r328525:

ftp(1): Use closefrom() instead of individual close()s.

6 years agoMFC r303150:
eadler [Sun, 18 Mar 2018 22:55:07 +0000 (22:55 +0000)]
MFC r303150:

[mx25l] add new device id.

6 years agoMFC r314955:
eadler [Sun, 18 Mar 2018 22:42:32 +0000 (22:42 +0000)]
MFC r314955:

o Typo in the comment fixed.

6 years agoMFC r325215,r325216:
eadler [Sun, 18 Mar 2018 22:36:21 +0000 (22:36 +0000)]
MFC r325215,r325216:

Update tuning(7) some more

At this point its unclear how much help tuning(7) is whatsoever
but leave it around in case someone decides to spend some time on
it.

6 years agoMFC r315190:
eadler [Sun, 18 Mar 2018 22:29:41 +0000 (22:29 +0000)]
MFC r315190:

Add constants and descriptions for some new PCI class definitions

6 years agoMFC r319274:
eadler [Sun, 18 Mar 2018 22:24:29 +0000 (22:24 +0000)]
MFC r319274:

- Add a simple example to uname(1) manual page to show how the hardware
  platform (returned by -m) can be different from the machine's processor
  architecture (-p)
- Document that make(1) sets universal MACHINE and MACHINE_ARCH variables
  based on these values

6 years agoMFC r303452,r303482,r303483,r303484,r303485,r303487,r303489,r303498,r303499,r303502...
eadler [Sun, 18 Mar 2018 22:19:52 +0000 (22:19 +0000)]
MFC r303452,r303482,r303483,r303484,r303485,r303487,r303489,r303498,r303499,r303502,r303523,r303525,r303570,r303571,r303588,r303596,r303597,r303598,r303599,r303600,r303601,r303625,r303629,r303718,r304651,r304684,r304686,r305983,r309217,r309219,r309341,r309342,r309343,r309382,r309415,r309417,r309418,r309419,r310863,r311141,r314613,r318471,r321382,r321383,r321396:

indent(1): avoid calling write(2) with a negative second parameter.
indent(1): Avoid out of bound access of array codebuf.
indent(1): Avoid potential use-after-free.
indent(1): Fix breakage caused by single comment following "else".
indent(1) simply wasn't taught that "else" may be followed by a comment
without any opening brace anywhere on the line, so it was very confused
in such cases.
indent(1): fix struct termination detection.
indent(1): fix struct termination detection.
indent(1): Removed whitespace shouldn't be considered in column calculations.
indent(1): Support "f" and "F" floating constant suffixes.
indent(1): Use NULL instead of zero for pointers.
indent(1): Attempt to preserve some consistent style.
indent(1): Yet more style issues.
indent(1): Consistently indent declarations.
indent(1): Bail out if there's no more space on the parser stack.
indent(1): Remove dead code relating to unix-style comments.
indent(1): Simplify pr_comment().
indent(1): Fix wrapping of some lines in comments.
indent(1): Untangle the connection between pr_comment.c and io.c.
indent(1): Don't newline on cpp lines like #endif unless -bacc is on.
indent(1): replace function call to bzero with memset.
indent(1): Rearrange option parsing code to squelch clang's static analyzer.
indent(1): Use a dash in the license headers.
indent(1): accept offsetof(3) as a keyword.
indent(1): add some comments to quiet down Coverity.
indent(1): remove dead assignments.
indent(1): have the memset invocation somewhat more canonical.
indent(1): Capsicumify
indent(1): minor off-by-one error.
indent(1): fix regression introduced in r303596.
indent(1): Avoid out of bound access of array in_buffer
indent(1): Don't ignore newlines after comments that follow braces.
indent(1): Don't unnecessarily add a blank before a comment ends.
indent(1): Do not define opchar unless it will be used.
indent(1): Optimize parser stack usage.
indent(1): Remove an extra newline added in a previous commit.
indent(1): Avoid out-of-bound accesses of arrays.
indent(1): Avoid out-of-bound accesses of array ps.p_stack.
indent(1): Avoid out of bounds access of array ps.paren_indents
indent(1): add a piece missed in r311138.
indent(1): Support binary integer literals.
indent(1): don't produce unnecessary blank lines.
indent(1): rename the profile file.
indent(1): better alignment of comments on code.