13 months agokernel - Rejigger midistat functions to close a race
Matthew Dillon [Wed, 21 Aug 2019 01:50:59 +0000 (18:50 -0700)]
kernel - Rejigger midistat functions to close a race

* Make sure lock has full coverage across midistat_open() and
  midistat_read().  The temporary drop of the lock in midistat_read()
  lead to a race which allows one to read kernel memory beyond the
  end of the sbuf buffer.

* Rejigger the code to remove the global offset and just use
  uio_offset, which also fixes the same race (but leave the
  lock coverage in place regardless).

Taken-From: FreeBSD
Security:       CVE-2019-5612

13 months agokernel - merge m_pulldown() bug fix
Matthew Dillon [Wed, 21 Aug 2019 01:36:46 +0000 (18:36 -0700)]
kernel - merge m_pulldown() bug fix

In m_pulldown(), before trying to prepend bytes to the subsequent mbuf,
ensure that the subsequent mbuf contains the remainder of the bytes
the caller sought. If this is not the case, fall through to the code
which gathers the bytes in a new mbuf.

This fixes a bug where m_pulldown() could fail to gather all the desired
bytes into consecutive memory.

Patch-by: sephe
FreeBSD-PR: 238787
Reported by: A reddit user
Discussed with: emaste
Obtained from: NetBSD
Obtained from: FreeBSD

13 months agodsynth - Stabilization
Matthew Dillon [Tue, 20 Aug 2019 19:36:14 +0000 (12:36 -0700)]
dsynth - Stabilization

* Set the PORTSDIR and BATCH environment variables for bulk pkglist
  operations (these were already being set properly for chroot'd

  This will fix the PORTSDIR prefix test and removal for dependencies
  done by resolveDepString().

13 months agodsynth - Optimize pty use
Matthew Dillon [Tue, 20 Aug 2019 19:08:08 +0000 (12:08 -0700)]
dsynth - Optimize pty use

* Have the WORKER process allocate the pty once and use it in all
  phases, instead of allocating and closing a new pty for each phase.

* Make N copies of /bin, /lib, /usr/bin, and /libexec into the base
  directory and mount those in the chroots instead of the system
  directory, essentially unsharing these directories.  Each worker
  gets an independent copy.

  This should reduce contention and cache-line ping-ponging overhead
  on /bin/sh, libc, make, etc, significantly.

* Create the template conditionally whether 'pkg' has been built or

13 months agodsynth - Get skips working, etc
Matthew Dillon [Tue, 20 Aug 2019 17:23:29 +0000 (10:23 -0700)]
dsynth - Get skips working, etc

* Get 'Skipped' working, and print a nice depdency chain for the reason
  why a packge got skipped.

* Added swap% to the dynamic worker reduction algorithm.  It startsr at
  10% swap used and maxes out at a 75% reduction with 40% of swap used.

* Add a slow-start feature so dsynth does not try to load all workers
  at startup simultaneously.  This gives the swap% and loadavg worker
  reduction code a chance to activate before the system becomes totally

* Cache the 0*.log logfile descirptors instead of open/write/close.

13 months agoroute: Remove ref counting around rt_newaddrmsg().
Roy Marples [Tue, 20 Aug 2019 13:18:51 +0000 (14:18 +0100)]
route: Remove ref counting around rt_newaddrmsg().

Doesn't seem to be needed anymore.
As proposed by sephe.

13 months agoMerge remote-tracking branch 'remotes/crater/vendor/BYACC'
Sascha Wildner [Tue, 20 Aug 2019 09:44:00 +0000 (11:44 +0200)]
Merge remote-tracking branch 'remotes/crater/vendor/BYACC'

13 months agosbin/hammer2: Use hammer2_uuid_to_str() instead of uuid_to_string()
Tomohiro Kusumi [Mon, 19 Aug 2019 20:24:40 +0000 (05:24 +0900)]
sbin/hammer2: Use hammer2_uuid_to_str() instead of uuid_to_string()

13 months agosbin/hammer2: Use hammer2_time64_to_str() in "printinode"
Tomohiro Kusumi [Mon, 19 Aug 2019 19:51:28 +0000 (04:51 +0900)]
sbin/hammer2: Use hammer2_time64_to_str() in "printinode"

13 months agodsynth - Misc work
Matthew Dillon [Tue, 20 Aug 2019 05:56:50 +0000 (22:56 -0700)]
dsynth - Misc work

* Try to get Skipped working, propagate the NOBUILD flag upward
  and process it as a Skipped in startbuild().

* Change descriptor 0 in the forkpty()'d sub-process to /dev/null
  to try to shortcut ports which sometimes ask questions.
  (We do set BATCH as well, but some ports still ask questions).

* Change the dynamic MaxWorkers adjustment to reduce MaxWorkers
  by up to 75% at (5 * ncpus) of load.  The adjustment begins
  at 0% at (1.5 * ncpus) load.

13 months agosbin/hammer2: Fix remaining type warnings on Linux distros
Tomohiro Kusumi [Mon, 19 Aug 2019 18:12:20 +0000 (03:12 +0900)]
sbin/hammer2: Fix remaining type warnings on Linux distros

Bring in local changes existed in https://github.com/kusumi/lh1.
These ondisk fields are not of char*.

13 months agodsynth - Reap processes more generally in the poll loop
Matthew Dillon [Tue, 20 Aug 2019 03:19:45 +0000 (20:19 -0700)]
dsynth - Reap processes more generally in the poll loop

* Adjust the dsynth worker process to reap any pid needing
  reaping within the poll loop instead of just checking the
  primary exec'd make pid.

* This catches any orphaned children that would otherwise
  accumulate during the build.

13 months agodsynth - Misc/stabilization
Matthew Dillon [Tue, 20 Aug 2019 02:30:30 +0000 (19:30 -0700)]
dsynth - Misc/stabilization

* Add missing environment variables PORT_DBDIR, PACKAGE_BUILDING,

* Increase field width for Impulse and Pkg/hour to 5 digits.

* Fix bugs in the dynamic MaxWorkers reduction code (based on load).

13 months agodsynth - Fleshout functions
Matthew Dillon [Tue, 20 Aug 2019 00:12:44 +0000 (17:12 -0700)]
dsynth - Fleshout functions

* Add dynamic MaxWorker reduction based on the load.  The number of
  workers will be reduced by (load * 2 / ncpus) when the load
  exceeds (ncpus * 2.0), with a floor of min(4, MaxWorkers).

  The idea here is to reduce unnecessary swap use when building
  larger packages that push the load up greatly.

* Clean-up terminal spam after ncurses has been turned on.

* Generate fatal error if required configured directories are

* Add -y (yes to all) option.

* Implement 'status' and 'status-everything'

* Implement 'purge-distfiles' (initial work)

* In scans that dump percentages, print 100% at the end before
  moving onto the next step.

13 months agodsynth - Initial commit (unhooked from buildworld)
Matthew Dillon [Mon, 19 Aug 2019 20:36:33 +0000 (13:36 -0700)]
dsynth - Initial commit (unhooked from buildworld)

* DSynth is basically synth written in C, from scratch.  It is designed
  to give us a bulk builder in base and be friendly to porting and jails
  down the line (for now its uses chroot's).

  The original synth was written by John R. Marino and its basic flow
  was used in writing this program, but as it was written in ada no
  code was directly copied.

* The intent is to make dsynth compatible with synth's configuration
  files and directory structure.

* This is a work in progress and not yet ready for prime-time.  Pushing
  so we can get some more eyeballs.  Most of the directives do not yet
  work (everything, and build works, and 'cleanup' can be used to clean
  up any dangling mounts).

* Not connected to the build yet.  A great deal more work is needed.
  As-of this commit, these areas need work:

  - Uname/architecture/release-versioning stuff.

  - Possibly additional environment variables or make variables
    for certain cases and situations.

  - The repo building step.

  - Web interface.

  - Dynamic load management (reduce the number of workers dynamically
    based on load/ncpus).

  - curses cleanup and window resizing.

13 months agosbin/hammer2: Minor fix in man
Tomohiro Kusumi [Mon, 19 Aug 2019 14:59:59 +0000 (23:59 +0900)]
sbin/hammer2: Minor fix in man

Correct d371ccd28ada846c26eb398d4f4798fd4a74d47d.

13 months agolib/libdmsg: Fix compile warning on Linux distros
Tomohiro Kusumi [Mon, 19 Aug 2019 14:13:38 +0000 (23:13 +0900)]
lib/libdmsg: Fix compile warning on Linux distros

Appeared since 030e3428e0c23c47cef4dfab51f988a8fa665d19.

msg.c:202: warning: pointer targets in passing argument 1 of 'atomic_set_int' differ in signedness
atomic.h:129: note: expected 'volatile u_int *' but argument is of type 'int *'

13 months agosbin/hammer2: Fix compile warning on Linux distros
Tomohiro Kusumi [Mon, 19 Aug 2019 14:03:52 +0000 (23:03 +0900)]
sbin/hammer2: Fix compile warning on Linux distros

cmd_debug.c: In function 'show_bref':
cmd_debug.c:812: warning: pointer targets in passing argument 2 of 'CountFreeBlocks' differ in signedness
cmd_debug.c:42: note: expected 'hammer2_off_t *' but argument is of type 'int64_t *'
cmd_debug.c:812: warning: pointer targets in passing argument 3 of 'CountFreeBlocks' differ in signedness
cmd_debug.c:42: note: expected 'hammer2_off_t *' but argument is of type 'int64_t *'

cmd_debug.c: In function 'cmd_hash':
cmd_debug.c:890: warning: pointer targets in passing argument 1 of 'dirhash' differ in signedness

13 months agousr.sbin/fstyp: Fix compile warning on Linux distros
Tomohiro Kusumi [Mon, 19 Aug 2019 14:00:09 +0000 (23:00 +0900)]
usr.sbin/fstyp: Fix compile warning on Linux distros

Ondisk inode's filename[] is of unsigned char.

hammer2.c: In function '__read_label':
hammer2.c:123: warning: pointer targets in passing argument 2 of 'strncpy' differ in signedness

13 months agosbin/hammer2: Add missing usage() exit for "destroy"/"destroy-inum"
Tomohiro Kusumi [Sun, 18 Aug 2019 15:44:23 +0000 (00:44 +0900)]
sbin/hammer2: Add missing usage() exit for "destroy"/"destroy-inum"

13 months agosbin/hammer2: Align usage() output
Tomohiro Kusumi [Sun, 18 Aug 2019 15:40:11 +0000 (00:40 +0900)]
sbin/hammer2: Align usage() output

13 months agosbin/hammer2: Fix hammer2(8) and usage()
Tomohiro Kusumi [Sat, 17 Aug 2019 20:06:34 +0000 (05:06 +0900)]
sbin/hammer2: Fix hammer2(8) and usage()

13 months agosbin/mount_hammer2: Fix usage() output
Tomohiro Kusumi [Sat, 17 Aug 2019 15:30:07 +0000 (00:30 +0900)]
sbin/mount_hammer2: Fix usage() output

Sync with mount_hammer2(8).

13 months agolast(1): Fix braces.
Sascha Wildner [Sat, 17 Aug 2019 20:55:02 +0000 (22:55 +0200)]
last(1): Fix braces.

13 months agokernel - Fix race in sys_shmmat()
Matthew Dillon [Sat, 17 Aug 2019 18:34:12 +0000 (11:34 -0700)]
kernel - Fix race in sys_shmmat()

* Fix a race whereby two threads can attempt to allocate the
  same shmmap_s.  The race can occur because blocking conditions
  interrupt the token interlock.

  Simply add a simple reserved field to stage the allocation
  prior to the shmid being assigned.

13 months agoprintenv(1) - Sync with FreeBSD
Antonio Huete Jimenez [Sat, 17 Aug 2019 16:34:41 +0000 (18:34 +0200)]
printenv(1) - Sync with FreeBSD

- Remove MLINKS, env.1 has its own manpage now.

13 months agoenv(1) - Sync with FreeBSD
Antonio Huete Jimenez [Sat, 17 Aug 2019 15:59:46 +0000 (17:59 +0200)]
env(1) - Sync with FreeBSD

- There have been almost no changes since it was first imported.
- Now it has its own manpage

13 months agosbin/newfs_hammer2: Eliminate (an only)tab in result output
Tomohiro Kusumi [Fri, 16 Aug 2019 22:46:04 +0000 (07:46 +0900)]
sbin/newfs_hammer2: Eliminate (an only)tab in result output

Other lines are aligned with space.

13 months agosbin/newfs_hammer2: Zero clear boot/aux area
Tomohiro Kusumi [Fri, 16 Aug 2019 20:28:17 +0000 (05:28 +0900)]
sbin/newfs_hammer2: Zero clear boot/aux area

Although currently unused, don't leave unrelated garbage.
This increases runtime by 1 sec or so with default boot/aux size.

Also drop redundant bzero() call against zero'd buffer.

13 months agosbin/newfs_hammer2: Make ascii-art a bit more descriptive
Tomohiro Kusumi [Fri, 16 Aug 2019 18:43:31 +0000 (03:43 +0900)]
sbin/newfs_hammer2: Make ascii-art a bit more descriptive

13 months agoinet6: Take route reference before announcing address
Roy Marples [Fri, 16 Aug 2019 18:26:23 +0000 (19:26 +0100)]
inet6: Take route reference before announcing address

This mirrors the behaviour in rtinit_rtrequest_callback.

13 months agobump version for prior
Roy Marples [Fri, 16 Aug 2019 16:56:17 +0000 (17:56 +0100)]
bump version for prior

13 months agoinet6: emit RTM_NEWADDR messages on address flag changes.
Roy Marples [Fri, 16 Aug 2019 16:54:35 +0000 (17:54 +0100)]
inet6: emit RTM_NEWADDR messages on address flag changes.

We no longer emit RTM_NEWADDR right away when adding a new address
and starting DAD. Instead the result of the DAD will be emitted.

Some minor fixes from NetBSD are also brought in, such as
starting DAD when addresses are no longer detached and the
tentative state not being added when address lifetime is

Taken-from: NetBSD
Reviewed-by: sephe
13 months agoroute: Add support for route(4) message filtering.
Roy Marples [Fri, 16 Aug 2019 15:39:35 +0000 (16:39 +0100)]
route: Add support for route(4) message filtering.

This saves waking up listeners for messages they have no interest in.
It also helps to reduce the chance of a receive buffer overflow.

Taken-from: OpenBSD
Reviewd-by: sephe
13 months agosbin/mount_hammer2: Include <errno.h> for errno
Tomohiro Kusumi [Fri, 16 Aug 2019 15:10:21 +0000 (00:10 +0900)]
sbin/mount_hammer2: Include <errno.h> for errno

It's currently included via <dmsg.h>.

13 months agosbin/*_hammer2: Fix/cleanup Makefile
Tomohiro Kusumi [Fri, 16 Aug 2019 15:10:04 +0000 (00:10 +0900)]
sbin/*_hammer2: Fix/cleanup Makefile

13 months agosys/vfs/hammer2: Drop obsolete comment on chain allocation
Tomohiro Kusumi [Thu, 15 Aug 2019 19:06:04 +0000 (04:06 +0900)]
sys/vfs/hammer2: Drop obsolete comment on chain allocation

This comment no longer applies to this switch/case.
See 355d67fcd81e0a7b17007d691bb00bdd151f3d28 in 2013.

13 months agosbin/hammer2: Simplify bitmap offset calculation in "freemap"
Tomohiro Kusumi [Thu, 15 Aug 2019 15:10:10 +0000 (00:10 +0900)]
sbin/hammer2: Simplify bitmap offset calculation in "freemap"

Eliminate a magic number 256 (4MB / 16KB).
Each hammer2_bmap_data in leaf covers 4MB (level 0) data store.

13 months agosbin/hammer2: Print rotation# (0-7) in "freemap"
Tomohiro Kusumi [Wed, 14 Aug 2019 15:59:02 +0000 (00:59 +0900)]
sbin/hammer2: Print rotation# (0-7) in "freemap"

13 months agosbin/hammer2: Print bcount(>0) for all blockrefs in "show"/"freemap"
Tomohiro Kusumi [Wed, 14 Aug 2019 15:50:43 +0000 (00:50 +0900)]
sbin/hammer2: Print bcount(>0) for all blockrefs in "show"/"freemap"

13 months agosbin/hammer2: Refactor show_bref()
Tomohiro Kusumi [Wed, 14 Aug 2019 15:36:33 +0000 (00:36 +0900)]
sbin/hammer2: Refactor show_bref()

No functional difference.
Read media buf, get bscan pointer, and calculate bcount first.

13 months agosbin/hammer2: Remove unused local variable
Tomohiro Kusumi [Wed, 14 Aug 2019 15:29:29 +0000 (00:29 +0900)]
sbin/hammer2: Remove unused local variable

Always 1 and never used for anything.

13 months agoUpdate the pciconf(8) database.
Sascha Wildner [Thu, 15 Aug 2019 06:08:54 +0000 (08:08 +0200)]
Update the pciconf(8) database.

August 8, 2019 snapshot from https://pci-ids.ucw.cz

13 months agoahci - Add quirk for MCP73 AHCI Controller
Antonio Huete Jimenez [Thu, 15 Aug 2019 00:03:25 +0000 (02:03 +0200)]
ahci - Add quirk for MCP73 AHCI Controller

- The AHCI chip for the MCP73 motherboard, which is identified as below, does
  not properly handle certain handshake operations.

  ahci0@pci0:0:14:0:      class=0x010601 card=0xe03a1631 chip=0x07f410de rev=0xa2 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device     = 'GeForce 7100/nForce 630i SATA'
    class      = mass storage
    subclass   = SATA
    cap 01[44] = powerspec 2  supports D0 D3  current D0
    cap 12[8c] = SATA Index-Data Pair
    cap 05[b0] = MSI supports 8 messages, 64 bit enabled with 1 message

Pointed-out-by: dillon
13 months agosbin/hammer2: Whitespace cleanups/etc for cmd_debug.c
Tomohiro Kusumi [Wed, 14 Aug 2019 01:13:57 +0000 (10:13 +0900)]
sbin/hammer2: Whitespace cleanups/etc for cmd_debug.c

13 months agosbin/hammer2: Add -q mode (no blockref data) for "show"/"freemap"
Tomohiro Kusumi [Wed, 14 Aug 2019 01:08:25 +0000 (10:08 +0900)]
sbin/hammer2: Add -q mode (no blockref data) for "show"/"freemap"

13 months agonet/raw: Assert all APIs are called from netisr0.
Sepherosa Ziehau [Wed, 14 Aug 2019 02:40:22 +0000 (10:40 +0800)]
net/raw: Assert all APIs are called from netisr0.

Remove the raw pcb list lock, since thread serialization is used.

13 months agokernel - Fix SMP races in raw socket code
Matthew Dillon [Tue, 13 Aug 2019 17:55:50 +0000 (10:55 -0700)]
kernel - Fix SMP races in raw socket code

* The raw socket code was not properly dealing with SMP races
  in attach/detach verses receive processing.  Replace the token
  with a lockmgr lock.

  These issues never really caused an issue because raw sockets just
  aren't used very often, but they still need to be dealt with.

* SMP performance is not super-critical in this case so I just use a
  normal lock and keep it simple.

13 months agosbin/hammer2: Fix root blockref type in "freemap"
Tomohiro Kusumi [Tue, 13 Aug 2019 16:00:03 +0000 (01:00 +0900)]
sbin/hammer2: Fix root blockref type in "freemap"

The root blockref type for freemap should be
Both are pseudo types, but sync with what fchain uses.

13 months agosys/vfs/hammer2: Use HAMMER2_FREEMAP_LEVEL1_MASK
Tomohiro Kusumi [Tue, 13 Aug 2019 01:30:43 +0000 (10:30 +0900)]
sys/vfs/hammer2: Use HAMMER2_FREEMAP_LEVEL1_MASK


13 months agosys/vfs/hammer2: Drop redundant H2FMSHIFT() macro
Tomohiro Kusumi [Mon, 12 Aug 2019 16:31:35 +0000 (01:31 +0900)]
sys/vfs/hammer2: Drop redundant H2FMSHIFT() macro

Since H2FMSHIFT() is only used with freemap radix levels, it can be
completely replaced with the existing HAMMER2_FREEMAP_LEVEL*_SIZE.
This is more readable.

13 months agosys/vfs/hammer2: Move duplicated macros H2FM*() to hammer2_disk.h
Tomohiro Kusumi [Mon, 12 Aug 2019 16:13:47 +0000 (01:13 +0900)]
sys/vfs/hammer2: Move duplicated macros H2FM*() to hammer2_disk.h

These macros exist in both freemap and bulkfree code.
Should be part of ondisk layout spec.

13 months agosys/vfs/hammer2: Drop unused inline function hammer2_freemapradix()
Tomohiro Kusumi [Mon, 12 Aug 2019 16:03:40 +0000 (01:03 +0900)]
sys/vfs/hammer2: Drop unused inline function hammer2_freemapradix()

Unused since 93f3933ac3e2ad37a7ba775663c711b13588f147 in 2013.

13 months agosys/vfs/hammer2: Use HAMMER2_FREEMAP_LEVEL1_SIZE
Tomohiro Kusumi [Mon, 12 Aug 2019 16:00:06 +0000 (01:00 +0900)]
sys/vfs/hammer2: Use HAMMER2_FREEMAP_LEVEL1_SIZE

13 months agosbin/newfs_hammer2: Drop -Isbin/hammer2 in Makefile
Tomohiro Kusumi [Sun, 11 Aug 2019 16:32:06 +0000 (01:32 +0900)]
sbin/newfs_hammer2: Drop -Isbin/hammer2 in Makefile

Unlike newfs_hammer(8), newfs_hammer2(8) just creates root inodes,
therefore it doesn't (need to) rely on hammer2(8) for ondisk
initialization nor does it have such functionality.

13 months agosbin/hammer2: Don't test uuid on "info"/"mountall" if uuid is 0
Tomohiro Kusumi [Sun, 11 Aug 2019 16:01:55 +0000 (01:01 +0900)]
sbin/hammer2: Don't test uuid on "info"/"mountall" if uuid is 0

Don't terminate if HAMMER2 device/partition has 0 uuid.

13 months agosbin/hammer2: Remove unnecessary { ... } scope
Tomohiro Kusumi [Sun, 11 Aug 2019 15:13:52 +0000 (00:13 +0900)]
sbin/hammer2: Remove unnecessary { ... } scope

13 months agosbin/newfs_hammer2: Whitespace cleanups
Tomohiro Kusumi [Sun, 11 Aug 2019 04:03:07 +0000 (13:03 +0900)]
sbin/newfs_hammer2: Whitespace cleanups

13 months agosbin/newfs_hammer2: Fix usage() output
Tomohiro Kusumi [Sun, 11 Aug 2019 03:55:00 +0000 (12:55 +0900)]
sbin/newfs_hammer2: Fix usage() output

Sync with newfs_hammer2(8).
Unlike HAMMER1, label name via -L is optional.

13 months agosbin/newfs_hammer2: Drop unused GIG
Tomohiro Kusumi [Sun, 11 Aug 2019 03:49:36 +0000 (12:49 +0900)]
sbin/newfs_hammer2: Drop unused GIG

from 2012.
There is no block device size requirement like HAMMER1.

13 months agosys/vfs/hammer2: Cleanup unused bp/nbio's in strategy
Tomohiro Kusumi [Sat, 10 Aug 2019 22:41:44 +0000 (07:41 +0900)]
sys/vfs/hammer2: Cleanup unused bp/nbio's in strategy

13 months agosys/vfs/hammer2: Use MAXBSIZE for getblk() size limit
Tomohiro Kusumi [Sat, 10 Aug 2019 22:01:45 +0000 (07:01 +0900)]
sys/vfs/hammer2: Use MAXBSIZE for getblk() size limit

13 months agodrm/linux: Add X86_FEATURE_HYPERVISOR
François Tigeot [Sat, 10 Aug 2019 19:57:15 +0000 (21:57 +0200)]

13 months agoBuild: Bump __DragonFly_version to 500703
François Tigeot [Sat, 10 Aug 2019 19:51:01 +0000 (21:51 +0200)]
Build: Bump __DragonFly_version to 500703

Knowing whether static TLS binding is useable or not is important
for some ports like graphics/mesa-libs

13 months agosys/vfs/hammer2: Fix comments on inode lock on truncation
Tomohiro Kusumi [Sat, 10 Aug 2019 17:04:03 +0000 (02:04 +0900)]
sys/vfs/hammer2: Fix comments on inode lock on truncation

Inodes are locked when these are called.

13 months agosys/vfs/hammer2: Fix indentation
Tomohiro Kusumi [Sat, 10 Aug 2019 15:05:07 +0000 (00:05 +0900)]
sys/vfs/hammer2: Fix indentation

13 months agokernel: Fix the _KERNEL/_KERNEL_STRUCTURES checks w/ error msg a bit.
Sascha Wildner [Sat, 10 Aug 2019 11:52:09 +0000 (13:52 +0200)]
kernel: Fix the _KERNEL/_KERNEL_STRUCTURES checks w/ error msg a bit.

Uniformly use this style:

#ifndef _KERNEL
#error "..."

over this style:

#ifndef _KERNEL
#error "..."
[rest of header]

Pointed-out-by: zrj
13 months agokdump(1): Remove an unneeded include path in the Makefile.
Sascha Wildner [Sat, 10 Aug 2019 09:54:53 +0000 (11:54 +0200)]
kdump(1): Remove an unneeded include path in the Makefile.

Include syscalls.c relative to ${.CURDIR}/../../sys, that we need

13 months agortld - Support static TLS bindings for late-loaded shared libraries (2)
Matthew Dillon [Sat, 10 Aug 2019 06:48:40 +0000 (23:48 -0700)]
rtld - Support static TLS bindings for late-loaded shared libraries (2)

* Add missing static_tls.h

Reported-by: ftigeot
13 months agortld - Support static TLS bindings for late-loaded shared libraries
Matthew Dillon [Fri, 9 Aug 2019 22:22:18 +0000 (15:22 -0700)]
rtld - Support static TLS bindings for late-loaded shared libraries

* Allow late (manual) dlopen()s to load shared libraries which
  use static TLS variables, as long as there is space.  Do proper
  late-binding and initialize the area for all threads.

* rtld will cache a symbol lookup on first-need for:
  "_pthread_distribute_static_tls" and then call it as needed to
  initialize late-bound static TLS space.

  This symbol is weakly bounded to __libc_distribute_static_tls in libc,
  and strongly overridden by _libthread_distribute_static_tls in

* Fixes mesa glx-tls and others.

* Test code from FreeBSD.  Also tested with other combinations
  including a pthread_create() and -static compilation.


13 months ago<machine/stdint.h>: Move __offsetof() to <sys/cdefs.h>.
Sascha Wildner [Fri, 9 Aug 2019 19:08:02 +0000 (21:08 +0200)]
<machine/stdint.h>: Move __offsetof() to <sys/cdefs.h>.

It didn't really fit well into <machine/stdint.h> which is for machine
dependent types only.

See FreeBSD's r99594.

I took a comment and some additional casts from FreeBSD.

Pointed-out-by: zrj
13 months agolibc/utmpx: Fix updwtmpx() across newsyslog rotation of /var/log/wtmpx.
Sascha Wildner [Fri, 9 Aug 2019 17:19:07 +0000 (19:19 +0200)]
libc/utmpx: Fix updwtmpx() across newsyslog rotation of /var/log/wtmpx.

When /var/log/wtmpx is rotated by newsyslog(8), an empty /var/log/wtmpx
is created. Fix updwtmpx() to write the signature record this case as
well. This signature record is used by setutxdb() to verify the file.

13 months ago<machine/stdint.h>: Use __GNUC_PREREQ__() for a __GNUC__ check.
Sascha Wildner [Fri, 9 Aug 2019 17:11:12 +0000 (19:11 +0200)]
<machine/stdint.h>: Use __GNUC_PREREQ__() for a __GNUC__ check.

Reported-by: zrj
13 months agoreboot(8): Fix argument order in logwtmpx().
Sascha Wildner [Thu, 8 Aug 2019 20:32:11 +0000 (22:32 +0200)]
reboot(8): Fix argument order in logwtmpx().

13 months agoinet6: discard NA messages with a lladdress we own
Roy Marples [Thu, 8 Aug 2019 16:41:55 +0000 (17:41 +0100)]
inet6: discard NA messages with a lladdress we own

This allows userland to send NA messages for already existing
addresses without the kernel reporting incorrectly that a
duplicate address has been detected.

13 months agonet/if: introduce if_bylla to find an interface by hardware address
Roy Marples [Thu, 8 Aug 2019 16:38:21 +0000 (17:38 +0100)]
net/if: introduce if_bylla to find an interface by hardware address

13 months ago<sys/stdint.h>: Remove obsolete typedefs for __wctrans_t and __wctype.h.
Sascha Wildner [Thu, 8 Aug 2019 08:32:03 +0000 (10:32 +0200)]
<sys/stdint.h>: Remove obsolete typedefs for __wctrans_t and __wctype.h.

These are no longer used since 0d5acd7467c4e95f792ef49fceb3ab8e917ce86b.

Reported-by: zrj
13 months ago<uchar.h>: Define char16_t and char32_t better.
Sascha Wildner [Wed, 7 Aug 2019 20:00:17 +0000 (22:00 +0200)]
<uchar.h>: Define char16_t and char32_t better.

Define them unless we use C++11 or higher. Also, remove __char16_t
and __char32_t from <sys/types.h>. Furthermore, remove the unneeded
declaration guards.

Thanks to zrj for his help.

13 months agodrm/linux: Implement more idr routines
François Tigeot [Wed, 7 Aug 2019 17:56:50 +0000 (19:56 +0200)]
drm/linux: Implement more idr routines

Add idr_get_next() and idr_for_each_entry()

Inspired-from: FreeBSD

13 months agokernel: Enable more generic drm code
François Tigeot [Wed, 7 Aug 2019 17:34:00 +0000 (19:34 +0200)]
kernel: Enable more generic drm code

Reduce differences with Linux 4.7.10

13 months agoDocument ENOBUFS error in read(2) and recv(2).
Roy Marples [Wed, 7 Aug 2019 01:05:43 +0000 (02:05 +0100)]
Document ENOBUFS error in read(2) and recv(2).

13 months agosocket: introduce SO_RERROR to detect receive buffer overflow
Roy Marples [Wed, 7 Aug 2019 00:48:21 +0000 (01:48 +0100)]
socket: introduce SO_RERROR to detect receive buffer overflow

kernel receive buffers are initially of a limited size and
generally the network protocols that use them don't care
if a packet gets lost.

However some users do care about lost messages even if not
baked into the protocol - such as consumers of route(4) to
track state.

POSIX states that read(2) can return an error of ENOBUFS so
return this error code when an overflow is detected.
Guard this with socket option SO_RERROR so that existing
applications which do not care can carry on not caring by

Taken-from: NetBSD
Reviewed-by: sephe
13 months agoTest commit
Roy Marples [Tue, 6 Aug 2019 22:32:53 +0000 (23:32 +0100)]
Test commit

13 months agodbopen.3: Mention O_CLOEXEC.
Sascha Wildner [Tue, 6 Aug 2019 21:03:02 +0000 (23:03 +0200)]
dbopen.3: Mention O_CLOEXEC.

13 months ago<sys/copyright.h>: Remove a K&R leftover; use just spaces instead of /**/.
Sascha Wildner [Tue, 6 Aug 2019 18:45:35 +0000 (20:45 +0200)]
<sys/copyright.h>: Remove a K&R leftover; use just spaces instead of /**/.

13 months agosys/vfs/hammer2: Drop redundant ; in H2XOPDESCRIPTOR()
Tomohiro Kusumi [Mon, 5 Aug 2019 04:24:26 +0000 (13:24 +0900)]
sys/vfs/hammer2: Drop redundant ; in H2XOPDESCRIPTOR()

13 months agoFWIW, fix systags.sh.
Sascha Wildner [Tue, 6 Aug 2019 11:08:22 +0000 (13:08 +0200)]
FWIW, fix systags.sh.

13 months agokernel/ixgbe: Use __restrict instead of restrict like everywhere else.
Sascha Wildner [Tue, 6 Aug 2019 08:26:38 +0000 (10:26 +0200)]
kernel/ixgbe: Use __restrict instead of restrict like everywhere else.

13 months agokernel/drm: Add print_hex_buffer() and use it.
Sascha Wildner [Mon, 5 Aug 2019 19:02:28 +0000 (21:02 +0200)]
kernel/drm: Add print_hex_buffer() and use it.

13 months agosail(6): Sync with NetBSD.
Sascha Wildner [Mon, 29 Jul 2019 10:43:57 +0000 (12:43 +0200)]
sail(6): Sync with NetBSD.

This, among other things, fixes an old curses related bug that caused
FreeBSD ports to take NetBSD's instead of ours (the games/bsdgames port
takes our source as the distfile). They've since switched to debian's

See https://svnweb.freebsd.org/ports?view=revision&revision=495354

13 months agosys/vfs/hammer2: Drop obsolete comments on chain
Tomohiro Kusumi [Sun, 4 Aug 2019 16:29:16 +0000 (01:29 +0900)]
sys/vfs/hammer2: Drop obsolete comments on chain

"dbtree", "dbq", "core_entry", "domodify" are all removed in around 2014.

13 months agoahci - sili - Reduce insertion delay from 10 seconds to 5
Matthew Dillon [Sat, 3 Aug 2019 20:42:45 +0000 (13:42 -0700)]
ahci - sili - Reduce insertion delay from 10 seconds to 5

* Reduce the insertion delay for hot-plug from 10 seconds to
  5 seconds.

13 months agosys/vfs/hammer2: Test bref type HAMMER2_BREF_TYPE_EMPTY instead 0
Tomohiro Kusumi [Fri, 2 Aug 2019 22:22:44 +0000 (07:22 +0900)]
sys/vfs/hammer2: Test bref type HAMMER2_BREF_TYPE_EMPTY instead 0

13 months agotelnet - Apply FreeBSD-SA-19:12.telnet.asc to telnet
Matthew Dillon [Sat, 3 Aug 2019 16:09:45 +0000 (09:09 -0700)]
telnet - Apply FreeBSD-SA-19:12.telnet.asc to telnet

* Fix two environment variable vulnerabililties in the telnet

* Generally replace all sprintf()s with snprintf()s.

13 months agosys/vfs/hammer2: Fix function name in panic() calls
Tomohiro Kusumi [Thu, 1 Aug 2019 20:27:37 +0000 (05:27 +0900)]
sys/vfs/hammer2: Fix function name in panic() calls

13 months agosys/vfs/hammer2: Drop unused CHAIN_CORE_DELETE_BMAP_ENTRIES
Tomohiro Kusumi [Thu, 1 Aug 2019 18:36:05 +0000 (03:36 +0900)]
sys/vfs/hammer2: Drop unused CHAIN_CORE_DELETE_BMAP_ENTRIES

Added in 8138a154be31c3db1d8bd046ca7b003a6c79c01c in 2014,
but never used. It also doesn't seem to have any meaning in
current implementation.

13 months agokernel - Add SIOCGIFALIAS
Matthew Dillon [Fri, 2 Aug 2019 15:26:32 +0000 (08:26 -0700)]

* Add SIOCGIFALIAS to retrieve ifconfig information on a single
  alias entry.

Submitted-by: rsmarples (Roy Marples)
Taken-from: NetBSD

13 months agokernel: Clean up a bit after the recent tap/tun changes.
Sascha Wildner [Fri, 2 Aug 2019 14:59:23 +0000 (16:59 +0200)]
kernel: Clean up a bit after the recent tap/tun changes.

13 months agohammer2 - Reorder errno priority for unlink directory errors
Matthew Dillon [Fri, 2 Aug 2019 05:13:49 +0000 (22:13 -0700)]
hammer2 - Reorder errno priority for unlink directory errors

* When AT_REMOVEDIR is not specified, or unlink() is called on a
  directory, prioritize returning EISDIR over ENOTEMPTY.

* Unbreaks part of 'go'.

Reported-by: hsw
13 months agodrm/linux: Add pci_name()
François Tigeot [Thu, 1 Aug 2019 18:37:12 +0000 (20:37 +0200)]
drm/linux: Add pci_name()

Obtained-from: FreeBSD