]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoxen: allow limiting the amount of duplicated pending xenstore watches
Roger Pau Monné [Wed, 25 Nov 2020 11:34:38 +0000 (12:34 +0100)]
xen: allow limiting the amount of duplicated pending xenstore watches

Xenstore watches received are queued in a list and processed in a
deferred thread. Such queuing was done without any checking, so a
guest could potentially trigger a resource starvation against the
FreeBSD kernel if such kernel is watching any user-controlled xenstore
path.

Allowing limiting the amount of pending events a watch can accumulate
to prevent a remote guest from triggering this resource starvation
issue.

For the PV device backends and frontends this limitation is only
applied to the other end /state node, which is limited to 1 pending
event, the rest of the watched paths can still have unlimited pending
watches because they are either local or controlled by a privileged
domain.

The xenstore user-space device gets special treatment as it's not
possible for the kernel to know whether the paths being watched by
user-space processes are controlled by a guest domain. For this reason
watches set by the xenstore user-space device are limited to 1000
pending events. Note this can be modified using the
max_pending_watch_events sysctl of the device.

This is XSA-349.

Sponsored by: Citrix Systems R&D
MFC after: 3 days

3 years agoxen/xenstore: remove unused functions
Roger Pau Monné [Thu, 26 Nov 2020 08:57:47 +0000 (09:57 +0100)]
xen/xenstore: remove unused functions

Those helpers are not used, so remove them. No functional change.

Sponsored by: Citrix Systems R&D
MFC after: 3 days

3 years agoTegra210: Connect to GENERIC kernel.
Michal Meloun [Tue, 29 Dec 2020 09:46:49 +0000 (10:46 +0100)]
Tegra210: Connect to GENERIC kernel.

3 years agoTegra210: Add lost-in-merge fixes:
Michal Meloun [Tue, 29 Dec 2020 09:58:29 +0000 (10:58 +0100)]
Tegra210: Add lost-in-merge fixes:
 - misplaced '#ifdef notyet' in max77620.c
 - misnamed 'xusb_gate' clock in tegra210_clk_per.c

3 years agoUpdate leap-seconds to leap-seconds.3676924800.
Xin LI [Wed, 30 Dec 2020 06:01:46 +0000 (22:01 -0800)]
Update leap-seconds to leap-seconds.3676924800.

Obtained from: ftp://ftp.nist.gov/pub/time/leap-seconds.3676924800
MFC after: 3 days

3 years agocontrib/tzdata: import tzdata 2020f
Philip Paeps [Wed, 30 Dec 2020 04:50:26 +0000 (12:50 +0800)]
contrib/tzdata: import tzdata 2020f

Merge commit '96b88ac701b35ce68425046d4be8f51cb75b5d5b' into main

Changes: https://github.com/eggert/tz/blob/2020f/NEWS

MFC after:    1 day

3 years agoImport tzdata 2020f
Philip Paeps [Wed, 30 Dec 2020 04:45:24 +0000 (12:45 +0800)]
Import tzdata 2020f

3 years agobsdcat,cpio,tar: derive version string from archive.h
Xin LI [Tue, 29 Dec 2020 21:38:47 +0000 (13:38 -0800)]
bsdcat,cpio,tar: derive version string from archive.h

Reviewed by: mm
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27823

3 years agocxgbe: replace zero sized array by flexible array
Toomas Soome [Tue, 29 Dec 2020 20:59:01 +0000 (22:59 +0200)]
cxgbe: replace zero sized array by flexible array

The issue was found while building cxgbe with gcc 10 (in illumos),
the array subscription check is warning us about outside the bounds
access.

See also: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

3 years agoSet stdout & stderr unbuffered, so that the "telnet>" prompt
Poul-Henning Kamp [Tue, 29 Dec 2020 21:05:48 +0000 (21:05 +0000)]
Set stdout & stderr unbuffered, so that the "telnet>" prompt
also shows up when output is redirected:

telnet |& tee _log

3 years agoRevert "bsnmpclient(3): make it thread-safe"
Edward Tomasz Napierala [Tue, 29 Dec 2020 19:55:05 +0000 (19:55 +0000)]
Revert "bsnmpclient(3): make it thread-safe"

This reverts commit 89e3d5671ba13dceca272d5b159c9bd805f3f504.

As pointed out, there are several problems with that commit:

1. The new semantics, while useful for clients where multiple
   threads use separate contexts, breaks clients which correctly
   share a single one
2. Change in semantics would require a library version bump
3. It doesn't build with GCC

3 years agoFix generation of colldef source files for non-UTF-8 locales
Hiroki Sato [Tue, 29 Dec 2020 19:21:19 +0000 (04:21 +0900)]
Fix generation of colldef source files for non-UTF-8 locales

- Files for colldef were generated by duplicating UTF-8 collation files
  for each language and included invalid characters in the non-UTF-8
  encodings.  localedef(1) does not allow those characters.
  cldr2def.pl now checks if the characters are valid based on charmap files.

  TODO: ja_JP.UTF-8 locale should not be generated solely from CLDR because
  it was standardized in a document "UI-OSF Application Platform Profile for
  Japanese Environment" which was incompatible with information in CLDR.
  Most of commercial Unix vendors adopt this pre-Unicode-era document
  as the reference even for UTF-8 locale.  Newer versions of Solaris have
  added a CLDR version as ja_JP.UTF-8@cldr, and IBM AIX has used
  JA_JP.UTF-8 for the UI-OSF specification and ja_JP.UTF-8 for CLDR.

  Note that this commit does not change generation of ja_JP.UTF-8.
  Changes related to this issue will be committed separately later.

- Generate POSIX charamap UTF-32 as a reference.  It was confusing that
  charmap.xml used Unicode names defined in UnicodeData.txt though POSIX
  charmap used slightly different names for the same code points.
  cldr2def.pl now uses UTF-32.cm as single information source for Unicode
  symbol names and code points.  Charset.xml is also updated to use them.

- Fix a bug in get_encodings() in cldr2def.pl which did not understand
  0x00+0x00 notation correctly in charmaps/ISCII-DEV.TXT.

- Do not regenerate posix/xx_Comm_C.UTF-8.src every time when doing
  "make build".

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D27809

3 years agolook(1): Add EXAMPLES section
Fernando Apesteguía [Tue, 29 Dec 2020 20:48:12 +0000 (21:48 +0100)]
look(1): Add EXAMPLES section

Add two simple examples. In this case I opted to show a small portion of
the output since it helps to understand what the tool does. It shows the use
of the -t flag too.

PR:
Submitted by:
Reported by:
Reviewed by: gbe@
Approved by: manpages (bcr@)
Obtained from:
MFC after:
MFH:
Relnotes:
Security:
Sponsored by:
Differential Revision: https://reviews.freebsd.org/D27543

3 years agolsvfs(1): Add EXAMPLES section
Fernando Apesteguía [Tue, 29 Dec 2020 20:35:24 +0000 (21:35 +0100)]
lsvfs(1): Add EXAMPLES section

Add one simple exapmle and contrast some of the information using mount(8)

PR:
Submitted by:
Reported by:
Reviewed by: gbe@, yuripv@
Approved by: manpages (bcr@)
Obtained from:
MFC after:
MFH:
Relnotes:
Security:
Sponsored by:
Differential Revision: https://reviews.freebsd.org/D27544

3 years agoFix typo in ap_initator_portal.
Alexander Motin [Tue, 29 Dec 2020 18:32:05 +0000 (13:32 -0500)]
Fix typo in ap_initator_portal.

MFC after: 1 week

3 years ago[wlanwatch] fix compiler warnings-as-errors on gcc-6.4 mips
Adrian Chadd [Tue, 29 Dec 2020 17:50:49 +0000 (09:50 -0800)]
[wlanwatch] fix compiler warnings-as-errors on gcc-6.4 mips

* argc/argv are currently unused
* msglen is currently unused
* "default" is a const buffer, but char *cp isn't, so
  change default string to be a non-const global string variable
* Make 'cp' private to each context that's using it, which fixes
  a "variable shadows previous declaration" warning and makes it
  easier to track where it was being leaked between address family
  sections

3 years ago[wlanwds] Fix compiler warnings-as-errors on freebsd gcc-6.4 mips
Adrian Chadd [Tue, 29 Dec 2020 01:04:43 +0000 (17:04 -0800)]
[wlanwds] Fix compiler warnings-as-errors on freebsd gcc-6.4 mips

* Remove unused verbose global; things are now done through syslog
* Mark a variable as unused in handle_rtmsg()

Tested:

* FreeBSD/mips32 using gcc-6.4

3 years ago[wlanstats] Fix warnings-as-errors on gcc-6.4 on mips
Adrian Chadd [Tue, 29 Dec 2020 01:03:11 +0000 (17:03 -0800)]
[wlanstats] Fix warnings-as-errors on gcc-6.4 on mips

* use CLLADDR() to not try deconsting a const
* Unsigned where they should be
* static where it should be

Tested:

* freebsd/mips32, using gcc-6.4

3 years agokern: efirt: correct configuration table entry size
Kyle Evans [Sun, 27 Dec 2020 17:26:45 +0000 (11:26 -0600)]
kern: efirt: correct configuration table entry size

Each entry actually stores a native pointer, not a uint64_t quantity. While
we're here, go ahead and export the pointer as-is rather than converting it
to KVA. This may be more useful as consumers can map /dev/mem and observe
the entry.

For reference, see: sys/contrib/edk2/Include/Uefi/UefiSpec.h

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27669

3 years agokern: efirt: enter runtime environment to deref efi_cfgtbl
Kyle Evans [Sun, 27 Dec 2020 17:28:32 +0000 (11:28 -0600)]
kern: efirt: enter runtime environment to deref efi_cfgtbl

This fixes an insta-panic when EFIIOC_GET_TABLE is used.

Reviewed by: imp (earlier version), kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27669

3 years agoStreamline the infiniband code according to the ethernet code.
Hans Petter Selasky [Tue, 29 Dec 2020 17:01:57 +0000 (18:01 +0100)]
Streamline the infiniband code according to the ethernet code.

Specifically implement the if_requestencap callback function for infiniband.
Most of the changes are simply a cut and paste of the equivalent ethernet part.

Reviewed by: melifaro @
Differential Revision: https://reviews.freebsd.org/D27631
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoFix for IPoIB over lagg(4).
Hans Petter Selasky [Tue, 29 Dec 2020 16:34:01 +0000 (17:34 +0100)]
Fix for IPoIB over lagg(4).

Need to update both link layer address and broadcast address when active link changes for IP over infiniband.
This is because the broadcast address contains the so-called P-key, which is interface dependent.

Reviewed by: kib @
Differential Revision: https://reviews.freebsd.org/D27658
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agobsnmpclient(3): make it thread-safe
Edward Tomasz Napierala [Tue, 29 Dec 2020 14:59:31 +0000 (14:59 +0000)]
bsnmpclient(3): make it thread-safe

Reviewed By: harti
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27336

3 years agoiscsid(8): fix memory leak by freeing the 'addr'
Edward Tomasz Napierala [Tue, 29 Dec 2020 14:53:03 +0000 (14:53 +0000)]
iscsid(8): fix memory leak by freeing the 'addr'

Reviewed By: mav
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27328

3 years agoiscsid(8): free data allocated by getaddrinfo(3)
Edward Tomasz Napierala [Tue, 29 Dec 2020 14:47:35 +0000 (14:47 +0000)]
iscsid(8): free data allocated by getaddrinfo(3)

Reviewed By: mav
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27329

3 years agorelease.sh: Update GITROOT URL
Glen Barber [Tue, 29 Dec 2020 14:34:05 +0000 (09:34 -0500)]
release.sh: Update GITROOT URL

Hard-code the GITROOT for the ports tree to use cgit-beta
until the ports repository is converted.

While here, remove $FreeBSD$ RCS IDs.

Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agogeom(4): make g_newprovider_event() return if G_P_WITHER is set
Edward Tomasz Napierala [Tue, 29 Dec 2020 14:29:54 +0000 (14:29 +0000)]
geom(4): make g_newprovider_event() return if G_P_WITHER is set

This fixes a failed assertion in scenario where the provider
disappears, disk_gone() gets called, and at the exact same
time something else closes the device node triggering a retaste.

Reviewed By: mav
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27330

3 years agolibcam(3): make cam_getccb(3) zero the whole ccb, not just the header
Edward Tomasz Napierala [Tue, 29 Dec 2020 14:25:46 +0000 (14:25 +0000)]
libcam(3): make cam_getccb(3) zero the whole ccb, not just the header

Leaving zeroing to the clients leads to error-prone pointer
tricks (zeroing needs to preserve the CCB header), and this
code is not performance-critical, so there's really no reason
to not do it.

Reviewed By: imp, rpokala (manpages)
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27333

3 years agodevfs(4): defer freeing until we drop devmtx ("cdev")
Edward Tomasz Napierala [Tue, 29 Dec 2020 13:45:53 +0000 (13:45 +0000)]
devfs(4): defer freeing until we drop devmtx ("cdev")

Before r332974 the old code would sometimes cause a rare lock order
reversal against pagequeue, which looked roughly like this:

witness_checkorder()
__mtx_lock-flags()
vm_page_alloc()
uma_small_alloc()
keg_alloc_slab()
keg_fetch-slab()
zone_fetch-slab()
zone_import()
zone_alloc_bucket()
uma_zalloc_arg()
bucket_alloc()
uma_zfree_arg()
free()
devfs_metoo()
devfs_populate_loop()
devfs_populate()
devfs_rioctl()
VOP_IOCTL_APV()
VOP_IOCTL()
vn_ioctl()
fo_ioctl()
kern_ioctl()
sys_ioctl()

Since r332974 the original problem no longer exists, but it still
makes sense to move things out of the - often congested - lock.

Reviewed By: kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27334

3 years agoRevert "uefi.8: mention boot1.efi"
Kevin Lo [Tue, 29 Dec 2020 04:08:19 +0000 (12:08 +0800)]
Revert "uefi.8: mention boot1.efi"

This reverts commit a8ec81e79871de98e30ce572a313f3f8d059ce7b

Revert D27782.  imp@ pointed out that bsdinstall has been updated, and gpart
bootcode isn't used with EFI.

3 years agoMove cp(4) module enable to SOURCELESS_HOST
Ed Maste [Tue, 29 Dec 2020 00:36:13 +0000 (19:36 -0500)]
Move cp(4) module enable to SOURCELESS_HOST

cp contains obfuscated code that runs on the host's processor

3 years agokern.mk: drop flag only patched in-tree gcc understood
Ryan Libby [Mon, 28 Dec 2020 22:03:36 +0000 (14:03 -0800)]
kern.mk: drop flag only patched in-tree gcc understood

-mno-align-long-strings was a flag maintained by FreeBSD for the
now-deleted in-tree gcc.  Upstream gcc has no such flag, so just drop
it.

The flag was originally submitted by bde and committed in 2002 (svn
r97911 & r104455).  However, upstream gcc did address this same issue in
2004 (gcc svn r76694 / git 4137ba7ab7a), reducing long string alignment
in general, and to 1 with -Os.

Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27768

3 years agodump(8): clarify the recommended use of cache and snapshots
Guangyuan Yang [Mon, 28 Dec 2020 21:54:36 +0000 (21:54 +0000)]
dump(8): clarify the recommended use of cache and snapshots

PR: 131626
MFC after: 1 week
Submitted by: Andrew Hamilton-Wright <andrew@qemg.org>
Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D27775

3 years agocache: work around corner case of dvp == tvp in cache_fplookup_final_modifying
Mateusz Guzik [Mon, 28 Dec 2020 21:24:53 +0000 (21:24 +0000)]
cache: work around corner case of dvp == tvp in cache_fplookup_final_modifying

Fixes a panic where the kernel would unlock an unheld lock coming from
rename looking up "foo/." as the source.

Reported by: markj (syzkaller)

3 years agofusefs: delete some dead code
Alan Somers [Thu, 24 Dec 2020 19:21:00 +0000 (19:21 +0000)]
fusefs: delete some dead code

The original fusefs GSoC project seems to have envisioned exchanging two
types of messages with FUSE servers.  Perhaps vectored and non-vectored?
But in practice only one type has ever been used.  Delete the other type.

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

3 years agoeventfd.2: Add the mail address of the submitter into copyright.
Konstantin Belousov [Mon, 28 Dec 2020 19:01:26 +0000 (21:01 +0200)]
eventfd.2: Add the mail address of the submitter into copyright.

Requested by: rgrimes
MFC after: 13 days

3 years agofusefs: fix the tests for a wider range of maxphys
Alan Somers [Thu, 24 Dec 2020 06:03:06 +0000 (06:03 +0000)]
fusefs: fix the tests for a wider range of maxphys

maxphys is now a tunable, ever since r368124.  The default value is also
larger than it used to be.  That broke several fusefs tests that made
assumptions about maxphys.

* WriteCluster.clustering used the MAXPHYS compile-time constant.

* WriteBackAsync.direct_io_partially_overlaps_cached_block implicitly
  depended on the default value of maxphys.  Fix it by making the
  dependency explicit.

* Write.write_large implicitly assumed that maxphys would be no more
  than twice maxbcachebuf.  Fix it by explicitly setting m_max_write.

* WriteCluster.clustering and several others failed because the MockFS
  module did not work for max_write > 128KB (which most tests would set
  when maxphys > 256KB).  Limit max_write accordingly.  This is the same
  as fusefs-libs's behavior.

* Bmap's tests were originally written for MAXPHYS=128KB.  With larger
  values, the simulated file size was too small.

PR: 252096
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D27769

3 years agoCorrect font.h comment describing vfnt font maps
Ed Maste [Mon, 28 Dec 2020 16:56:00 +0000 (11:56 -0500)]
Correct font.h comment describing vfnt font maps

Commit 41fb06651122 doubled the number of glyph maps in the vfnt format
from 2 to 4 to support double-width characters, but a comment describing
the maps was not updated to match.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agodumpon(8): Add missing section arguments
Gordon Bergling [Mon, 28 Dec 2020 15:48:58 +0000 (16:48 +0100)]
dumpon(8): Add missing section arguments

MFC after: 3 days

3 years agonewfs(8): Fix unusual Xr order
Gordon Bergling [Mon, 28 Dec 2020 15:46:28 +0000 (16:46 +0100)]
newfs(8): Fix unusual Xr order

- unusual Xr order: gjournal after gpart

MFC after: 3 days

3 years agoRemove misleading macros from -width arguments
Mateusz Piotrowski [Mon, 28 Dec 2020 15:29:35 +0000 (16:29 +0100)]
Remove misleading macros from -width arguments

Also, remove $FreeBSD$ tag from manual page examples.

MFC after: 1 week

3 years agoCollect statistics from all rate-limit queues in mlx5en(4).
Hans Petter Selasky [Mon, 12 Oct 2020 08:18:48 +0000 (10:18 +0200)]
Collect statistics from all rate-limit queues in mlx5en(4).

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoImprove error message printing in krping.
Hans Petter Selasky [Wed, 9 Dec 2020 12:59:01 +0000 (13:59 +0100)]
Improve error message printing in krping.
Don't print completion queue flush as an error.

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoARM64: Port FreeBSD to Nvidia Jetson TX1 and Nano.
Michal Meloun [Thu, 4 Jan 2018 12:18:24 +0000 (13:18 +0100)]
ARM64: Port FreeBSD to Nvidia Jetson TX1 and Nano.

Add support for the Tergra210 SoC and its companion PMIC MAX77620.

3 years agortld-elf: link libcompiler_rt on all architectures
Ryan Libby [Mon, 28 Dec 2020 08:44:25 +0000 (00:44 -0800)]
rtld-elf: link libcompiler_rt on all architectures

Statically link rtld-elf with libcompiler_rt on all architectures so
that we don't need to try to pick and choose the bits we need from it
for each architecture (we now leave that to the linker).  Compilers may
emit calls to support functions in this library, but because of the use
of the linker flag -nostdlib for rtld's special needs, the library is
not linked as normal.

Previously we had two different solutions.  On some architectures, we
were able to extract reimplementations of the necessary builtin
functions from our special build of libc.  On ARM, we just linked
libcompiler_rt.

This is motivated by the same issue as D26199 and D27665, but should be
a simpler solution that will apply to all architectures.

Reviewed by: arichardson, kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27736

3 years agoRevert "rtld-elf: link udivmoddi4 from compiler_rt"
Ryan Libby [Mon, 28 Dec 2020 08:44:25 +0000 (00:44 -0800)]
Revert "rtld-elf: link udivmoddi4 from compiler_rt"

This reverts commit bce2cff0bc0ee3ab5b7a66c19920e7cfe3400f6f.

Revert D27665 in favor of a more general fix coming in D27736.

3 years agolibcompiler_rt: stop building with stack smashing protection
Ryan Libby [Mon, 28 Dec 2020 08:44:25 +0000 (00:44 -0800)]
libcompiler_rt: stop building with stack smashing protection

libcompiler_rt implements certain functions that clang and gcc emit
calls to as part of their codegen (e.g. for extended width math).  Build
it without stack smashing protection (SSP, -fstack-protector) in order
to support building binaries without SSP, especially the dynamic linker.
Besides, SSP is probably not very valuable in this library.

Reviewed by: arichardson, dim, kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27786

3 years agocaroot: drop $FreeBSD$ expansion from root bundle
Kyle Evans [Mon, 28 Dec 2020 03:47:41 +0000 (21:47 -0600)]
caroot: drop $FreeBSD$ expansion from root bundle

This debatably could have waited until the next update would have taken
place, but it's easier to see what changes if we get it out of the way
now.

MFC after: 3 days

3 years agoMention boot1.efi since it is an image of 800KB FAT filesystem stored as
Kevin Lo [Mon, 28 Dec 2020 02:30:21 +0000 (10:30 +0800)]
Mention boot1.efi since it is an image of 800KB FAT filesystem stored as
/EFI/BOOT/BOOTX64.EFI.
Differential Revision: https://reviews.freebsd.org/D27782

3 years agocache: reduce engrish in previous commit
Mateusz Guzik [Mon, 28 Dec 2020 02:05:30 +0000 (02:05 +0000)]
cache: reduce engrish in previous commit

3 years agocache: save on some branching in common case mount point traversal
Mateusz Guzik [Mon, 28 Dec 2020 01:52:20 +0000 (01:52 +0000)]
cache: save on some branching in common case mount point traversal

3 years agovfs: stop open-coding setting WILLBEDIR flag
Mateusz Guzik [Mon, 28 Dec 2020 01:17:15 +0000 (01:17 +0000)]
vfs: stop open-coding setting WILLBEDIR flag

3 years agovfs: add FAILIFEXISTS flag
Mateusz Guzik [Sun, 27 Dec 2020 23:33:04 +0000 (23:33 +0000)]
vfs: add FAILIFEXISTS flag

Both FreeBSD and Linux mkdir -p walk the tree up ignoring any EEXIST on
the way and both are used a lot when building respective kernels.

This poses a problem as spurious locking avoidably interferes with
concurrent operations like getdirentries on affected directories.

Work around the problem by adding FAILIFEXISTS flag. In case of lockless
lookup this manages to avoid any work to begin with, there is no speed
up for the locked case but perhaps this can be augmented later on.

For simplicity the only supported semantics are as used by mkdir.

Reviewed by: kib (previous version)
Differential Revision: https://reviews.freebsd.org/D27789

3 years agocache: simplify lockless dot lookups
Mateusz Guzik [Mon, 28 Dec 2020 00:12:28 +0000 (00:12 +0000)]
cache: simplify lockless dot lookups

3 years agoroute: quiet -Wredundant-decls
Ryan Libby [Mon, 28 Dec 2020 00:32:27 +0000 (16:32 -0800)]
route: quiet -Wredundant-decls

Remove declaration duplicated in
f5baf8bb12f39d0e8d64508c47eb6c4386ef716d

Reviewed by: melifaro
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27790

3 years agobsdcat,cpio,tar: Bump version number to 3.5.1
Martin Matuska [Sun, 27 Dec 2020 23:35:49 +0000 (00:35 +0100)]
bsdcat,cpio,tar: Bump version number to 3.5.1

Matches import of libarchive 3.5.1

3 years agocontrib/libarchive: Import libarchive 3.5.1
Martin Matuska [Sun, 27 Dec 2020 23:34:06 +0000 (00:34 +0100)]
contrib/libarchive: Import libarchive 3.5.1

Merge commit '8be2bb3d35e232080b4e39244020e650bbe31562' into main

3 years agoUpdate vendor/libarchive/dist to 227a4b9719a7fbeba6ba46e377ff7d953f405cd5
Martin Matuska [Sun, 27 Dec 2020 23:06:27 +0000 (00:06 +0100)]
Update vendor/libarchive/dist to 227a4b9719a7fbeba6ba46e377ff7d953f405cd5

Libarchive 3.5.1

3 years agoMerge commit d8a09b3a0 from openzfs git (by Ryan Libby):
Ryan Libby [Sun, 27 Dec 2020 22:33:13 +0000 (14:33 -0800)]
Merge commit d8a09b3a0 from openzfs git (by Ryan Libby):

  lua: avoid gcc -Wreturn-local-addr bug

  Avoid a bug with gcc's -Wreturn-local-addr warning with some
  obfuscation.  In buggy versions of gcc, if a return value is an
  expression that involves the address of a local variable, and even if
  that address is legally converted to a non-pointer type, a warning may
  be emitted and the value of the address may be replaced with zero.
  Howerver, buggy versions don't emit the warning or replace the value
  when simply returning a local variable of non-pointer type.

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90737

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Libby <rlibby@FreeBSD.org>
  Closes #11337

3 years agoMerge commit 956f94010 from openzfs git (by Ryan Libby):
Ryan Libby [Sun, 27 Dec 2020 22:33:13 +0000 (14:33 -0800)]
Merge commit 956f94010 from openzfs git (by Ryan Libby):

  spa: avoid type narrowing warning

  Building the spa module for i386 caused gcc to emit
  -Wint-to-pointer-cast "cast to pointer from integer of different size"
  because spa.spa_did was uint64_t but pthread_join (via thread_join in
  spa_deactivate) takes a pointer (32-bit on i386).  Define spa_did to be
  pointer-size instead.  For now spa_did is in fact never non-zero and the
  thread_join could instead be ifdef'd out, but changing the size of
  spa_did may be more useful for the future.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Libby <rlibby@FreeBSD.org>
  Closes #11336

3 years agoMerge commit c7500ded3 from openzfs git (by Ryan Libby):
Ryan Libby [Sun, 27 Dec 2020 22:33:13 +0000 (14:33 -0800)]
Merge commit c7500ded3 from openzfs git (by Ryan Libby):

  FreeBSD libzfs: gcc requires __thread after static

  Building libzfs with gcc on FreeBSD failed because gcc is picky about
  the order of keywords in declarations with __thread, whereas clang is
  more relaxed.

  https://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ryan Libby <rlibby@FreeBSD.org>
  Closes #11331

3 years agoMerge commit 3fcd73747 from openzfs git (by Adrian Chadd):
Ryan Libby [Sun, 27 Dec 2020 22:33:13 +0000 (14:33 -0800)]
Merge commit 3fcd73747 from openzfs git (by Adrian Chadd):

  Fix compiling on FreeBSD + gcc - don't assume illmnos bits

  This looks like it was once from the illumnos compat code.
  FreeBSD doesn't have cmn_err as a compiler format attribute, so
  it definitely errors out.

  It doesn't show up on LLVM because it doesn't trigger at all.

  Add in the format flags but keep them behind #if 0 for now;
  there are too many format issues that trigger when one does
  format checking in the shared code.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: adrian chadd <adrian@freebsd.org>
  Closes #11068
  Closes #11069

3 years agoMerge commit 79a357c2a from openzfs git (by Adrian Chadd):
Ryan Libby [Sun, 27 Dec 2020 22:33:13 +0000 (14:33 -0800)]
Merge commit 79a357c2a from openzfs git (by Adrian Chadd):

  Fix pointer-is-uint64_t-sized assumption in the ioctl path

  This shows up when compiling freebsd-head on amd64 using gcc-6.4.
  The lib32 compat build ends up tripping over this assumption.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: adrian chadd <adrian@freebsd.org>
  Closes #11068
  Closes #11069

3 years agoopenzfs: fix gcc kernel module builds
Ryan Libby [Sun, 27 Dec 2020 22:33:13 +0000 (14:33 -0800)]
openzfs: fix gcc kernel module builds

 - Suppress -Wredundant-decls.  Ultimately this warning is harmless in
   any case, and it does not look like there is a simple way to avoid
   redundant declarations in this case without a lot of header pollution
   (e.g. having openzfs's shim param.h pulling in sys/kernel.h for hz).
 - Suppress -Wnested-externs, which is useless anyway.

Unfortunately it was not sufficient just to modify OPENZFS_CFLAGS,
because the warning suppressions need to appear on the command line
after they are explicitly enabled by CWARNFLAGS from sys/conf/kern.mk,
but OPENZFS_CFLAGS get added before due to use of -I for the shims.

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27685

3 years agomsdosfs: Fix a leak of dirent padding bytes
Mark Johnston [Sun, 27 Dec 2020 21:52:30 +0000 (16:52 -0500)]
msdosfs: Fix a leak of dirent padding bytes

This was missed in r340856 / commit
6d2e2df764199f0a15fd743e79599391959cc17d.  Three bytes from the kernel
stack may be leaked when reading directory entries.

Reported by: Syed Faraz Abrar <faraz@elttam.com>
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agovm: Fix some bugs in the page busying code
Mark Johnston [Sun, 27 Dec 2020 21:50:54 +0000 (16:50 -0500)]
vm: Fix some bugs in the page busying code

In vm_page_busy_acquire(), load the object pointer using
atomic_load_ptr() as we do elsewhere.  Per the comment, the object
identity must be consistent across sleeps.

In vm_page_grab_sleep(), pass the correct pindex to
_vm_page_busy_sleep().  The pindex is used to re-check the page's
identity before going to sleep.  In particular, vm_page_grab_sleep() is
used in unlocked grab, so the object lock is not necessarily held when
verifying the page's identity, and the pindex may change if the page is
moved, or freed and re-allocated.  I believe this can result in spurious
VM_PAGER_FAILs from vm_page_grab_valid_unlocked() or early termination
of vm_page_grab_pages_unlocked().

In vm_page_grab_pages(), pass the correct pindex to
vm_page_grab_sleep().  Otherwise I believe vm_page_grab_pages() will
effectively spin when attempting to busy a busy page after the first
index in the range.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27607

3 years agouma: Remove the MINBUCKET flag from the flag name list
Mark Johnston [Sun, 27 Dec 2020 21:50:24 +0000 (16:50 -0500)]
uma: Remove the MINBUCKET flag from the flag name list

This should have been done in r368399 / commit
f8b6c51538fab88a7a62a399fb0948806b06133c.

Reported by: rlibby
Sponsored by: The FreeBSD Foundation

3 years agomd: Set bio_completed properly in the face of errors
Mark Johnston [Sun, 27 Dec 2020 21:49:35 +0000 (16:49 -0500)]
md: Set bio_completed properly in the face of errors

Account for any residual bytes.  This is only relevant for vnode-backed
md(4) devices.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27738

3 years agoImport bc 3.2.4
Stefan Eßer [Sun, 27 Dec 2020 20:53:09 +0000 (21:53 +0100)]
Import bc 3.2.4

3 years agoReplace sscanf() by strtoul()
Stefan Eßer [Sat, 26 Dec 2020 21:21:49 +0000 (22:21 +0100)]
Replace sscanf() by strtoul()

This change has been motivated by a mail from bde sent in 2015 in
which he mentioned inappropriate use of sscanf() in 3 programs in
/bin.

This change removes the potential mismatch of the types of the return
values and the variable width specified in the scan pattern. While
there was no issue with the patterns and types used, the new code is
simpler and more efficient.

3 years agoSimplify LS_COLWIDTHS processing
Stefan Eßer [Sat, 26 Dec 2020 21:10:54 +0000 (22:10 +0100)]
Simplify LS_COLWIDTHS processing

The previous version normalized the width list (replaced empty fields
with "0") just to be able to use sscanf() on the string.

It is much simpler to just parse the string as-is.

The clearing of f_notabs is preserved for the case that less than 9
width values have been defined, but I do not understand the rationale
for this particular condition. E.g., LS_COLWIDTHS="::::::::" will be
counted as 9 defined fields (may clear f_notabs) but is no different
fron LS_COLWIDTHS="" with regard to the field width (and that does not
clear f_notabs, since there are less than 9 fields).

3 years agoAdjust to display more than 999 sleeping threads
Stefan Eßer [Fri, 25 Dec 2020 11:38:53 +0000 (12:38 +0100)]
Adjust to display more than 999 sleeping threads

3 years agoStatistics are for threads, not processes
Stefan Eßer [Fri, 25 Dec 2020 11:38:17 +0000 (12:38 +0100)]
Statistics are for threads, not processes

3 years agolibsa: xdrproc_t should return bool
Toomas Soome [Sun, 27 Dec 2020 21:19:41 +0000 (23:19 +0200)]
libsa: xdrproc_t should return bool

Since our xdr translation function are returning bool, so should
xdrproc_t.

Issue reported by gcc 10 build.

3 years agocache: modification and last entry filling support in lockless lookup v2
Mateusz Guzik [Sun, 27 Dec 2020 19:19:43 +0000 (19:19 +0000)]
cache: modification and last entry filling support in lockless lookup v2

The previous patch failed to set the ISDOTDOT flag when appropriate,
which in turn fail to properly handle degenerate lookups.

While here sprinkle some extra assertions.

Tested by: pho (previous version)

3 years agocache: assert internal flags are not passed by namei
Mateusz Guzik [Sun, 27 Dec 2020 19:42:16 +0000 (19:42 +0000)]
cache: assert internal flags are not passed by namei

3 years agoRevert "cache: modification and last entry filling support in lockless lookup"
Mateusz Guzik [Sun, 27 Dec 2020 19:02:29 +0000 (19:02 +0000)]
Revert "cache: modification and last entry filling support in lockless lookup"

This reverts commit 6dbb07ed6872ae7988b9b705e322c94658eba6d1.

Some ports unreliably fail to build with rmdir getting ENOTEMPTY.

3 years agoPerform kernel linker ifunc test only for builds
Ed Maste [Sun, 27 Dec 2020 00:34:24 +0000 (19:34 -0500)]
Perform kernel linker ifunc test only for builds

dvl reported that "make installkernel" failed with "amd64/arm64/i386
kernel requires linker ifunc support."  This test should apply to builds
only; the linker is not used at install time.

I think the same (ifunc-supporting) linker used to build the kernel
should be detected at install time in usual cases (and so not trigger
this error).  However, there is no reason to disallow the install, if
for some reason the expected linker isn't the one tested at install
time.

PR: 251580
Reported by: dvl
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agocache: modification and last entry filling support in lockless lookup
Mateusz Guzik [Sun, 27 Dec 2020 15:28:14 +0000 (15:28 +0000)]
cache: modification and last entry filling support in lockless lookup

Tested by: pho (previous version)

3 years agoEXTRES: Ignore index modifier flags for table based clock dividers.
Michal Meloun [Thu, 4 Jan 2018 12:12:39 +0000 (13:12 +0100)]
EXTRES: Ignore index modifier flags for table based clock dividers.

The divider table already contains the correct HW divider value, it should
not be modified by other flags such as 'CLK_DIV_ZERO_BASED'.

MFC after: 4 weeks

3 years agoamd64 nmi handler: fix comment about %ebx
Konstantin Belousov [Sun, 27 Dec 2020 10:47:36 +0000 (12:47 +0200)]
amd64 nmi handler: fix comment about %ebx

Reported by: markj
MFC after: 3 days

3 years agoamd64: preserve %cr2 in NMI/MCE/DBG handlers.
Konstantin Belousov [Fri, 25 Dec 2020 21:58:43 +0000 (23:58 +0200)]
amd64: preserve %cr2 in NMI/MCE/DBG handlers.

These handlers could interrupt code which has interrupts disabled,
and if a spurious page fault occurs during exception handler run,
we get clobbered %cr2 in higher level stack.

This is mostly a speculation, but it is based on hints from good sources.

MFC after: 1 week
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27772

3 years agoRegen.
Konstantin Belousov [Sun, 27 Dec 2020 10:55:50 +0000 (12:55 +0200)]
Regen.

3 years agoDecode and report native eventfd descriptors from libprocstat and procstat.
Konstantin Belousov [Wed, 23 Dec 2020 14:17:44 +0000 (16:17 +0200)]
Decode and report native eventfd descriptors from libprocstat and procstat.

Submitted by:   greg@unrelenting.technology
Reviewed by:    markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668

3 years agoDocument eventfd().
Konstantin Belousov [Wed, 23 Dec 2020 14:17:09 +0000 (16:17 +0200)]
Document eventfd().

Submitted by:   greg@unrelenting.technology
Reviewed by:    bcr, markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668

3 years agokqueue(2): Use .Fo instead .Ft
Konstantin Belousov [Wed, 23 Dec 2020 15:22:09 +0000 (17:22 +0200)]
kqueue(2): Use .Fo instead .Ft

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agoAdd eventfd(3) wrappers to libc.
Konstantin Belousov [Wed, 23 Dec 2020 14:16:35 +0000 (16:16 +0200)]
Add eventfd(3) wrappers to libc.

eventfd_read/write one-liners are from musl libc.

Submitted by:   greg@unrelenting.technology
Reviewed by:    markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668

3 years agoExpose eventfd in the native API/ABI using a new __specialfd syscall
Konstantin Belousov [Wed, 23 Dec 2020 14:14:04 +0000 (16:14 +0200)]
Expose eventfd in the native API/ABI using a new __specialfd syscall

eventfd is a Linux system call that produces special file descriptors
for event notification. When porting Linux software, it is currently
usually emulated by epoll-shim on top of kqueues.  Unfortunately, kqueues
are not passable between processes.  And, as noted by the author of
epoll-shim, even if they were, the library state would also have to be
passed somehow.  This came up when debugging strange HW video decode
failures in Firefox.  A native implementation would avoid these problems
and help with porting Linux software.

Since we now already have an eventfd implementation in the kernel (for
the Linuxulator), it's pretty easy to expose it natively, which is what
this patch does.

Submitted by:   greg@unrelenting.technology
Reviewed by:    markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668

3 years agoRemove useless ARGUSED annotations.
Konstantin Belousov [Wed, 23 Dec 2020 13:25:02 +0000 (15:25 +0200)]
Remove useless ARGUSED annotations.

Submitted by: greg@unrelenting.technology

3 years agoAdd SPDX tag.
Konstantin Belousov [Wed, 23 Dec 2020 13:18:57 +0000 (15:18 +0200)]
Add SPDX tag.

Submitted by: greg@unrelenting.technology

3 years agojail: add a missing lock around an osd_jail_call().
Jamie Gritton [Sun, 27 Dec 2020 04:49:30 +0000 (20:49 -0800)]
jail: add a missing lock around an osd_jail_call().

allprison_lock should be at least held shared when jail OSD methods
are called.  Add a shared lock around one such call where that wasn't
the case.

In another such call, change an exclusive lock grab to be shared in
what is likely the more common case.

3 years agojail: Consistently handle the pr_allow bitmask
Jamie Gritton [Sun, 27 Dec 2020 04:25:02 +0000 (20:25 -0800)]
jail: Consistently handle the pr_allow bitmask

Return a boolean (i.e. 0 or 1) from prison_allow, instead of the flag
value itself, which is what sysctl expects.

Add prison_set_allow(), which can set or clear a permission bit, and
propagates cleared bits down to child jails.

Use prison_allow() and prison_set_allow() in the various jail.allow.*
sysctls, and others that depend on thoe permissions.

Add locking around checking both pr_allow and pr_enforce_statfs in
prison_priv_check().

3 years agojail: Make comments on struct prison locking more precise
Jamie Gritton [Sun, 27 Dec 2020 01:01:16 +0000 (17:01 -0800)]
jail: Make comments on struct prison locking more precise

3 years agoFix daily_backup_gpart_exclude in periodic daily 221.backup-gpart
Ed Maste [Sun, 27 Dec 2020 00:24:18 +0000 (19:24 -0500)]
Fix daily_backup_gpart_exclude in periodic daily 221.backup-gpart

Since gpart_devs was not quoted (losing embedded newlines), if
daily_backup_gpart_exclude matched something, gpart_devs was empty.

PR: 251961
Submitted by: Kan Sasaki
MFC after: 1 week

3 years agoFix default route handling in radix4_lockless algo.
Alexander V. Chernikov [Sat, 26 Dec 2020 22:46:43 +0000 (22:46 +0000)]
Fix default route handling in radix4_lockless algo.
Improve nexthop debugging.

Reported by: Florian Smeets <flo at smeets.xyz>

3 years agosym.4: Remove remainder of SYM_SETUP_LP_PROBE_MAP documentation
Marius Strobl [Sat, 26 Dec 2020 21:38:59 +0000 (22:38 +0100)]
sym.4: Remove remainder of SYM_SETUP_LP_PROBE_MAP documentation

This option has been removed in 221ac8f4cd823a2b047c2807e2cf744c7176dd1f
and r339575 respectively.

3 years agosendfile: Ensure that sfio->npages is initialized
Mark Johnston [Sat, 26 Dec 2020 21:07:40 +0000 (16:07 -0500)]
sendfile: Ensure that sfio->npages is initialized

We initialize sfio->npages only when some I/O is required to satisfy the
request.  However, sendfile_iodone() contains an INVARIANTS-only check
that references sfio->npages, and this check is executed even if no I/O
is performed, so the check may use an uninitialized value.

Fix the problem by initializing sfio->npages earlier.  Note that
sendfile_swapin() always initializes the page array.  In some rare cases
we need to trim the page array so ensure that sfio->npages gets updated
accordingly.

Reported by: syzkaller (with KASAN)
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27726

3 years agojail: Fix lock-free access to dynamic pr.allow flags
Jamie Gritton [Sat, 26 Dec 2020 20:53:28 +0000 (12:53 -0800)]
jail: Fix lock-free access to dynamic pr.allow flags

Use atomic access and a memory barrier to ensure that the flag parameter
in pr_flag_allow is indeed set after the rest of the structure is valid.

Simplify adding flag bits with pr_allow_all, a dynamic version of
PR_ALLOW_ALL_STATIC.

3 years agoUse the base address for early arm64 page tables
Andrew Turner [Wed, 23 Dec 2020 18:56:09 +0000 (18:56 +0000)]
Use the base address for early arm64 page tables

Use the kernel physical base rather than the ttbr0 base when building
the kernel identity map. The latter is correct with current assumptions
but may not always be the case.

Sponsored by: Innovate UK

3 years agonsphy(4): Remove obsolete support for pcn(4)
Marius Strobl [Sat, 26 Dec 2020 18:20:03 +0000 (19:20 +0100)]
nsphy(4): Remove obsolete support for pcn(4)

This should have gone in 607790d10fdb97d25cdc0bbe9ed6eaae67383ae1 and
r347915 respectively along with pcn(4).