dragonfly.git
3 years agolibdmsg: Init a pointer that was used uninitialized in early error paths. v5.8.2
Sascha Wildner [Tue, 22 Sep 2020 19:58:59 +0000 (21:58 +0200)]
libdmsg: Init a pointer that was used uninitialized in early error paths.

3 years agoftpd(8): Fix wrong buffer used in an snprintf()'s sizeof().
Sascha Wildner [Tue, 22 Sep 2020 19:56:14 +0000 (21:56 +0200)]
ftpd(8): Fix wrong buffer used in an snprintf()'s sizeof().

3 years agorwhod(8): Fix a for() loop that was incrementing twice.
Sascha Wildner [Tue, 22 Sep 2020 19:53:46 +0000 (21:53 +0200)]
rwhod(8): Fix a for() loop that was incrementing twice.

3 years agoftpd(8): Exit during authentication if an error occurs after chroot().
Antonio Huete Jimenez [Wed, 16 Sep 2020 00:04:57 +0000 (02:04 +0200)]
ftpd(8): Exit during authentication if an error occurs after chroot().

Taken-from: FreeBSD
Security:       CVE-2020-7468

3 years agousr.bin/xargs: Do not report SIGPIPE from children.
Antonio Huete Jimenez [Tue, 15 Sep 2020 23:38:32 +0000 (01:38 +0200)]
usr.bin/xargs: Do not report SIGPIPE from children.

  - Additionally, print the signal name if it's known,
    otherwise just print the signal number. Before only
    the signal number was being reported.

Reported-by: swildner@
Taken-from: OpenBSD

3 years agobinutils227: Backport binutils commit 033bfb739b52
Antonio Huete Jimenez [Sun, 13 Sep 2020 14:54:04 +0000 (14:54 +0000)]
binutils227: Backport binutils commit 033bfb739b52

 - In DPorts, lang/ghc 'configure' phase was failing with this message:

      checking for ld.gold object merging bug (binutils 22266)... Abort trap
      (core dumped) affected
      configure: error: Linker is affected by binutils 22266 but couldn't find
      another unaffected linker. Please set the SettingsMergeObjectsCommand
      variable to a functional linker.
      ===>  Script "configure" failed unexpectedly.
 - https://lists.gnu.org/archive/html/bug-binutils/2017-11/msg00042.html
 - https://gitlab.haskell.org/ghc/ghc/-/issues/14328

Tested-with: buildworld+buildkernel+full dsynth run.

--------
The fix for PR 19291 broke some other cases where -r is used with scripts,
as reported in PR 22266. The original fix for PR 22266 ended up breaking
many cases for REL targets, where the addends are stored in the section data,
and are not being adjusted properly.

The problem was basically that in a relocatable output file (ET_REL),
symbol values are supposed to be relative to the start address of their
section. Usually in a relocatable file, all sections start at 0, so the
failure to get this right is often irrelevant, but with a linker script,
we occasionally see an output section whose starting address is not 0,
and gold would occasionally write a symbol with its relocated value instead
of its section-relative value.

This patch reverts the recent fix for PR 22266 as well as my original fix
for PR 19291. The original fix moved the symbol value adjustment to
write_local_symbols, but neglected to undo a few places where the adjustment
was also being applied, resulting in an occasional double adjustment. The
more recent fix removed those other adjustments, but then failed to
re-account for the adjustment when rewriting the relocations on REL targets.

With the old attempts reverted, we now apply the symbol value adjustment to
the one case that had been missed (non-section symbols in merge sections).
But now we also need to account for the adjustment when rewriting the addends
for RELA relocations.

gold/
PR gold/19291
PR gold/22266
* object.cc (Sized_relobj_file::compute_final_local_value_internal):
Revert changes from 2017-11-08 patch.  Adjust symbol value in
relocatable links for non-section symbols.
(Sized_relobj_file::compute_final_local_value): Revert changes from
2017-11-08 patch.
(Sized_relobj_file::do_finalize_local_symbols): Likewise.
(Sized_relobj_file::write_local_symbols): Revert changes from
2015-11-25 patch.
* object.h (Sized_relobj_file::compute_final_local_value_internal):
Revert changes from 2017-11-08 patch.
* powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for
relocatable links.
* target-reloc.h (relocate_relocs): Adjust addend for relocatable links.
* testsuite/pr22266_a.c (hello): New function.
* testsuite/pr22266_main.c (main): Add test for merge sections.
* testsuite/pr22266_script.t: Add rule for .rodata.
--------

3 years agobinutils227: Backport binutils commit 333d0055f6f16
Antonio Huete Jimenez [Sun, 13 Sep 2020 14:49:45 +0000 (14:49 +0000)]
binutils227: Backport binutils commit 333d0055f6f16

-------
Fix problems with -r.

The fix committed for PR gold/19291 ended up breaking other cases. The
commit added adjustment code to write_local_symbols, but in many cases
compute_final_local_value_internal had already subtracted the output
section's address. To fix this, all other adjustments are now removed, so
only the one in write_local_symbols is left.

gold/
PR gold/22266
* object.cc (Sized_relobj_file::compute_final_local_value_internal):
Drop relocatable parameter and stop adjusting output value based on
it.
(Sized_relobj_file::compute_final_local_value): Stop passing
relocatable to compute_final_local_value_internal.
(Sized_relobj_file::do_finalize_local_symbols): Ditto.
* object.h (Sized_relobj_file::compute_final_local_value_internal):
Drop relocatable parameter.
-------

3 years agokernel: avoid possible use-after-free in ipv6
Daniel Fojt [Thu, 3 Sep 2020 06:59:12 +0000 (08:59 +0200)]
kernel: avoid possible use-after-free in ipv6

Fix improper mbuf handling when processing IPv6 Hop-by-Hop options.

Taken from: FreeBSD (FreeBSD-SA-20:24.ipv6)

3 years agolibc & libkvm: Fix wrong calculations in getloadavg() functions.
Sascha Wildner [Sun, 30 Aug 2020 07:52:34 +0000 (09:52 +0200)]
libc & libkvm: Fix wrong calculations in getloadavg() functions.

41ca9afb26bd2f0654acb8462f6abe441e329f80 changed the ldavg field of
struct loadavg to an array of __uint64_t from previously fixpt_t
which is __uint32_t.

Adjust two associated nelem calculations to use __uint64_t as well.

3 years ago<sys/if_media.h>: Fix typo.
Sascha Wildner [Sat, 29 Aug 2020 18:10:48 +0000 (20:10 +0200)]
<sys/if_media.h>: Fix typo.

3 years agovkernel: Adjust vke(4) for the if_media.h changes (fixes vkernel build).
Sascha Wildner [Sat, 29 Aug 2020 12:40:18 +0000 (14:40 +0200)]
vkernel: Adjust vke(4) for the if_media.h changes (fixes vkernel build).

3 years ago<net/if_media.h>: Adjust ethernet media types some more.
Sascha Wildner [Sat, 29 Aug 2020 10:13:58 +0000 (12:13 +0200)]
<net/if_media.h>: Adjust ethernet media types some more.

* IFM_1000_FX was cleaned up long ago in FreeBSD (see r95702) and
  NetBSD.

* Add a useful comment from FreeBSD.

* Adjust some whitespace and indentation.

While here, clean up the ifmedia.4 manual page a bit and add a
IFM_10G_TWINAX description (from NetBSD).

3 years ago<net/if_media.h>: IFM_HPNA_1 != IFM_10G_LR, renumber as needed.
Sascha Wildner [Thu, 27 Aug 2020 15:41:04 +0000 (17:41 +0200)]
<net/if_media.h>: IFM_HPNA_1 != IFM_10G_LR, renumber as needed.

Reported-by: zrj
3 years agokernel/nata: Fix operator precedence issue.
Sascha Wildner [Tue, 25 Aug 2020 04:43:26 +0000 (06:43 +0200)]
kernel/nata: Fix operator precedence issue.

3 years ago<sys/elf_common.h>: Add GNU note types and NT_GNU_PROPERTY_TYPE_0 bits.
Sascha Wildner [Sat, 15 Aug 2020 15:06:15 +0000 (17:06 +0200)]
<sys/elf_common.h>: Add GNU note types and NT_GNU_PROPERTY_TYPE_0 bits.

Apparently some ports need those.

Reported-by: zrj
Taken-from:  FreeBSD (r348628)

3 years ago<sys/random.h>: Add missing __{BEGIN,END}_DECLS.
Sascha Wildner [Sat, 15 Aug 2020 05:48:09 +0000 (07:48 +0200)]
<sys/random.h>: Add missing __{BEGIN,END}_DECLS.

Reported-by: zrj
3 years agokernel/iscsi: Remove iscsi's local definition of boolean_t.
Sascha Wildner [Tue, 11 Aug 2020 21:30:51 +0000 (23:30 +0200)]
kernel/iscsi: Remove iscsi's local definition of boolean_t.

It was locally defining boolean_t as int (4 bytes) for userland, but
boolean_t is _Bool (1 byte) in the kernel since quite some time.

This caused isc_opt_t's size being different in userland vs. kernel,
and ultimately caused the ioctl number of ISCSISETOPT, which includes
sizeof(isc_opt_t), to be different in userland vs. the kernel,
resulting in at first inexplicable ENOIOCTL issues when using
iscontrol(8).

Change all 'boolean_t' usage to 'bool' which is available for both
userland and kernel, defined as _Bool.

Thanks-to: Georg "megaT" Bege <georg@bege.email> for spotting the ioctl
           number difference & testing

3 years agoUpgrade make(1). 2/2
Daniel Fojt [Wed, 5 Aug 2020 07:12:15 +0000 (09:12 +0200)]
Upgrade make(1). 2/2

- update README.{DELETED,DRAGONFLY}
- adapt Makefile
- regenerate config.h

3 years agoUpgrade make(1). 1/2
Daniel Fojt [Wed, 5 Aug 2020 07:10:07 +0000 (09:10 +0200)]
Upgrade make(1). 1/2

Merge branch 'vendor/BMAKE' into DragonFly_RELEASE_5_8.

3 years agoMakefile.usr: Add '--ff-only' to 'git pull'
Aaron LI [Sat, 1 Aug 2020 06:34:55 +0000 (14:34 +0800)]
Makefile.usr: Add '--ff-only' to 'git pull'

Since version 2.27, Git will warn the pulling if not specified how to
reconcile divergent branch:

    warning: Pulling without specifying how to reconcile divergent
    branches is discouraged. You can squelch this message by running one
    of the following commands sometime before your next pull:

    git config pull.rebase false  # merge (the default strategy)
    git config pull.rebase true   # rebase
    git config pull.ff only       # fast-forward only

As a result, users may come into this issue when doing 'make src-update'
or 'make dports-update' tasks and need to resolve the 'git pull'
manually.  Add the '--ff-only' (i.e., fast-forward only, which is the
safest) to the 'git pull' command.

While there, adjust the update automation note and show it in
'src-update' and 'dports-update' tasks.

Credit: https://stackoverflow.com/a/62653400

Mentioned-by: noob237 (Gonzalo Nemmi)
3 years agoix(4): Fix a wrong check (&& -> ||).
Sascha Wildner [Fri, 31 Jul 2020 21:18:22 +0000 (23:18 +0200)]
ix(4): Fix a wrong check (&& -> ||).

This is also in Intel's ix-3.3.14.

Reviewed-by: sephe
3 years agore(4): Fix a wrong check. Looks like copy/paste but not adjusted properly.
Sascha Wildner [Fri, 31 Jul 2020 21:21:27 +0000 (23:21 +0200)]
re(4): Fix a wrong check. Looks like copy/paste but not adjusted properly.

This is also in Realtek's v196.04.

Reviewed-by: sephe
3 years agomfi(4): Fix a wrong check.
Sascha Wildner [Fri, 31 Jul 2020 21:22:55 +0000 (23:22 +0200)]
mfi(4): Fix a wrong check.

Taken-from: FreeBSD

3 years agovendor/bmake: upgrade from 20160818 to 20200710
Daniel Fojt [Thu, 30 Jul 2020 03:55:49 +0000 (05:55 +0200)]
vendor/bmake: upgrade from 20160818 to 20200710

Summary of notable changes:

- add :range and :_
- support for .DELETE_ON_ERROR
- allow specifying the utc value used by :{gm,local}time
- allow :_=var and avoid use of special context
- use -C arg "as is" if it contains no relative component
- when setting .OBJDIR, ignore '$' in paths
- add -v option to always fully expand values
- pass SIGINT etc onto child and wait for it to exit
- when target is out-of-date per normal make rules record
  value of .OODATE in meta file
- add :Or for reverse sort
- improvements to avoid unnecessary evaluation use enums
  for flags
- debugging output for :@
- fix for compare_expression when doEval=0

For detailed list see ChangeLog.

3 years agokernel/e1000: Add missing 'break'.
Sascha Wildner [Wed, 22 Jul 2020 20:46:19 +0000 (22:46 +0200)]
kernel/e1000: Add missing 'break'.

3 years agolibdmsg: Fix wrong check in dmsg_crypto_negotiate()'s error path.
Sascha Wildner [Mon, 20 Jul 2020 22:53:13 +0000 (00:53 +0200)]
libdmsg: Fix wrong check in dmsg_crypto_negotiate()'s error path.

3 years agotail(1): improve style consistency of previous change
Daniel Fojt [Thu, 18 Jun 2020 04:28:36 +0000 (06:28 +0200)]
tail(1): improve style consistency of previous change

Suggested by: Sascha Wildner

3 years agotail(1): fix misbehaviour on pseudo filesystems
Daniel Fojt [Wed, 17 Jun 2020 06:56:17 +0000 (08:56 +0200)]
tail(1): fix misbehaviour on pseudo filesystems

When processing regular zero-sized files, use display_lines() instead of
rlines(). This fixes tail(1) behaviour with files on pseudo filesystems
(like procfs) which are often reported to have zero size while having
a content.

Issue: https://bugs.dragonflybsd.org/issues/3034

3 years ago<sys/cdefs.h>: FWIW, add __unreachable from FreeBSD.
Sascha Wildner [Tue, 30 Jun 2020 12:31:23 +0000 (14:31 +0200)]
<sys/cdefs.h>: FWIW, add __unreachable from FreeBSD.

3 years agoif_clone: Fix a missing allocated unit free upon error
Aaron LI [Sat, 27 Jun 2020 11:36:11 +0000 (19:36 +0800)]
if_clone: Fix a missing allocated unit free upon error

3 years agoProperly ignore "trim" failures in swapon(8).
Daniel Fojt [Thu, 11 Jun 2020 18:11:55 +0000 (20:11 +0200)]
Properly ignore "trim" failures in swapon(8).

When trying to "trim" a swap device that doesn't support this, just ignore
particular ioctl() failure and continue activating the swap. This actually
matches the behaviour described in swapon(8) manpage.

Issue: https://bugs.dragonflybsd.org/issues/3207

3 years agokernel: fix misleading error from allocating file descriptors
Daniel Fojt [Thu, 11 Jun 2020 09:25:27 +0000 (11:25 +0200)]
kernel: fix misleading error from allocating file descriptors

Return EINVAL instead of EMFILE when requested new file descriptor number
exceeds the limit.

Discussed with: Sascha Wildner

3 years agoread.2: improve formatting of previous addition
Daniel Fojt [Mon, 8 Jun 2020 17:11:42 +0000 (19:11 +0200)]
read.2: improve formatting of previous addition

- start sentences on new lines
- highlight mentioned functions properly
- add a reference to readdir(3)

Pointed out by: Sascha Wildner

3 years agoread.2: describe EISDIR error
Daniel Fojt [Mon, 8 Jun 2020 13:13:52 +0000 (15:13 +0200)]
read.2: describe EISDIR error

Discussed with: Sascha Wildner

3 years agokernel: more precious errors from read()ing hammer and hammer2
Daniel Fojt [Mon, 8 Jun 2020 12:42:10 +0000 (14:42 +0200)]
kernel: more precious errors from read()ing hammer and hammer2

To conform POSIX, return EISDIR instead of EINVAL when trying to read(2)
a directory from hammer or hammer2 filesystem.

Discussed with and reviewed by: Sascha Wildner

3 years agoworld - Change serial port default from 9600 to 115200
Matthew Dillon [Wed, 10 Jun 2020 21:00:28 +0000 (14:00 -0700)]
world - Change serial port default from 9600 to 115200

* Long overdue change, all serial port defaults are now set to
  115200.

* NOTE: legacy BIOS boot0/boot1 use int 0x14 to set the serial
  console baud rate.  This BIOS call only supports up to 9600.
  But once you get into the boot loader it should be able to set
  the correct baud rate.

3 years agokernel - Refactor kern_kevent(), fix timeout overflow (ppoll() bug) (3)
Matthew Dillon [Sun, 7 Jun 2020 18:30:49 +0000 (11:30 -0700)]
kernel - Refactor kern_kevent(), fix timeout overflow (ppoll() bug) (3)

* Fix a second timer overflow.  The systimer clock variable is
  actualy only 32 bits, a 10 minute timeout will overflow it.
  Change the kqueue timeout to 1 minute to work-around.

  (We really need to redo sysclock_t from 32 to 64 bits)

* This should finally fix both swildner's panic and rsmarples
  continued early timeout issue.

Reported-by: swildner, rsmarples
3 years agokernel - Increase KNOTE_CACHE_MAX
Matthew Dillon [Sat, 6 Jun 2020 18:08:22 +0000 (11:08 -0700)]
kernel - Increase KNOTE_CACHE_MAX

* Increase KNOTE_CACHE_MAX from 8 to 64 descriptors.  These are tiny
  descriptors, we can afford to have a larger per-cpu cache.

3 years agokernel - Refactor kern_kevent(), fix timeout overflow (ppoll() bug) (2)
Matthew Dillon [Sat, 6 Jun 2020 18:05:53 +0000 (11:05 -0700)]
kernel - Refactor kern_kevent(), fix timeout overflow (ppoll() bug) (2)

* Certain unsupported EV_ERROR events can cause kern_kevent() to
  live-lock, which hits a 'checkloop failed' panic.  Silently
  deregister such events.

* Complain and deregister any kqueue event on behalf of *poll()
  which does not set any poll return flags.

Reported-by: swildner
3 years agohammer2 - Enhance pfs-list and pfs-delete (2)
Matthew Dillon [Fri, 5 Jun 2020 20:34:41 +0000 (13:34 -0700)]
hammer2 - Enhance pfs-list and pfs-delete (2)

* Fix cast error last commit.

Reported-by: CuteLarva
3 years agohammer2 - Enhance pfs-list and pfs-delete
Matthew Dillon [Fri, 5 Jun 2020 19:33:26 +0000 (12:33 -0700)]
hammer2 - Enhance pfs-list and pfs-delete

* Enhance pfs-list to list PFSs available across all mounted hammer2
  filesystems instead of just the current directory's mount.  A
  specific mount may be specified via -s mountpt.

* Enhance pfs-delete to look for the PFS name across all mounted
  hammer2 filesystems instead of just the current directory's mount.

  As a safety, pfs-delete will refuse to delete PFS names which are
  duplicated across multiple mounts.  A specific mount may be specified
  via -s mountpt.

3 years agokernel - Refactor kern_kevent(), fix timeout overflow (ppoll() bug)
Matthew Dillon [Thu, 4 Jun 2020 23:33:04 +0000 (16:33 -0700)]
kernel - Refactor kern_kevent(), fix timeout overflow (ppoll() bug)

* Fix a bug where large timeouts or very small timeouts could
  overflow the ustimeout variable.  Change the internal timeout
  cap to ensure that no overflow occurs.

* Fix another bug where the internal timeout cap could cause
  ppoll() to return early.  Internal tsleep (etc) timeouts
  need to be ignored because the external timeout might be
  larger and will handle the error return for us when it is
  checked.

* Refactor kern_kevent() to be somewhat more efficient.

Reported-by: rsmarples
3 years agokernel/efirt: Fix a kfree(NULL) panic when deleting a UEFI variable.
Sascha Wildner [Tue, 2 Jun 2020 18:24:30 +0000 (20:24 +0200)]
kernel/efirt: Fix a kfree(NULL) panic when deleting a UEFI variable.

There is no data in this case. Rest of function is ok, just a forgotten
datasize check.

3 years agodsynth - Track contents of dports to detect changes
Matthew Dillon [Sun, 31 May 2020 00:36:00 +0000 (17:36 -0700)]
dsynth - Track contents of dports to detect changes

* Stat information and path names for the files making up a port
  (in the dports directly tree) is rolled-up into a CRC and tracked
  by dsynth.

* By default, dsynth automatically rebuilds any dport that it detects
  has changed, even if a binary package file already exists, including
  any dependent ports.

* Add the -x and -xx options which may be used to override this behavior.

3 years agodsynth - Add 'debug' directive to the manual page
Matthew Dillon [Tue, 3 Mar 2020 01:28:44 +0000 (17:28 -0800)]
dsynth - Add 'debug' directive to the manual page

* Describe the debug directive in the manual page.  It's been in dsynth
  for a while and can be quite useful.

3 years agodsynth - Work on count mismatch issues, fix binary pkg deletion
Matthew Dillon [Sat, 30 May 2020 15:43:20 +0000 (08:43 -0700)]
dsynth - Work on count mismatch issues, fix binary pkg deletion

* The remaining count issue was due to an incorrect test
  involving PKGF_NOTREADY, which also happens to be the code
  which is supposed to delete packages with missing or modified
  dependencies.

* Fix the test.  This should fix both the remaining count issue
  (any remaining issues will be logged in 05*.log), and hopefully
  also properly delete packages with missing or modified dependencies
  at the start of the run (logged as DELETE-PACKAGE in 00*.log).

Reported-by: tuxillo
3 years agodsynth - Work on count mismatch issues
Matthew Dillon [Sat, 30 May 2020 06:38:11 +0000 (23:38 -0700)]
dsynth - Work on count mismatch issues

* Sometimes the individual counts do not add up to the total
  count.

* Fix an issue where 'pkg' is not always accounted for.

* Fix an issue where certain ignored packages are not passed on
  to the service list.

* Log unexpected PKGF_PACKAGED state in 05_abnormal*.log.  This
  typically occurs on incremental runs and is not being properly
  accounted for.

* Log any packages left over on the origination list after the
  run completes to 05_abnormal*.log.  These are usually dependencies
  on ports which do not exist in dports.

3 years agodsynth - Automatically run at nice 10 by default
Matthew Dillon [Fri, 1 May 2020 01:56:30 +0000 (18:56 -0700)]
dsynth - Automatically run at nice 10 by default

* dsynth now automatically nices sub-processes to +10.  This is a
  good middle-of-the-road nice to ensure that dsynth does not interfere
  with other system tasks too much (beyond the massive amount of memory
  and cpu these builds burn normally).

  We don't want to nice it too high or the scheduler won't have enough
  room for its normal dynamic priority management.

* This feature may be disabled via -N.

3 years agodsynth - Enable ccache support
Matthew Dillon [Wed, 22 Apr 2020 00:23:08 +0000 (17:23 -0700)]
dsynth - Enable ccache support

* Get ccache support working

Tested-by: kworr, dillon
3 years agodsynth - Add skip count for ignored and other failure conditions
Matthew Dillon [Tue, 14 Apr 2020 04:49:27 +0000 (21:49 -0700)]
dsynth - Add skip count for ignored and other failure conditions

* Improve implementation for the skip count in the logs and HTML
  interfaces.

Requested-by: tuxillo
3 years agodsynth - Fix bug in dequote()
Matthew Dillon [Thu, 19 Mar 2020 00:29:08 +0000 (17:29 -0700)]
dsynth - Fix bug in dequote()

* Fix bug, the buffer was declared on the stack instead of as a
  static.

* Repurpose the static buffer to be a buffer pointer instead,
  removing the 256 char limit.  The limit was messing up the
  :|: delimeter.

3 years agoxargs.1: Change .Fx to .Dx where appropriate
Antonio Huete Jimenez [Sat, 23 May 2020 10:09:26 +0000 (12:09 +0200)]
xargs.1: Change .Fx to .Dx where appropriate

3 years agoxargs(1): Sync with FreeBSD
Antonio Huete Jimenez [Sat, 23 May 2020 01:22:51 +0000 (03:22 +0200)]
xargs(1): Sync with FreeBSD

  Changes:
    - Use waitpid(2) instead of wait3(2), for portability reasons.
    - Call setlocale(3) with LC_ALL category instead of LC_MESSAGES.
    - Fix -0 vs -L/-I processing.
    - Add -S option to control the maximum size of an argument.
    - Make xargs(1) keep track of its children.
    - Wait for all invocations upon exit.
    - calloc(3) usage fixes.
    - Replace atoi(3) calls with stronum(3) ones.
    - Now -P0 creates as many concurrent processes as possible.
    - Fix exit status expression when a child fails to exec.

The -0 fix solves a problem with DPorts' graphics/libprojectm during stage phase.

3 years agokernel - Fix efivar panic
Matthew Dillon [Fri, 29 May 2020 05:41:32 +0000 (22:41 -0700)]
kernel - Fix efivar panic

* The efirt driver uses direct-map mode, and creates an independent
  pmap to hold it.  The direct map typically uses userspace addresses,
  so SMAP must be disabled across any EFI call.

* Add smap_open(), smap_close(), smap_smep_disable(), and
  smap_smep_enable() calls for C.

  NOTE: We also have to set pcb_onfault to non-NULL to bypass failsafe
checks done in trap().

* Hack the EFI address space code to disable SMAP and SMEP across
  the EFI call.  Unfortunately since we also have to disable SMEP,
  these functions have to manipulate CR4.

Reported-by: daftaupe
3 years agobzip2: Update README.DRAGONFLY.
Daniel Fojt [Thu, 21 May 2020 05:37:09 +0000 (07:37 +0200)]
bzip2: Update README.DRAGONFLY.

3 years agoMerge branch 'vendor/BZIP' into rel5_8
Sascha Wildner [Fri, 22 May 2020 18:56:18 +0000 (20:56 +0200)]
Merge branch 'vendor/BZIP' into rel5_8

3 years agovendor/bzip: upgrade bzip2 from 1.0.6 to 1.0.8 vendor/BZIP
Daniel Fojt [Thu, 21 May 2020 05:26:34 +0000 (07:26 +0200)]
vendor/bzip: upgrade bzip2 from 1.0.6 to 1.0.8

Fixes CVE-2016-3189 and CVE-2019-12900.

3 years agoworld - libmagic depends on several other libraries
Matthew Dillon [Wed, 20 May 2020 20:57:05 +0000 (13:57 -0700)]
world - libmagic depends on several other libraries

* Fix missing dependencies. libmagic needs libbz2 and liblzma.

* Fixes devel/py-subversion@py27 build

Reported-by: tuxillo
3 years agoinstaller: Fix process killing issue in installer.sh
Aaron LI [Sat, 16 May 2020 06:43:20 +0000 (14:43 +0800)]
installer: Fix process killing issue in installer.sh

The original way of obtaining PIDs is actually wrong, becuase it would
get the user of processes instead of the process ID.

Directly use killall(1) to fix the issue as well as clean the code.

3 years agonrelease: Recopy passwd and master.passwd as well
Aaron LI [Sat, 16 May 2020 04:52:12 +0000 (12:52 +0800)]
nrelease: Recopy passwd and master.passwd as well

Ports/packages may also install new users.

While there, use '--yes' option for 'pkg autoremove' to clean a bit.

3 years agoSync zoneinfo database with tzdata2020a from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Thu, 14 May 2020 03:41:16 +0000 (05:41 +0200)]
Sync zoneinfo database with tzdata2020a from ftp://ftp.iana.org/tz/releases

* Morocco's second spring-forward transition in 2020 will be May 31,
    not May 24 as predicted earlier.  (Thanks to Semlali Naoufal.)

* Canada's Yukon advanced to -07 year-round on 2020-03-08.

* America/Nuuk renamed from America/Godthab.

* Shanghai observed DST in 1919.  (Thanks to Phake Nick.)

* To reflect current usage in English better, America/Godthab has
    been renamed to America/Nuuk.  A backwards-compatibility link
    remains for the old name.

For a detailed list of changes, see share/zoneinfo/NEWS.

3 years agorelease: Mount tmpfs at /usr/local/etc only if exists for ISO
Aaron LI [Tue, 12 May 2020 14:38:34 +0000 (22:38 +0800)]
release: Mount tmpfs at /usr/local/etc only if exists for ISO

For an ISO release built with the 'nopkgs' option, it doesn't have the
'/usr/local/etc' directory.  Thus the boot process would fail because it
cannot mount tmpfs at the non-existent directory '/usr/local/etc'.

Fix this issue by checking the existence of '/usr/local/etc' before
appending the corresponding entry to the ISO's fstab.

3 years agonrelease/Makefile: Fix 'pkg_${PKG}' to 'PKG_${PKG}' in a message
Aaron LI [Tue, 12 May 2020 14:08:57 +0000 (22:08 +0800)]
nrelease/Makefile: Fix 'pkg_${PKG}' to 'PKG_${PKG}' in a message

3 years agokernel/vinum: Fix panic when vinum was loaded twice. v5.8.1
Sascha Wildner [Fri, 1 May 2020 16:13:26 +0000 (18:13 +0200)]
kernel/vinum: Fix panic when vinum was loaded twice.

Occurred when it was both compiled into the kernel and in loader.conf
at the same time.

Reported-by: CuteLarva (on IRC)
3 years agolibc - Fix a serious memory leak in the nmalloc code
Matthew Dillon [Thu, 30 Apr 2020 08:39:05 +0000 (01:39 -0700)]
libc - Fix a serious memory leak in the nmalloc code

* Fix a bug where mtmagazine_free() would assign mt->newmag without
  re-checking its contents, potentially overwriting an assignment
  made by _slaballoc(), causing a memory leak.

* This bug generally rears its ugly head in heavily pthreaded programs,
  but it can occur under other conditions too.

Reported-by: hsw (irc)
4 years agohammer2 - Fix serious de-duplication bug and a few other things (2)
Matthew Dillon [Fri, 24 Apr 2020 01:06:03 +0000 (18:06 -0700)]
hammer2 - Fix serious de-duplication bug and a few other things (2)

* Remove debugging kprintf()

4 years agohammer2 - Fix serious de-duplication bug and a few other things
Matthew Dillon [Fri, 24 Apr 2020 00:38:10 +0000 (17:38 -0700)]
hammer2 - Fix serious de-duplication bug and a few other things

* Fix a serious de-duplication bug.  When small files <= 512
  bytes are extended with write()s to being larger than 512 bytes,
  it triggers a de-duplication bug in the first block of the file
  if that block can be de-duplicated from other sources.

  A mishandled skip condition combined with modest buffer cache
  flush loads can cause this first block can wind up getting
  zero'd out and cause a CHECK failure (I/O error) on the file.

  The fixes for this are primarily in hammer2_chain_modify().

* Replace HAMMER2_BREF_FLAG_ZERO in the bref.flags with
  HAMMER2_CHAIN_NOTTESTED in the chain structure and deprecate
  the flag.  This flag could sometimes accidentally be flushed
  to the media.

* Clear HAMMER2_CHAIN_INITIAL in two strategy write paths
  that are not typically hit.  The flag is probably already
  clear at this point since hammer2_chain_modify() has likely
  already been called, but be sure.

4 years agokernel - Fix excessive VM pageout flushes (2)
Matthew Dillon [Fri, 24 Apr 2020 00:37:10 +0000 (17:37 -0700)]
kernel - Fix excessive VM pageout flushes (2)

* Add a couple of missing page-rebusy tests in the vnode/putpages
  path for the pageout daemon.

4 years agotmpfs - Change paging behavior, fix two directory-entry races
Matthew Dillon [Thu, 23 Apr 2020 02:24:13 +0000 (19:24 -0700)]
tmpfs - Change paging behavior, fix two directory-entry races

* Change the paging behavior for vfs.tmpfs.bufcache_mode.

  These changes try to reduce unnecessary tmpfs flushes to swap when
  the pageout daemon is able to locate sufficient clean VM pages.
  The pageout daemon can still page tmpfs data to swap via its normal
  operation, but tmpfs itself will not force write()s to pipeline to
  swap unless memory pressure is severe.

  0 tmpfs write()s are pipelined to swap via the buffer cache only
if the VM system is below the minimum free page count.

(this is the new default)

  1 tmpfs write()s are pipelined to swap via the buffer cache when
the VM system is paging.

  2 Same as (1) but be more aggressive about releasing buffer cache
buffers.

  3 tmpfs_write()s are always pipelined to swap via the buffer cache,
regardless.

* Fix tmpfs file creation, hard-linking, and rename to ensure that the
  new file is not created in a deleted directory.  We must lock the
  directory node around existing tests and add checks that were missing.

  Also remove a few unnecessary recursive locks.

4 years agokernel - Improve tmpfs support
Matthew Dillon [Thu, 13 Feb 2020 03:39:12 +0000 (19:39 -0800)]
kernel - Improve tmpfs support

* When a file in tmpfs is truncated to a size that is not on a block
  boundary, or extended (but not written) to a size that is not on a
  block boundary, the nvextendbuf() and nvtruncbuf() functions must
  modify the contents of the straddling buffer and bdwrite().

  However, a bdwrite() for a tmpfs buffer will result in a dirty buffer
  cache buffer and likely force it to be cycled out to swap relatively
  soon under a modest load.  This is not desirable if there is no memory
  pressure present to force it out.

  Tmpfs almost always uses buwrite() in order to leave the buffer 'clean'
  (the underlying VM pages are dirtied instead), to prevent unecessary
  paging of tmpfs data to swap when the buffer gets recycled or the vnode
  cycles out.

* Add support for calling buwrite() in these functions by changing the
  'trivial' boolean into a flags variable.

* Tmpfs now passes the appropriate flag, preventing the undesirable
  behavior.

4 years agotmpfs - Too aggressive during paging
Matthew Dillon [Wed, 22 Apr 2020 21:27:17 +0000 (14:27 -0700)]
tmpfs - Too aggressive during paging

* tmpfs was being a bit too aggressive during paging.  We were trying to
  bypass all the way to PQ_CACHE as well as unconditionally age the
  buffers.  This caused the pageout daemon to thrash on any underlying
  tmpfs pages that were being re-referenced quickly.

* Change the defaults to (1) Not try to flush all the way to PQ_CACHE
  unless the system is in an extreme low memory condition.  And (2) to
  only B_AGE the buffer when the system is paging and otherwise allow
  it to cycle normally.

4 years agokernel - Fix excessive VM pageout flushes
Matthew Dillon [Thu, 23 Apr 2020 02:39:37 +0000 (19:39 -0700)]
kernel - Fix excessive VM pageout flushes

* The VM pageout code was calculating the laundering limit improperly.
  We were trying to calculate a per-pass limit within each queue list
  but were not taking into account the fact that the number of queues
  have greatly increased in the last few years AND also that the paging
  scans only check 1/10 of each queue for each scan.

  These fixes allow the pageout scan to pick-up many more clean pages
  before beginning to stall-out on dirty pages.

* vm_max_launder is now calculated as 1/256 of physical memory at startup
  instead of hardwired.

* local max_launder calculations now take into account the number of
  queues and the fact that only 1/10 of each queue is checked in each
  pass.

  In addition, the local max_launder calculation is increased by the
  pass number divided by 10 so as to only increase for each full queue
  scan.

* the 'pass' variable passed down into helper functions is now divided
  by 10 because we do not want it to 'increment' and trigger stronger
  behavior until after the entire inactive queue has been scanned.

4 years agokernel - Double LRU dirty pages by default
Matthew Dillon [Wed, 22 Apr 2020 21:05:12 +0000 (14:05 -0700)]
kernel - Double LRU dirty pages by default

* The pageout daemon was supposed to double-LRU dirty pages in the inactive
  queue by default and it wasn't.  This was causing dirty tmpfs pages to
  have too much priority in the inactive queue.

  Theoretically since tmpfs now issues direct writes to backing store in
  low-memory situations, we should be able to allow its dirty pages to
  cycle normally in all other situations.

4 years agokernel - Minor optimizations
Matthew Dillon [Wed, 4 Mar 2020 17:16:09 +0000 (09:16 -0800)]
kernel - Minor optimizations

* Minor __predict and __read_mostly/frequently optimizations.

4 years agolt(1): Use 'find -s' instead of 'find | sort'.
Sascha Wildner [Sun, 29 Mar 2020 08:18:45 +0000 (10:18 +0200)]
lt(1): Use 'find -s' instead of 'find | sort'.

This diff of the old behavior vs. new shows the issue:

--- /tmp/t1 2020-03-29 10:09:50.009490000 +0200
+++ /tmp/t2 2020-03-29 10:10:09.909695000 +0200
@@ -48,12 +48,12 @@
     |   |-- SimpleTextOut.h
     |   `-- UgaDraw.h
     |-- Uefi
-    |-- Uefi.h
     |   |-- UefiBaseType.h
     |   |-- UefiGpt.h
     |   |-- UefiInternalFormRepresentation.h
     |   |-- UefiMultiPhase.h
     |   |-- UefiPxe.h
     |   `-- UefiSpec.h
+    |-- Uefi.h
     `-- X64
         `-- ProcessorBind.h

With 'find | sort', lt(1) would incorrectly show the contents of the
'Uefi' directory below the 'Uefi.h' file.

With 'find -s', the 'Uefi.h' file is correctly sorted below 'Uefi'
and its contents.

4 years agossh-copy-id(1): Fix a printf(1) missing format character warning.
Sascha Wildner [Tue, 24 Mar 2020 15:52:43 +0000 (16:52 +0100)]
ssh-copy-id(1): Fix a printf(1) missing format character warning.

Reported-by: Pierre-Alain TORET <pierre-alain.toret@protonmail.com>
4 years agoHook ssh-copy-id into the build and adjust README.DELETED.
Sascha Wildner [Tue, 24 Mar 2020 15:24:01 +0000 (16:24 +0100)]
Hook ssh-copy-id into the build and adjust README.DELETED.

4 years agoMerge branch 'vendor/OPENSSH' into rel5_8
Sascha Wildner [Tue, 24 Mar 2020 16:00:07 +0000 (17:00 +0100)]
Merge branch 'vendor/OPENSSH' into rel5_8

4 years agoImport OpenSSH-8.0p1's ssh-copy-id and manual page on the vendor branch.
Sascha Wildner [Tue, 24 Mar 2020 15:14:20 +0000 (16:14 +0100)]
Import OpenSSH-8.0p1's ssh-copy-id and manual page on the vendor branch.

4 years agoAdjust iwm.4/iwmfw.4/fstab.5 a bit.
Sascha Wildner [Fri, 20 Mar 2020 14:48:16 +0000 (15:48 +0100)]
Adjust iwm.4/iwmfw.4/fstab.5 a bit.

* iwm.4/iwmfw.4: Mention new devices and firmware.

Reported-by: noob237 (IRC)
* fstab.5: Mention HAMMER2.

Reported-by: daftaupe (IRC)
4 years agokernel - Generate POLLHUP for fully disconnected socket
Matthew Dillon [Wed, 18 Mar 2020 23:35:39 +0000 (16:35 -0700)]
kernel - Generate POLLHUP for fully disconnected socket

* Properly generate POLLHUP for fully disconnected sockets.

  However, there is still a possible issue.  We do not set POLLHUP
  for half-closed sockets and it is really unclear whether we should
  or not once read data has been exhausted.

4 years agodsynth - Fix escaping, skipped count
Matthew Dillon [Wed, 18 Mar 2020 18:04:58 +0000 (11:04 -0700)]
dsynth - Fix escaping, skipped count

* Fix backslashes in info fields that were causing json to implode.

* Remove parens around (%d) skipped count reporting so the field
  can be sorted.

Reported-by: tuxillo
4 years agoworld: Install Linux headers required by Mesa >= 19.3
François Tigeot [Wed, 11 Mar 2020 11:19:45 +0000 (12:19 +0100)]
world: Install Linux headers required by Mesa >= 19.3

Avoiding many patches in dports

4 years agolinux/types.h: Fix compilation with userland C++ programs
François Tigeot [Wed, 11 Mar 2020 11:15:31 +0000 (12:15 +0100)]
linux/types.h: Fix compilation with userland C++ programs

Such as newer Mesa versions

4 years agortld - Increase default tls extra
Matthew Dillon [Sat, 7 Mar 2020 17:48:42 +0000 (09:48 -0800)]
rtld - Increase default tls extra

* rtld allocates 'extra' TLS space beyond that used by the base-loaded
  (ldd) libraries.  This space can be used by late-loaded libraries.
  If insufficient space has been reserved, a late-loaded library using
  static TLS space will fail to load.

* Partial MFC of 4c898ae594, just increase the default for release,
  do not add the kernel support.  Increase the default from 1280 to 6144
  bytes to handle mesa 19.3.

4 years agotmpfs - MFC - Fix minor deadlock
Matthew Dillon [Wed, 4 Mar 2020 17:13:55 +0000 (09:13 -0800)]
tmpfs - MFC - Fix minor deadlock

* Fix a minor deadlock.  tmpfs_alloc_vp() can rarely race a vnode
  and leave a dangling lock, causing a later umount to deadlock.

  Taken from 4d22d8eea66a45843

4 years agokernel - Improve cache_fullpath() performance v5.8.0
Matthew Dillon [Sat, 29 Feb 2020 06:10:38 +0000 (22:10 -0800)]
kernel - Improve cache_fullpath() performance

* realpath() now uses cache_fullpath() in the kernel.  This procedure
  was not optimized for performance.

* Fix cache_fullpath() to use a shared ncp lock instead of an exclusive
  one.

* Significantly improves concurrent program executions that use
  realpath() a lot, such as high make -j ops or concurrent makes.

* Change not yet in master but will be soon.

4 years agodsynth - pkg install -U and improve debug support
Matthew Dillon [Sun, 16 Feb 2020 19:57:12 +0000 (11:57 -0800)]
dsynth - pkg install -U and improve debug support

* pkg install now passes the -U option to avoid trying to access remote
  repos.

* Multiple -d's will turn off ncurses and log to stdout, but what we
  really want to do is to log to a file.  Fix thet 'single -d option'
  feature to now log to 07_debug.log.

* Package dependencies on generic flavored ports (i.e. a depdency which
  does not specify the flavor) were sometimes improperly flagged for
  building even when the default flavor had failed.

Reported-by: zrj
4 years agokernel - Microoptimization, avoid dirtying vm_page_hash entry
Matthew Dillon [Sat, 15 Feb 2020 19:46:32 +0000 (11:46 -0800)]
kernel - Microoptimization, avoid dirtying vm_page_hash entry

* Avoid dirtying the vm_page_hash entry unnecessarily with a
  ticks update if the existing field already has the correct value.

  The VM page hash has an extreme level of SMP concurrency, so
  avoiding cache coherency contention is important.

4 years agodsynth - Adjust 'Limit' display in upper right-hand corner
Matthew Dillon [Sat, 15 Feb 2020 05:46:15 +0000 (21:46 -0800)]
dsynth - Adjust 'Limit' display in upper right-hand corner

* Increase the Limit display from 2 to 3 digits, fixing minor
  display corruption when dsynth is run with greater than 99
  worker slots.

4 years agokernel - Reduce SMP contention during low-memory stress
Matthew Dillon [Sat, 15 Feb 2020 05:39:32 +0000 (21:39 -0800)]
kernel - Reduce SMP contention during low-memory stress

* When memory gets low vm_page_alloc() is forced to stray into
  adjacent VM page queues to find free pages.  This search can
  expand to the whole queue and cause massive SMP contention on
  systems with many cores.

  For example, if PQ_FREE has almost no pages but PQ_CACHE has
  plenty of pages, the previous scan code widened its search
  to the entire PQ_FREE queue (causing a ton of SMP contention)
  before beginning a search of PQ_CACHE.

* The new scan code starts in PQ_FREE but once the search widens
  sufficiently it will also simultaneously begin searching PQ_CACHE.

  This allows the system to continue to allocate memory with minimal
  contention as long as PQ_FREE or PQ_CACHE have pages.

* The new mechanism integrated a whole lot better with pageout
  daemon behavior.  The pageout daemon generally triggers off
  the FREE+CACHE total and not (generally) off of low levels
  for one or the other.

4 years agokernel - Fix rare wait*() deadlock
Matthew Dillon [Sat, 15 Feb 2020 05:37:32 +0000 (21:37 -0800)]
kernel - Fix rare wait*() deadlock

* It is possible for the kernel to deadlock two processes or process
  threads attempting to wait*() on the same pid.

* Fix by adding a bit of magic to give ownership of the reaping
  operation to one of the waiters, and causing the other waiters
  to skip/reject that pid.

4 years agodevfs - Clean up some SMP inefficiencies
Matthew Dillon [Sat, 15 Feb 2020 00:01:09 +0000 (16:01 -0800)]
devfs - Clean up some SMP inefficiencies

* We don't need the devfs master lock around a setattr call.  This
  fixes the open(O_CREAT|O_TRUNC) path for redirects to e.g. /dev/null,
  which is used all over the place in ports builds.

* The devfs spec open (open() again) path can obtain the devfs master
  lock shared instead of exclusive, except in the cloning case.
  This significantly reduces stalls during heavily concurrent bulk
  builds.

4 years agokernel - Increase size of the vm_page hash table
Matthew Dillon [Fri, 14 Feb 2020 23:50:48 +0000 (15:50 -0800)]
kernel - Increase size of the vm_page hash table

* Increase the size of the vm_page hash table used to shortcut
  page lookups during a fault.  Improves the hit rate on machines
  with large amounts of memory.

* Adjust the ticks overflow test from < 0 to < -1 in to avoid
  getting tripped up by SMP races on the global 'ticks' variable
  (which is not accessed atomically).  One cpu can conceivably
  update a hash ticks value while another cpu is doing a calculation
  based on a stale copy of ticks.

  Avoids premature vm_page_hash cache evictions due to this race.

4 years agokernel - Offset the stathz systimer by 50% of the hz timer
Matthew Dillon [Fri, 14 Feb 2020 05:48:23 +0000 (21:48 -0800)]
kernel - Offset the stathz systimer by 50% of the hz timer

* Offset the initial starting point of the stathz systimer by
  50% of the hz timer, so they do not interfere with each other
  if they happen to be set to the same frequency.

* Change the default stathz frequency to hz + 1 (101hz) so it
  slides across the tick interval window.

4 years agordrand - Document massive improvement in performance
Matthew Dillon [Fri, 14 Feb 2020 06:13:57 +0000 (22:13 -0800)]
rdrand - Document massive improvement in performance

* Document the huge difference going from 512 to 16 bytes.  General
  system performance is improved by 9.3% on a TR3990X.

  This is not entirely the fault of rdrand.  It is also in a large
  part due to the overhead of add_buffer_randomness().

4 years agokernel - Add more dtypes to sys/dtype.h
Matthew Dillon [Fri, 14 Feb 2020 05:53:04 +0000 (21:53 -0800)]
kernel - Add more dtypes to sys/dtype.h

* Add a few from FreeBSD, and also add some placeholder types for
  "encrypted" and "unspecified" partition types.

4 years agopctrack - Fix symbol table scan
Matthew Dillon [Fri, 14 Feb 2020 05:52:29 +0000 (21:52 -0800)]
pctrack - Fix symbol table scan

* Fix the symbol table scan to properly parse kernel symbols and not
  get confused by non-code symbols.

4 years agokernel - Reduce excessive rdrand harvesting
Matthew Dillon [Fri, 14 Feb 2020 05:39:17 +0000 (21:39 -0800)]
kernel - Reduce excessive rdrand harvesting

* Our rdrand driver harvests 512 bytes on each cpu thread at a rate
  of 10hz.  Ryzen CPUs appear to burn about 0.73uS per word, creating
  an overhead of about 460uS/sec on EACH cpu thread in the system.

  When added to the even higher overhead of the add_buffer_randomness()
  call, the result was a roughly 3% loss of performance across the board.

* Reduce the harvest size to 16 bytes, which honestly is still plenty
  of entropy to inject.

* Change some symbolic branch targets to local branch targets in the
  rdrand and padlock code to avoid generating symbols that can cause
  weird output in our PC sampler (I was getting 'loop+N' and 'out+N'
  while testing the above).

4 years agokernel - Rearrange uidinfo structure a bit
Matthew Dillon [Wed, 26 Feb 2020 05:57:52 +0000 (21:57 -0800)]
kernel - Rearrange uidinfo structure a bit

* Rearrange the structure to move ui_lock and ui_refs
  into a cache-line isolated area of the structure.