]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoTeach DTrace that unaligned accesses are OK on aarch64, not just x86.
Robert Watson [Mon, 22 Mar 2021 01:50:00 +0000 (01:50 +0000)]
Teach DTrace that unaligned accesses are OK on aarch64, not just x86.

Reviewed by: andrew
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D29369

(cherry picked from commit fb581531c1a0e6f1bf5392a2e97ed39d21d6e1fd)
(cherry picked from commit ba08ba5226ff8551ea3926ce49b8604b71c9cabf)

3 years agoTune DTrace 'aframes' for the FBT and profile providers on arm64.
Robert Watson [Sun, 21 Mar 2021 00:01:54 +0000 (00:01 +0000)]
Tune DTrace 'aframes' for the FBT and profile providers on arm64.

In both cases, too few frames were trimmed, leading to exception handling
or DTrace internals being exposed in stack traces exposed by D's stack()
primitive.

Reviewed by: emaste, andrew
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D29356

(cherry picked from commit 599fb1d198ec6792ba062114d2589ca9f01a3568)
(cherry picked from commit fcc700abe4fa85b0f0ec9d953436725533cecc17)

3 years agoarm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs
Ed Maste [Wed, 17 Mar 2021 14:10:41 +0000 (10:10 -0400)]
arm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs

On FreeBSD/arm fill_fpregs, fill_dbregs are stubs that zero the reg
struct and return success. set_fpregs and set_dbregs do nothing and
return success.

Provide the same implementation for arm64 COMPAT_FREEBSD32.

Reviewed by: andrew
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29314

(cherry picked from commit 5be27cbf16c85ce95d21db57349f61494f851821)
(cherry picked from commit db50c8123469e3eab07e931019bf6d4df2d55c78)

3 years agomn: report that this driver is removed in 14, not 13
Ed Maste [Thu, 25 Mar 2021 02:35:38 +0000 (22:35 -0400)]
mn: report that this driver is removed in 14, not 13

(cherry picked from commit a66e75d9e2ddd9a84f8de204438282a25bb1a954)

mn: bump deprecation version to 14 in man page as well

Fixes: 66e75d9e2ddd ("mn: report that this driver is removed in 14, not 13")
(cherry picked from commit 6acecf247f60fcd3ba9662d54c59fc7bd46fb67a)

Approved by: re (gjb)

3 years ago13.0: update to RC4
Glen Barber [Sun, 28 Mar 2021 23:51:40 +0000 (19:51 -0400)]
13.0: update to RC4

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoPlug nexthop group refcount leak.
Alexander V. Chernikov [Wed, 24 Mar 2021 23:51:45 +0000 (23:51 +0000)]
Plug nexthop group refcount leak.
In case with batch route delete via rib_walk_del(), when
 some paths from the multipath route gets deleted, old
 multipath group were not freed.

PR:    254496
Reported by:   Zhenlei Huang <zlei.huang@gmail.com>
Approved by: re (gjb)

(cherry picked from commit 47c00a9835926e96e562c67fa28e4432e99d9c56)

3 years agoFix panic when destroying interface with ECMP routes.
Alexander V. Chernikov [Tue, 23 Mar 2021 22:00:04 +0000 (22:00 +0000)]
Fix panic when destroying interface with ECMP routes.

Reported by: Zhenlei Huang <zlei.huang at gmail.com>
PR: 254496
Approved by: re (gjb)

(cherry picked from commit af85312e8a6f34ea7c8af77b9841fab6b5559e25)

3 years agoFix kassert panic when inserting multipath routes from multiple threads.
Alexander V. Chernikov [Sun, 21 Mar 2021 18:15:29 +0000 (18:15 +0000)]
Fix kassert panic when inserting multipath routes from multiple threads.

Reported by: Marco Zec <zec at fer.hr>
Approved by: re (gjb)

(cherry picked from commit 42f997d9b721ce5b64c37958f21fa81630f5a224)

3 years agoFlush remaining routes from the routing table during VNET shutdown.
Alexander V. Chernikov [Mon, 8 Mar 2021 21:35:41 +0000 (21:35 +0000)]
Flush remaining routes from the routing table during VNET shutdown.

Summary:
This fixes rtentry leak for the cloned interfaces created inside the
 VNET.

Loopback teardown order is `SI_SUB_INIT_IF`, which happens after `SI_SUB_PROTO_DOMAIN` (route table teardown).
Thus, any route table operations are too late to schedule.
As the intent of the vnet teardown procedures to minimise the amount of effort by doing global cleanups instead of per-interface ones, address this by adding a relatively light-weight routing table cleanup function, `rib_flush_routes()`.
It removes all remaining routes from the routing table and schedules the deletion, which will happen later, when `rtables_destroy()` waits for the current epoch to finish.

Test Plan:
```
set_skip:set_skip_group_lo  ->  passed  [0.053s]
tail -n 200 /var/log/messages | grep rtentry
```

PR: 253998
Reported by: rashey at superbox.pl
Reviewed By: kp
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D29116

(cherry picked from commit 8aafa7a0276302a0dcc3d0bd78b4d3842dfd1640)

3 years agoFix blackhole/reject routes.
Alexander V. Chernikov [Mon, 8 Feb 2021 23:29:05 +0000 (23:29 +0000)]
Fix blackhole/reject routes.

Traditionally *BSD routing stack required to supply some
 interface data for blackhole/reject routes. This lead to
 varieties of hacks in routing daemons when inserting such routes.
With the recent routeing stack changes, gateway sockaddr without
 RTF_GATEWAY started to be treated differently, purely as link
 identifier.

This change broke net/bird, which installs blackhole routes with
 127.0.0.1 gateway without RTF_GATEWAY flags.

Fix this by automatically constructing necessary gateway data at
 rtsock level if RTF_REJECT/RTF_BLACKHOLE is set.

Reported by: Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
Reviewed by: donner
Approved by: re (gjb)

(cherry picked from commit 3489286a5f368e7fcf11a9691f9bb5df77abe9a3)

3 years agorelease: amd64: Fix ISO/USB hybrid image
Emmanuel Vadot [Sat, 27 Mar 2021 11:04:51 +0000 (12:04 +0100)]
release: amd64: Fix ISO/USB hybrid image

Recent mkimg changes forces to have partitions given in explicit order.
This is so we can have the first partition starting at a specific offset
and the next ones starting after without having to specify an offset.
Switch the partition in the mkisoimage.sh script so the first one created
is the isoboot one.

Approved by: re(gjb)
PR:    254490
Reported by: Michael Dexter <editor@callfortesting.org
Tested by: Vincent Milum Jr <freebsd@darkain.com>
MFC after: Right now

(cherry picked from commit 90d2f7c413f9fc4ac479fa5e91ba1de6d4ea8d45)
(cherry picked from commit 08639983e0384556a37d19814f55417f604964a1)

3 years agoMakefile.inc1: unbreak bootstrap when kbdcontrol does not exist
Glen Barber [Wed, 24 Mar 2021 00:47:14 +0000 (20:47 -0400)]
Makefile.inc1: unbreak bootstrap when kbdcontrol does not exist

Approved by: re (cperciva)
Submitted by: Evgeniy Khramtsov
Reviewed by: arichardson
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 50179c5ec7d09d7b02497caf95dca5d33f93bcd9)
(cherry picked from commit 1048c56784c0e1d044b6828b030f326e48eaba28)

3 years agoaccept_filter: Fix filter parameter handling
Mark Johnston [Thu, 25 Mar 2021 21:55:20 +0000 (17:55 -0400)]
accept_filter: Fix filter parameter handling

For filters which implement accf_create, the setsockopt(2) handler
caches the filter name in the socket, but it also incorrectly frees the
buffer containing the copy, leaving a dangling pointer.  Note that no
accept filters provided in the base system are susceptible to this, as
they don't implement accf_create.

Approved by: re (gjb)
Reported by: Alexey Kulaev <alex.qart@gmail.com>
Discussed with: emaste
Security: kernel use-after-free
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 653a437c04440495cd8e7712c7cf39444f26f1ee)
(cherry picked from commit c7d10e7ec872070a40bbddc3158b1997c1df09af)

3 years agopf: Handle unmapped mbufs when computing checksums
Mark Johnston [Tue, 23 Mar 2021 13:38:59 +0000 (09:38 -0400)]
pf: Handle unmapped mbufs when computing checksums

Approved by: re (cperciva)
PR: 254419
Reviewed by: gallatin, kp
Tested by: Igor A. Valkov <viaprog@gmail.com>
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29378

(cherry picked from commit b93a796b06ec013a75a08ac43d8acf6aa94aa970)
(cherry picked from commit 5fcab6fbcf8b99d1420e681731a07670c38defe3)

3 years agoAdd UPDATING entry for OpenSSL advisory and bump version number.
Gordon Tetlow [Thu, 25 Mar 2021 23:38:52 +0000 (23:38 +0000)]
Add UPDATING entry for OpenSSL advisory and bump version number.

Approved by: re (implicit)
Approved by: so

3 years agortsold: Fix validation of RDNSS options
Mark Johnston [Sun, 21 Mar 2021 18:18:10 +0000 (14:18 -0400)]
rtsold: Fix validation of RDNSS options

The header specifies the size of the option in multiples of eight bytes.
The option consists of an eight-byte header followed by one or more IPv6
addresses, so the option is invalid if the size is not equal to 1+2n for
some n>0.  Check this.

The bug can cause random stack data to be formatted as an IPv6 address
and passed to resolvconf(8), but a host able to trigger the bug may also
specify arbitrary addresses this way.

Approved by: re (cperciva)
Reported by: Q C <cq674350529@gmail.com>
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1af332a7d8f86b6fcc1f0f575fe5b06021b54f4c)
(cherry picked from commit e4bdf7ac2a32ba1f2402e06360e476ec804210e7)

3 years agoOpenSSL: Regen manual pages for 1.1.1k
Jung-uk Kim [Thu, 25 Mar 2021 16:17:52 +0000 (12:17 -0400)]
OpenSSL: Regen manual pages for 1.1.1k

(cherry picked from commit 7595394130a163b7ff53d9ef3f28fcb87f629d17)

Approved by: re (implicit)

3 years agoOpenSSL: Merge OpenSSL 1.1.1k
Jung-uk Kim [Thu, 25 Mar 2021 15:45:19 +0000 (11:45 -0400)]
OpenSSL: Merge OpenSSL 1.1.1k

Merge commit '94fa08a4bcdfbb3434b025d67d014af3b18e5380'

(cherry picked from commit b6c1fdcdf5033d20c61cc77d66f58f31cc65e2ba)

Approved by: re (implicit)

3 years agorandom(9): Restore historical [0,2^31-1] output range and related man documention.
Lawrence Stewart [Wed, 24 Mar 2021 04:25:49 +0000 (15:25 +1100)]
random(9): Restore historical [0,2^31-1] output range and related man documention.

Commit SVN r364219 / Git 8a0edc914ffd changed random(9) to be a shim around
prng32(9) and inadvertently caused random(9) to begin returning numbers in the
range [0,2^32-1] instead of [0,2^31-1], where the latter has been the documented
range for decades.

The increased output range has been identified as the source of numerous bugs in
code written against the historical output range e.g. ipfw "prob" rules and
stats(3) are known to be affected, and a non-exhaustive audit of the tree
identified other random(9) consumers which are also likely affected.

As random(9) is deprecated and slated for eventual removal in 14.0, consumers
should gradually be audited and migrated to prng(9).

Submitted by: Loic Prylli <lprylli@netflix.com>
Obtained from: Netflix
Reviewed by: cem, delphij, imp
MFC after: 1 day
MFC to: stable/13, releng/13.0
Differential Revision: https://reviews.freebsd.org/D29385
Approved by: re (delphij)

(cherry picked from commit dbbf3e3f37d67d3eae0931855f8b62b9b299b80a)

3 years agoMFC: Fix post-start check when unbound.conf has moved.
Dag-Erling Smørgrav [Wed, 10 Mar 2021 14:18:59 +0000 (14:18 +0000)]
MFC: Fix post-start check when unbound.conf has moved.

On behalf of: des
Reported by: phk@
Sponsored by: Rubicon Communications, LLC ("Netgate")
Approved by: re (cperciva)

(cherry picked from commit 409388cfac49a312034e9397c870e3f81ff90734)
(cherry picked from commit c6aa83342e5deccc51f627fcb92ca083fe798a3b)

3 years agoMFC: Fix local-unbound setup for some IPv6 deployments.
Dag-Erling Smørgrav [Wed, 10 Mar 2021 14:01:38 +0000 (14:01 +0000)]
MFC: Fix local-unbound setup for some IPv6 deployments.

On behalf of: des
PR: 250984
Sponsored by: Rubicon Communications, LLC ("Netgate")
Approved by: re (cperciva)

(cherry picked from commit e5f02c140bf1e519a95bd6331382e8a2a1b6219f)
(cherry picked from commit 34e12e9a177a1d2386a855eb5a497f6f8a680180)

3 years agoAArch64: Don't set flush-subnormals-to-zero flag on startup
Alex Richardson [Mon, 1 Mar 2021 14:27:30 +0000 (14:27 +0000)]
AArch64: Don't set flush-subnormals-to-zero flag on startup

This flag has been set on startup since 65618fdda0f272a823e6701966421bdca0efa301.
However, This causes some of the math-related tests to fail as they report
zero instead of a tiny number. This fixes at least
/usr/tests/lib/msun/ldexp_test and possibly others.
Additionally, setting this flag prevents printf() from printing subnormal
numbers in decimal form.
See also https://www.openwall.com/lists/musl/2021/02/26/1

PR: 253847
Reviewed By: mmel
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D28938

(cherry picked from commit 0e4ff0acbe80c547988bede738af2e227c7eb47c)
(cherry picked from commit d37fb0e37814db8f76462b3b9f1fb0e6dfca6324)

3 years agonetmap: fix issues in nm_os_extmem_create()
Vincenzo Maffione [Sat, 20 Mar 2021 17:15:50 +0000 (17:15 +0000)]
netmap: fix issues in nm_os_extmem_create()

- Call vm_object_reference() before vm_map_lookup_done().
- Use vm_mmap_to_errno() to convert vm_map_* return values to errno.
- Fix memory leak of e->obj.

Approved by: re (gjb)
Reported by: markj
Reviewed by: markj
MFC after: 1 week

(cherry picked from commit ee7ffaa2e6e08b63efb4673610875d40964d5058)
(cherry picked from commit 3e4127f8f2933029034ac618a0013f434cb4a420)

3 years agonetmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET
Vincenzo Maffione [Mon, 15 Mar 2021 17:39:18 +0000 (17:39 +0000)]
netmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET

The netmap_ioctl() function has a reference counting bug in case of
NETMAP_REQ_PORT_INFO_GET command. When `hdr->nr_name[0] == '\0'`,
the function does not decrease the refcount of "nmd", which is
increased by netmap_mem_find(), causing a refcount leak.

Approved by: re (gjb)
Reported by: Xiyu Yang <sherllyyang00@gmail.com>
Submitted by: Carl Smith <carl.smith@alliedtelesis.co.nz>
MFC after: 3 days
PR: 254311

(cherry picked from commit 0ab5902e8ad93d0a9341dcce386b6c571ee02173)
(cherry picked from commit 120a4bd4e9d05147a9774a2ca4b4eff48e062442)

3 years ago[PowerPC] [PowerPCSPE] Fix multiple issues in fpsetmask().
Brandon Bergren [Mon, 1 Mar 2021 03:06:59 +0000 (21:06 -0600)]
[PowerPC] [PowerPCSPE] Fix multiple issues in fpsetmask().

Building R on powerpc64 exposed a problem in fpsetmask() whereby we
were not properly clamping the provided mask to the valid range.

This same issue affects powerpc and powerpcspe.

Properly limit the range of bits that can be set via fpsetmask().

While here, use the correct fp_except_t type instead of fp_rnd_t.

Reported by: pkubaj, jhibbits (in IRC)
Sponsored by: Tag1 Consulting, Inc.
Approved by: re (gjb) (Post-RC3 outstanding request approved for RC4)

(cherry picked from commit 384ee7cc6e9e4ddc91a6e9e623fcbbe5826bce38)
(cherry picked from commit 8b96d6ac04e7e761ec6b9eff47c801a2b89fbd6d)

3 years ago[PowerPC64] Fix multiple issues in fpsetmask().
Brandon Bergren [Mon, 1 Mar 2021 02:35:53 +0000 (20:35 -0600)]
[PowerPC64] Fix multiple issues in fpsetmask().

Building R exposed a problem in fpsetmask() whereby we were not properly
clamping the provided mask to the valid range.

R initilizes the mask by calling fpsetmask(~0) on FreeBSD. Since we
recently enabled precise exceptions, this was causing an immediate
SIGFPE because we were attempting to set invalid bits in the fpscr.

Properly limit the range of bits that can be set via fpsetmask().

While here, use the correct fp_except_t type instead of fp_rnd_t.

Reported by: pkubaj (in IRC)
Sponsored by: Tag1 Consulting, Inc.
Approved by: re (gjb) (Post-RC3 outstanding request approved for RC4)

(cherry picked from commit dd95b39235dd81c890aa3cce02a5bb7f91f23803)
(cherry picked from commit a79735386c46298274d71577ab6b4dd00be261cc)

3 years agoFix scripted installs on EFI systems after default mounting of the ESP.
Nathan Whitehorn [Tue, 23 Mar 2021 13:19:42 +0000 (09:19 -0400)]
Fix scripted installs on EFI systems after default mounting of the ESP.

Because the ESP mount point (/boot/efi) is in mtree, tar will attempt to
extract a directory at that point post-mount when the system is installed.
Normally, this is fine, since tar can happily set whatever properties it
wants. For FAT32 file systems, however, like the ESP, tar will attempt to
set mtime on the root directory, which FAT does not support, and tar will
interpret this as a fatal error, breaking the install (see
https://github.com/libarchive/libarchive/issues/1516). This issue would
also break scripted installs on bare-metal POWER8, POWER9, and PS3
systems, as well as some ARM systems.

This patch solves the problem in two ways:
- If stdout is a TTY, use the distextract stage instead of tar, as in
  interactive installs. distextract solves this problem internally and
  provides a nicer UI to boot, but requires a TTY.
- If stdout is not a TTY, use tar but, as a stopgap for 13.0, exclude
  boot/efi from tarball extraction and then add it by hand. This is a
  hack, and better solutions (as in the libarchive ticket above) will
  obsolete it, but it solves the most common case, leaving only
  unattended TTY-less installs on a few tier-2 platforms broken.

In addition, fix a bug with fstab generation uncovered once the tar issue
is fixed that umount(8) can depend on the ordering of lines in fstab in a
way that mount(8) does not. The partition editor now writes out fstab in
mount order, making sure umount (run at the end of scripted, but not
interactive, installs) succeeds.

PR: 254395
Approved by: re (gjb)
Reviewed by: gjb, imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29380

(cherry picked from commit c2f16c595eb51c6e0cb6ece3f6f078d738019059)
(cherry picked from commit 4601382e1362352f17a33e4ed38db5dcfe3f6be5)

3 years ago13.0 release: update to RC3
Glen Barber [Thu, 18 Mar 2021 23:55:48 +0000 (19:55 -0400)]
13.0 release: update to RC3

Sponsored by: Rubicon Communications, LLC ("Netgate")
Approved by: re (implicit)

3 years agozfs: bring back possibility to rewind the checkpoint from
Mariusz Zaborski [Sat, 13 Mar 2021 11:56:17 +0000 (12:56 +0100)]
zfs: bring back possibility to rewind the checkpoint from

Add parsing of the rewind options.

When I was upstreaming the change [1], I omitted the part where we
detect that the pool should be rewind. When the FreeBSD repo has
synced with the OpenZFS, this part of the code was removed.

[1] FreeBSD repo: 277f38abffc6a8160b5044128b5b2c620fbb970c
[2] OpenZFS repo: f2c027bd6a003ec5793f8716e6189c389c60f47a

Originally reviewed by: tsoome, allanjude
Originally reviewed by: kevans (ok from high-level overview)

Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
PR: 254152
Approved by: re(gjb)
Reported by: Zhenlei Huang <zlei.huang at gmail.com>
Obtained from: https://github.com/openzfs/zfs/pull/11730

(cherry picked from commit 653ed678c70376b15cdc42daafa7b4554570cea2)
(cherry picked from commit 6bbca5ca3a6634fc10b93da203df2ae92cf60b61)

3 years agovtnet: fix TSO for TCP/IPv6
Michael Tuexen [Thu, 18 Mar 2021 20:25:47 +0000 (21:25 +0100)]
vtnet: fix TSO for TCP/IPv6

The decision whether a TCP packet is sent over IPv4 or IPv6 was
based on ethertype, which works correctly. In D27926 the criteria
was changed to checking if the CSUM_IP_TSO flag is set in the
csum-flags and then considering it to be TCP/IPv4.
However, the TCP stack sets the flag to CSUM_TSO for IPv4 and IPv6,
where CSUM_TSO is defined as CSUM_IP_TSO|CSUM_IP6_TSO.
Therefore TCP/IPv6 packets gets mis-classified as TCP/IPv4,
which breaks TSO for TCP/IPv6.
This patch bases the check again on the ethertype.
This fix is instantly MFCed.

Approved by: re(gjb)
PR: 254366
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D29331

(cherry picked from commit d4697a6b56168876fc0ffec1a0bb1b24d25b198e)
(cherry picked from commit 6064ea8172f078c54954bc6e8865625feb7979fe)

3 years agovfs: fix vnlru marker handling for filtered/unfiltered cases
Mateusz Guzik [Wed, 17 Mar 2021 21:33:47 +0000 (22:33 +0100)]
vfs: fix vnlru marker handling for filtered/unfiltered cases

The global list has a marker with an invariant that free vnodes are
placed somewhere past that. A caller which performs filtering (like ZFS)
can move said marker all the way to the end, across free vnodes which
don't match. Then a caller which does not perform filtering will fail to
find them. This makes vn_alloc_hard sleep for 1 second instead of
reclaiming, resulting in significant stalls.

Fix the problem by requiring an explicit marker by callers which do
filtering.

As a temporary measure extend vnlru_free to restart if it fails to
reclaim anything.

Big thanks go to the reporter for testing several iterations of the
patch.

Reported by: Yamagi <lists yamagi.org>
Tested by: Yamagi <lists yamagi.org>
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D29324
Approved by: re (gjb)

(cherry picked from commit e9272225e6bed840b00eef1c817b188c172338ee)

3 years ago base: remove if_wg(4) and associated utilities, manpage
Scott Long [Thu, 18 Mar 2021 07:34:07 +0000 (07:34 +0000)]
   base: remove if_wg(4) and associated utilities, manpage

   After length decisions, we've decided that the if_wg(4) driver and
   related work is not yet ready to live in the tree.  This driver has
   larger security implications than many, and thus will be held to
   more scrutiny than other drivers.

Requested by: secteam
Approved by: re

3 years agoservice(8): use an environment more consistent with init(8)
Andrew Gierth [Wed, 3 Mar 2021 18:25:11 +0000 (12:25 -0600)]
service(8): use an environment more consistent with init(8)

init(8) sets the "daemon" login class without specifying a pw
entry (so no substitutions are done on the variables). service(8)'s
use of env -L had the effect of specifying root's pw entry, with two
effects: getpwnam and getpwuid are being called, which may not be
entirely safe depending on what nsswitch is up to and what stage of
boot we are at, and substitutions would have been done.

Fix by teaching env(8) to allow -L -/classname to set the class
environment with no pw entry at all specified, and use it in
service(8).

PR: 253959
Approved by: re (gjb)

(cherry picked from commit 55deb0a5f089c8a27cfc1666655b93881c2b47ae)
(cherry picked from commit 0c1a5eaae83267365330437adb60f44e1a622a2b)
(cherry picked from commit 872ec7e5b6f35d84745b49c02f58572632de22ed)

3 years agolinux(4): make getcwd(2) return ERANGE instead of ENOMEM
Edward Tomasz Napierala [Fri, 12 Mar 2021 15:31:37 +0000 (15:31 +0000)]
linux(4): make getcwd(2) return ERANGE instead of ENOMEM

For native FreeBSD binaries, the return value from __getcwd(2)
doesn't really matter, as the libc wrapper takes over and returns
the proper errno.

Approved by: re (gjb)
PR: kern/254120
Reported By: Alex S <iwtcex@gmail.com>
Reviewed By: kib
Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29217

(cherry picked from commit 0dfbdd9fc269f0438ffcc31632d35234a90584ad)
(cherry picked from commit ab1a91d95872e59db3d476be4fefb0b58df3afc4)

3 years agodevelopment(7): update to reflect Git transition
Edward Tomasz Napierala [Thu, 11 Mar 2021 20:03:30 +0000 (20:03 +0000)]
development(7): update to reflect Git transition

Approved by: re (gjb)
Reviewed By: debdrup, imp (earlier version)
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D28939

(cherry picked from commit d28cbb7944e5b1015d94a04cadc97d473838611e)
(cherry picked from commit d7ef665e10dd3bc0a6f3c0a8e928cf2fe695a113)

3 years agox86: tsc: deprioritize TSC on VirtualBox
Kyle Evans [Mon, 8 Mar 2021 20:20:10 +0000 (14:20 -0600)]
x86: tsc: deprioritize TSC on VirtualBox

Misbehavior has been observed with TSC under VirtualBox, where threads
doing small sleeps (~1 second) may miss their wake up and hang around
in a sleep state indefinitely.  Switching back to ACPI-fast decidedly
fixes it, so stop using TSC on VirtualBox at least for the time being.

This partially reverts 84eaf2ccc6aa, applying it only to VirtualBox and
increasing the quality to 0. Negative qualities can never be chosen and
cannot be chosen with the tunable recently added. If we do not have a
timecounter with a higher quality than 0, then TSC does at least leave
the system mostly usable.

PR: 253087
Approved by: re (gjb)

(cherry picked from commit 8cc15b0dfc2f3299662e78f18bd6127f83c14ab4)
(cherry picked from commit ec24f78e5b201ea56a69607c6e4438a2faac25c0)

3 years agovm_reserv: Fix list locking in vm_reserv_reclaim_contig()
Mark Johnston [Sun, 14 Mar 2021 16:39:23 +0000 (12:39 -0400)]
vm_reserv: Fix list locking in vm_reserv_reclaim_contig()

The per-domain partpop queue is locked by the combination of the
per-domain lock and individual reservation mutexes.
vm_reserv_reclaim_contig() scans the queue looking for partially
populated reservations that can be reclaimed in order to satisfy the
caller's allocation.

During the scan, we drop the per-domain lock.  At this point, the rvn
pointer may be invalidated.  Take care to load rvn after re-acquiring
the per-domain lock.

While here, simplify the condition used to check whether a reservation
was dequeued while the per-domain lock was dropped.

Approved by: re (gjb)
Reviewed by: alc, kib
Reported by: gallatin
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29203

(cherry picked from commit 968079f253c11433d47bece4b41b46fcbf985903)
(cherry picked from commit cec3990d347972c30558b135b1bc9954184fb5fe)

3 years agogic_v3: add message based interrupts support
Cyprien Laplace [Sat, 5 Dec 2020 15:47:33 +0000 (10:47 -0500)]
gic_v3: add message based interrupts support

Pull Request: https://github.com/freebsd/freebsd-src/pull/451

(cherry picked from commit 35ebd8d33ad2f7c2038f6bf9aa02eab21252f689)
(cherry picked from commit acd69b070403e12742ccea7b19d251320ed788d5)

Approved by: re (gjb)

3 years agogic_v3: Use 64-bit writes to GICD_IROUTERn
Cyprien Laplace [Thu, 26 Nov 2020 01:17:04 +0000 (20:17 -0500)]
gic_v3: Use 64-bit writes to GICD_IROUTERn

While 32-bit accesses to GICD_IROUTERn are allowed,
this is a 64-bit register.

Pull Request: https://github.com/freebsd/freebsd-src/pull/451

(cherry picked from commit 46ca0b903cad8955574a2c61bed41c2b92aa2273)
(cherry picked from commit 40f283b038015b5b750267a26402098418fd1fb3)

Approved by: re (gjb)

3 years agoupdate to 13.0-RC2
Glen Barber [Fri, 12 Mar 2021 00:03:52 +0000 (19:03 -0500)]
update to 13.0-RC2

While here, switch the pkg(8) repo to use release_0 for populating
the dvd1.iso packages.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoAdd ObsoleteFiles.inc entries for various OCF headers removed in 13.
John Baldwin [Mon, 8 Mar 2021 19:17:21 +0000 (11:17 -0800)]
Add ObsoleteFiles.inc entries for various OCF headers removed in 13.

Approved by: re (gjb)

(cherry picked from commit ef74bfc6fed298d5ca0e3cb92bf008b715ea0c2f)
(cherry picked from commit da55db32647bfe56ce12857ad6ef611af4cfb7be)

3 years agoCorrect the name of the structure used for TCP socket options.
John Baldwin [Mon, 8 Mar 2021 18:46:40 +0000 (10:46 -0800)]
Correct the name of the structure used for TCP socket options.

The structure was renamed while refactoring Netflix's KTLS changes for
upstreaming, but the original name remained in tcp.4 and was
subsequently copied to ktls.4.

PR: 254141
Reported by: asomers
Approved by: re (gjb)

(cherry picked from commit c5a365623f88999b524d94003187ef09fda55f67)
(cherry picked from commit 0fc5395122b4b50564f3dc9164830a0d1635b622)

3 years agoRemove the usr/tests/usr.bin/yacc/yacc directory when removing yacc.
John Baldwin [Wed, 3 Mar 2021 22:46:45 +0000 (14:46 -0800)]
Remove the usr/tests/usr.bin/yacc/yacc directory when removing yacc.

Approved by: re (gjb)

(cherry picked from commit e6cfd2939a4261c1f4bf802368cea8faf824c128)
(cherry picked from commit 6a2ab3769abb0ea6357a9c1b9630c4efc884aebc)

3 years agoFix 'in6_purgeaddr: err=65, destination address delete failed' message.
Alexander V. Chernikov [Mon, 8 Mar 2021 20:27:29 +0000 (20:27 +0000)]
Fix 'in6_purgeaddr: err=65, destination address delete failed' message.

P2P ifa may require 2 routes: one is the loopback route, another is
 the "prefix" route towards its destination.

Current code marks loopback routes existence with IFA_RTSELF and
 "prefix" p2p routes with IFA_ROUTE.

For historic reasons, we fill in ifa_dstaddr for loopback interfaces.
To avoid installing the same route twice, we preemptively set
 IFA_RTSELF when adding "prefix" route for loopback.
However, the teardown part doesn't have this hack, so we try to
 remove the same route twice.

Fix this by checking if ifa_dstaddr is different from the ifa_addr
 and moving this logic into a separate function.

Reviewed By: kp
Approved by: re(gjb)
Differential Revision: https://reviews.freebsd.org/D29121

(cherry picked from commit 83cedad139721c6c150be8c078417cfcb311ee78)

3 years agoMount the EFI system partition (ESP) on newly-installed systems and VM
Nathan Whitehorn [Tue, 23 Feb 2021 21:16:52 +0000 (16:16 -0500)]
Mount the EFI system partition (ESP) on newly-installed systems and VM
images.

Per hier(7), the ESP will be mounted at /boot/efi. On UFS systems,
any existing ESP will be reused and mounted there; otherwise, a new one
will be made. On ZFS systems, space for an ESP is allocated on all disks
in the root pool, but only the partition actually used to boot is set up
and mounted.

This makes future upgrades of the EFI loader easier (upgrade scripts can
just change /boot/efi) and also greatly simplifies the parts of the
installer involved in initialization of the ESP. It also makes the
installer's behavior correspond to the documentation in hier(7).

Reviewed by: imp, tsoome, bdragon
Approved by: re (gjb)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D28897

(cherry picked from commit 0b7472b3d8d2f1e90fade5236b44fd98d8e396c2)
(cherry picked from commit 2c26d77d989abe48c662eeb6f52f7e4c9b81680c)
(cherry picked from commit e77cf2a4ab32a381df3c06d25b8b4f650047c3f2)
(cherry picked from commit e70eb40271512dfbca7cecf823e4b445e3989c2e)
(cherry picked from commit 611d83116a6ca9132dbe72b39538f4651daeeb7e)

3 years agojail(8): reset to root cpuset before attaching to run commands
Kyle Evans [Thu, 4 Mar 2021 19:28:53 +0000 (13:28 -0600)]
jail(8): reset to root cpuset before attaching to run commands

Recent changes have made it such that attaching to a jail will augment
the attaching process' cpu mask with the jail's cpuset. While this is
convenient for allowing the administrator to cpuset arbitrary programs
that will attach to a jail, this is decidedly not convenient for
executing long-running daemons during jail creation.

This change inserts a reset of the process cpuset to the root cpuset
between the fork and attach to execute a command. This allows commands
executed to have the widest mask possible, and the administrator can
cpuset(1) it back down inside the jail as needed.

With this applied, one should be able to change a jail's cpuset at
exec.poststart in addition to exec.created.  The former was made
difficult if jail(8) itself was running with a constrained set, as then
some processes may have been spawned inside the jail with a non-root
set.  The latter is the preferred option so that processes starting in
the jail are constrained appropriately up front.

Note that all system commands are still run with the process' initial
cpuset applied.

PR: 253724
Approved by: re (gjb)

(cherry picked from commit 466df976babed65f8a8de9e36d7f016a444609af)
(cherry picked from commit bdd61b6914f1f961b5f414b2d5cc623a5a829b89)

3 years agowg(4): Fix an example in the manual page
Gordon Bergling [Sun, 7 Mar 2021 19:27:59 +0000 (20:27 +0100)]
wg(4): Fix an example in the manual page

The example in the manual page of wg(4) for connecting to a
peer was missing the 'public-key' ifconfig(8) keyword and for the
addressed peer the port must be specified.

PR: 253866
Reported by: Sergey Akhmatov <sergey at akhmatov dot ru>
Approved by: re (gjb)
Reviewed by: debdrup
Differential Revision: https://reviews.freebsd.org/D29115

(cherry picked from commit f7bfe310191c8292da51c8da166a521ff16e0e46)

3 years agosecurity(7): mention new W^X sysctls in the manual page
Evgeniy Khramtsov [Tue, 2 Mar 2021 18:52:22 +0000 (19:52 +0100)]
security(7): mention new W^X sysctls in the manual page

Reviewed by: emaste, gbe
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D28986

(cherry picked from commit 907023b454f06a6af87f21f8a9d6de6c11b2d275)

3 years agowg: Avoid leaking mbufs when the input handshake queue is full
Mark Johnston [Mon, 8 Mar 2021 17:39:05 +0000 (12:39 -0500)]
wg: Avoid leaking mbufs when the input handshake queue is full

Approved by: re
Reviewed by: grehan
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29011

(cherry picked from commit a11009dccb6a2e75de2b8f1b45a0896eda2e6d85)
(cherry picked from commit 47495bf648a3394383eec64cbff4f3527e76f690)

3 years agobacklight(8): Add note that with option it print the current brightness.
Emmanuel Vadot [Wed, 3 Mar 2021 08:00:42 +0000 (09:00 +0100)]
backlight(8): Add note that with option it print the current brightness.

MFC after:    3 days
PR:        253737
Approved by:  re (gjb)

(cherry picked from commit 1df30489a8f7083c98010c94d9ce522f9e8213dc)
(cherry picked from commit f21c0366f532888bec164717a93964610ab6baf6)

3 years agobacklight: Fix incr/decr with percent value of 0
David Schlachter [Wed, 3 Mar 2021 07:57:35 +0000 (08:57 +0100)]
backlight: Fix incr/decr with percent value of 0

This now does nothing instead of incr/decr by 10%

MFC After:    3 days
PR:        253736
Approved by:  re (gjb)

(cherry picked from commit 3b005d51bd0fe4d8d19fb2df4d470b6e8baebf16)
(cherry picked from commit 9ba393f2ca0fd561c1fbf96f38eb014d7f883381)

3 years agoFix dst/netmask handling in routing socket code.
Alexander V. Chernikov [Tue, 16 Feb 2021 20:30:04 +0000 (20:30 +0000)]
Fix dst/netmask handling in routing socket code.

Traditionally routing socket code did almost zero checks on
 the input message except for the most basic size checks.

This resulted in the unclear KPI boundary for the routing system code
 (`rtrequest*` and now `rib_action()`) w.r.t message validness.

Multiple potential problems and nuances exists:
* Host bits in RTAX_DST sockaddr. Existing applications do send prefixes
 with hostbits uncleared. Even `route(8)` does this, as they hope the kernel
 would do the job of fixing it. Code inside `rib_action()` needs to handle
 it on its own (see `rt_maskedcopy()` ugly hack).
* There are multiple way of adding the host route: it can be DST without
 netmask or DST with /32(/128) netmask. Also, RTF_HOST has to be set correspondingly.
 Currently, these 2 options create 2 DIFFERENT routes in the kernel.
* no sockaddr length/content checking for the "secondary" fields exists: nothing
 stops rtsock application to send sockaddr_in with length of 25 (instead of 16).
 Kernel will accept it, install to RIB as is and propagate to all rtsock consumers,
 potentially triggering bugs in their code. Same goes for sin_port, sin_zero, etc.

The goal of this change is to make rtsock verify all sockaddr and prefix consistency.
Said differently, `rib_action()` or internals should NOT require to change any of the
 sockaddrs supplied by `rt_addrinfo` structure due to incorrectness.

To be more specific, this change implements the following:
* sockaddr cleanup/validation check is added immediately after getting sockaddrs from rtm.
* Per-family dst/netmask checks clears host bits in dst and zeros all dst/netmask "secondary" fields.
* The same netmask checking code converts /32(/128) netmasks to "host" route case
 (NULL netmask, RTF_HOST), removing the dualism.
* Instead of allowing ANY "known" sockaddr families (0<..<AF_MAX), allow only actually
 supported ones (inet, inet6, link).
* Automatically convert `sockaddr_sdl` (AF_LINK) gateways to
  `sockaddr_sdl_short`.

Reported by: Guy Yur <guyyur at gmail.com>
Reviewed By: donner
Approved by: re(gjb)
Differential Revision: https://reviews.freebsd.org/D28668

(cherry picked from commit e1bdecd9f60a80604a351e38cab7cfc56e308c66)

3 years agoFix dpdk/ldradix fib lookup algorithm preference calculation.
Alexander V. Chernikov [Sun, 7 Mar 2021 22:05:34 +0000 (22:05 +0000)]
Fix dpdk/ldradix fib lookup algorithm preference calculation.

The current preference number were copied from IPv4 code,
 assuming 500k routes to be the full-view. Adjust with the current
 reality (100k full-view).

Reported by: Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
Approved by: re(gjb)

(cherry picked from commit 8a25d3f6ce34b80fef5fd6a324da724c56ad94ed)

3 years agoMake in_localip_more() fib-aware.
Alexander V. Chernikov [Tue, 16 Feb 2021 20:00:46 +0000 (20:00 +0000)]
Make in_localip_more() fib-aware.

It fixes loopback route installation for the interfaces
 in the different fibs using the same prefix.

Reviewed By: donner
PR: 189088
Approved by: re(gjb)
Differential Revision: https://reviews.freebsd.org/D28673

(cherry picked from commit f67641675958cb566b0ae50dc6942017d42393fe)

3 years agoice(4): Update to version 0.28.1-k
Eric Joyner [Tue, 23 Feb 2021 01:45:09 +0000 (17:45 -0800)]
ice(4): Update to version 0.28.1-k

This updates the driver to align with the version included in
the "Intel Ethernet Adapter Complete Driver Pack", version 25.6.

There are no major functional changes; this mostly contains
bug fixes and changes to prepare for new features. This version
of the driver uses the previously committed ice_ddp package
1.3.19.0.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Tested by: jeffrey.e.pieper@intel.com
Approved by: re (gjb)
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D28640

(cherry picked from commit d08b8680e12ad692736c84238dcf45c70c228914)
(cherry picked from commit 1da549169de0b30f0ba92fdb4e74897c837d618d)

3 years agoice_ddp: Update package file to 1.3.19.0
Eric Joyner [Tue, 23 Feb 2021 01:43:54 +0000 (17:43 -0800)]
ice_ddp: Update package file to 1.3.19.0

This package is intended to be used with ice(4) version 0.28.1-k.
That update will happen in a forthcoming commit.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Approved by: re (gjb)
Sponsored by: Intel Corporation

(cherry picked from commit a7ac518bff64d48cf262c60c4dc57eef34e74a07)
(cherry picked from commit a02640c79e0a97b925f49302763da9aa201c4a20)

3 years agoixl(4): Add ability to control link state on ifconfig down
Krzysztof Galazka [Wed, 3 Mar 2021 01:38:51 +0000 (17:38 -0800)]
ixl(4): Add ability to control link state on ifconfig down

Add sysctl link_active_on_if_down, which allows user to control
if interface is kept in active state when it is brought
down with ifconfig. Set it to enabled by default to preserve
backwards compatibility.

Reviewed by: erj
Tested by: gowtham.kumar.ks@intel.com
Approved by: re (gjb)
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D28028

(cherry picked from commit 21802a127d83e8a8c721d69b697e7ddb223d7797)
(cherry picked from commit 2b94bda05a6d43e89c4a785c0f1cd569a41cb200)

3 years agoixl(4): Report RX errors as sum of all RX error counters
Krzysztof Galazka [Wed, 3 Mar 2021 01:33:11 +0000 (17:33 -0800)]
ixl(4): Report RX errors as sum of all RX error counters

HW keeps track of RX errors using several counters, each for
specific type of errors. Report RX errors to OS as sum
of all those counters: CRC errors, illegal bytes, checksum,
length, undersize, fragment, oversize and jabber errors.

There is no HW counter for frames with invalid L3/L4 checksums
so add a SW one.

Also add a "rx_errors" sysctl with a copy of netstat IERRORS
counter value to make it easier accessible from scripts.

Reviewed By: erj
Tested By: gowtham.kumar.ks@intel.com
Approved by: re (gjb)
Sponsored By: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D27639

(cherry picked from commit 9f99061ef9c95b171fc92d34026222bb5e052337)
(cherry picked from commit b149f7c23d13e73b92c2bf8c3691e3e1ebd833c1)

3 years agoix(4): Report RX errors as sum of all RX error counters
Piotr Pietruszewski [Wed, 3 Mar 2021 01:21:58 +0000 (17:21 -0800)]
ix(4): Report RX errors as sum of all RX error counters

HW keeps track of RX errors using several counters, each for
specific type of errors. Report RX errors to OS as sum
of all those counters: CRC errors, illegal bytes, checksum,
length, undersize, fragment, oversize and jabber errors.

Also, add new "rx_errs" sysctl in the dev.ix.N.mac_stats tree. This is
to provide an another way to display the sum of RX errors.

Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Reviewed By: erj
Tested By: gowtham.kumar.ks@intel.com
Approved by: re (gjb)
Sponsored By: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D27191

(cherry picked from commit afb1aa4e6df245d38fd2ba683fa521d5dabe8392)
(cherry picked from commit 8fa11f89225695c185a8a92c7530e270e77552f8)

3 years agoixl(4): Fix VLAN HW filtering
Krzysztof Galazka [Wed, 3 Feb 2021 23:22:55 +0000 (15:22 -0800)]
ixl(4): Fix VLAN HW filtering

X700 family of controllers has limited number of available VLAN
HW filters. Driver did not handle properly a case when user
assigned more VLANs to the interface which had all filters
already in use. Fix that by disabling HW filtering when
it is impossible to create filters for all requested VLANs.
Keep track of registered VLANs using bitstring to be able
to re-enable HW filtering when number of requested VLANs
drops below the limit.

Also switch all allocations to use M_IXL malloc type
to ease detecting memory leaks in the driver.

Reviewed by: erj
Tested by: gowtham.kumar.ks@intel.com
Approved by: re (gjb)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28137

(cherry picked from commit 7d4dceec103039e2b2fa90793ceeb71a8d6684aa)
(cherry picked from commit 7e166d608eecf0188bbb7edf6b3d9abffe1dfc6b)

3 years agoAdd a few missed files to libclang_rt.profile-<arch>.a
Dimitry Andric [Fri, 5 Mar 2021 20:06:05 +0000 (21:06 +0100)]
Add a few missed files to libclang_rt.profile-<arch>.a

Otherwise, programs compiled with -fprofile-instr-generate will
encounter undefined symbol errors during linking, for example
__llvm_profile_counter_bias, lprofSetRuntimeCounterRelocation and a few
others were missing from the profile library.

Approved by: re (gjb)
Reported by: ota@j.email.ne.jp
PR: 254001

(cherry picked from commit 772c631af81abdb6d498d972bab79d04d3db16d0)
(cherry picked from commit 3f684107ef6e41b03a47d64d6e31cebc823d7448)

3 years agoarmv8crypto: fix AES-XTS regression introduced by ed9b7f44
Oleksandr Tymoshenko [Sun, 7 Mar 2021 20:03:47 +0000 (12:03 -0800)]
armv8crypto: fix AES-XTS regression introduced by ed9b7f44

Initialization of the XTS key schedule was accidentally dropped
when adding AES-GCM support so all-zero schedule was used instead.
This rendered previously created GELI partitions unusable.
This change restores proper XTS key schedule initialization.

Reported by: Peter Jeremy <peter@rulingia.com>
MFC after: immediately
Approved by: re (gjb)

(cherry picked from commit 748be78e60ccc4a26325a636347debb1f7e6749b)

3 years agoloader: cursor off should restore display content
Toomas Soome [Sat, 6 Mar 2021 10:19:43 +0000 (12:19 +0200)]
loader: cursor off should restore display content

When drawing cursor, we should store original display
content because there may be image data we would like to restore
when the cursor is removed.

PR: 254054
Reported by: Jose Luis Duran
Approved by: re (gjb)

(cherry picked from commit d708f23ebb06cfc9cf8f96f17a43eb63653b818a)

3 years agoatomic(9): note that atomic_interrupt_fence first appeared in 13.0
Konstantin Belousov [Sat, 6 Mar 2021 05:21:40 +0000 (07:21 +0200)]
atomic(9): note that atomic_interrupt_fence first appeared in 13.0

Approved by: re (gjb)

(cherry picked from commit f5e930b369c6ea7a3f81d8e5b52cc395bb7b4187)
(cherry picked from commit 8fb8f26ab4b62891be27402e4335c27cb6839d9e)

3 years agoUse atomic_interrupt_fence() instead of bare __compiler_membar()
Konstantin Belousov [Fri, 26 Feb 2021 23:54:17 +0000 (01:54 +0200)]
Use atomic_interrupt_fence() instead of bare __compiler_membar()

Approved by: re (gjb)

(cherry picked from commit b5449c92b489445635c7962875ce73b2c9211bba)
(cherry picked from commit c10e0a4656bfe650bb3bf46fcf026a8a51a34a69)

3 years agokcsan: add atomic_interrupt_fence
Mateusz Guzik [Mon, 1 Mar 2021 07:42:15 +0000 (07:42 +0000)]
kcsan: add atomic_interrupt_fence

Approved by: re (gjb)

(cherry picked from commit 2c1c1255e41ac3fecd79f9f704c934642f34fd60)
(cherry picked from commit a552da13fc8f803ffc51755436441f3c14e3c817)

3 years agoatomic: add atomic_interrupt_fence()
Konstantin Belousov [Tue, 23 Feb 2021 22:12:29 +0000 (00:12 +0200)]
atomic: add atomic_interrupt_fence()

Approved by: re (gjb)

(cherry picked from commit e2494f7561c852951d8ac567314f5e12f19ee7af)

3 years agoDo not exit ctl_be_block_worker() prematurely.
Alexander Motin [Sat, 6 Mar 2021 03:39:52 +0000 (22:39 -0500)]
Do not exit ctl_be_block_worker() prematurely.

Return while there are any I/Os in a queue may result in them stuck
indefinitely, since there is only one taskqueue task for all of them.
I think I've reproduced this by switching ha_role to secondary under
heavy load.

Approved by: re (delphij)

(cherry picked from commit 6ed39db2573bb808ac2c206cd6c831f0be86219c)
(cherry picked from commit a3d416f3daafc59bc2f4ee278593c8a3f7a30d2b)

3 years agoMove back the isa non-PNP driver deadline to FreeBSD 14.
Warner Losh [Mon, 8 Mar 2021 22:59:48 +0000 (15:59 -0700)]
Move back the isa non-PNP driver deadline to FreeBSD 14.

Approved by: re@ (gjb)

(cherry picked from commit 6ffdaa5f2d4f0881557f64dabf61fb57541e0fba)
(cherry picked from commit 832d0719d6e5eb4ee2dec62f88ec79bfb617cd9d)

3 years agoriscv: fix errors in some atomic type aliases
Mitchell Horne [Thu, 4 Mar 2021 17:52:45 +0000 (13:52 -0400)]
riscv: fix errors in some atomic type aliases

This appears to be a copy-and-paste error that has simply been
overlooked. The tree contains only two calls to any of the affected
variants, but recent additions to the test suite started exercising the
call to atomic_clear_rel_int() in ng_leave_write(), reliably causing
panics.

Apparently, the issue was inherited from the arm64 atomic header. That
instance was addressed in c90baf6817a0, but the fix did not make its way
to RISC-V.

Note that the particular test case ng_macfilter_test:main still appears
to fail on this platform, but this change reduces the panic to a
timeout.

PR: 253237
Reported by: Jenkins, arichardson
Reviewed by: kp, arichardson
Approved by: re (gjb)

(cherry picked from commit 0d3b3beeb253e09b2b6b3805065594aecc7e2c2f)
(cherry picked from commit cc24f5bc6f6eb56a959bd23ebb051d3bf6ebf670)

3 years agobc: Vendor import new version 3.3.3
Stefan Eßer [Fri, 5 Mar 2021 10:30:11 +0000 (11:30 +0100)]
bc: Vendor import new version 3.3.3

(cherry picked from commit 028616d0dd69a3da7a30cb94d35f040bf2ced6b9)

Make length(0) and length(0.0) return 1 for compatibility with GNU bc
and the traditional FreeBSD bc.

Fix a potential division by zero error in a non-standard (extended)
math library function.

(cherry picked from commit f165641df4da1752f8bb1f55c1e602cdb657fba4)

Approved by:   re

3 years agoUpgrade to version 3.3.0
Stefan Eßer [Wed, 17 Feb 2021 21:56:16 +0000 (22:56 +0100)]
Upgrade to version 3.3.0

This update changes the behavior of "-e" or "-f" in BC_ENV_ARGS:

Use of these options on the command line makes bc exit after executing
the given commands. These options will not cause bc to exit when
passed via the environment (but EOF in STDIN or -e or -f on the
command line will make bc exit as before).

The same applies to DC_ENV_ARGS with regard to the dc program.

(cherry picked from commit 9a995fe186257315e7b3d01e24c55d86bb18fd32)

Approved by:   re

3 years agoif_vtbe: Add missing includes to fix build
Jessica Clarke [Mon, 8 Mar 2021 20:47:29 +0000 (20:47 +0000)]
if_vtbe: Add missing includes to fix build

PR: 254137
Reported by: Mina Galić <me@igalic.co>
Fixes: f8bc74e2f4a5 ("tap: add support for virtio-net offloads")
Approved by: re (gjb)

(cherry picked from commit f2f8405cf6b50a9d91acc02073abf1062d9d34f4)
(cherry picked from commit e3394851b5da6ec46e655a4f801cd6cac0840445)

3 years agotcp: remove incorrect reset of SACK variable in PRR
Richard Scheffenegger [Fri, 5 Mar 2021 16:45:23 +0000 (17:45 +0100)]
tcp: remove incorrect reset of SACK variable in PRR
tcp: Add prr_out in preparation for PRR/nonSACK and LRD

Reviewed by:   #transport, rrs, tuexen, kbowling
Approved by:   #re (gjb)
PR:            253848
MFC after:     3 days
Sponsored by:  NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29083
Differential Revision: https://reviews.freebsd.org/D29058

(cherry picked from commit 4a8f3aad37dd35c905e34b64b022d60844ba8d01)
(cherry picked from commit d90bba73a2e43fa12ea19425d101df4c488c1070)

(cherry picked from commit e53138694aa41c24c17847afe959225ce0eeff91)
(cherry picked from commit 71cc98ba735283b8720c9031eb87810f3d3d96a0)

3 years agorack: unbreak TCP fast open for the client side
Michael Tuexen [Fri, 5 Mar 2021 14:57:26 +0000 (15:57 +0100)]
rack: unbreak TCP fast open for the client side

Allow sending user data on the SYN segment.

Reviewed by: rrs
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D29082
Sponsored by: Netflix, Inc.

(cherry picked from commit 705d06b289e9821439b7b694d766cad75bc064e5)
(cherry picked from commit 873f8376015c12febec3619976a8c30fbead4ad6)

3 years agozfs: cancel TRIM or initialize on FAULTED non-writeable vdevs
Martin Matuska [Wed, 3 Mar 2021 01:38:09 +0000 (02:38 +0100)]
zfs: cancel TRIM or initialize on FAULTED non-writeable vdevs

From the openzfs commit message:
  When a device which is actively trimming or initializing becomes
  FAULTED, and therefore no longer writable, cancel the active
  TRIM or initialization.  When the device is merely taken offline
  with `zpool offline` then stop the operation but do not cancel it.
  When the device is brought back online the operation will be
  resumed if possible.

Obtained from: openzfs/zfs@bedbc13daa6dfe9e0221bfadb8d8db2378deaacc
Approved by: re (delphij)

(cherry picked from commit dc2743434f6cc73ca8ec1d551aba03a678eac804)

3 years agozfs: fix assert in FreeBSD-specific dmu_read_pages
Martin Matuska [Wed, 3 Mar 2021 01:32:59 +0000 (02:32 +0100)]
zfs: fix assert in FreeBSD-specific dmu_read_pages

From the openzfs 2e160dee9 commit message:
  The function has three similar pieces of code: for read-behind pages,
  requested pages and read-ahead pages.  All three pieces had an
  assert to ensure that the page is not mapped.  Later the assert was
  relaxed to require that the page is not mapped for writing.  But that
  was done in two places out of three.  This change fixes the third piece,
  read-ahead.

Obtained from: openzfs/zfs@2e160dee97a4badbc318561f76ea56451c916d2f
Approved by: re (delphij)

(cherry picked from commit 19049a2b2bd7119ef7b34102513f6bbfdf9ff862)

3 years agozfs: fix vdev_rebuild_thread deadlock
Martin Matuska [Wed, 3 Mar 2021 01:28:56 +0000 (02:28 +0100)]
zfs: fix vdev_rebuild_thread deadlock

From the openzfs 8e43fa12c commit message:
  The metaslab_disable() call may block waiting for a txg sync.
  Therefore it's important that vdev_rebuild_thread release the
  SCL_CONFIG read lock it is holding before this call.  Failure
  to do so can result in the txg_sync thread getting blocked
  waiting for this lock which results in a deadlock.

Obtained from: openzfs/zfs@8e43fa12c571878f32119122771888ab9092a75a
Approved by: re (delphij)

(cherry picked from commit c7069063144395b025c0ef178431eb2cafdbe1ca)

3 years agozfs: fix overly broad locking in spa_vdev_config_exit()
Martin Matuska [Wed, 3 Mar 2021 01:25:03 +0000 (02:25 +0100)]
zfs: fix overly broad locking in spa_vdev_config_exit()

Resolves a deadlock which can occur when the ZED or zpool
command attaches a new device.

From the openzfs 75a089ed3 commit message:
  Calling vdev_free() only requires the we acquire the spa config
  SCL_STATE_ALL locks, not the SCL_ALL locks.  In particular, we need
  need to avoid taking the SCL_CONFIG lock (included in SCL_ALL) as a
  writer since this can lead to a deadlock.  The txg_sync_thread() may
  block in spa_txg_history_init_io() when taking the SCL_CONFIG lock
  as a reading when it detects there's a pending writer.

Obtained from: openzfs/zfs@75a089ed34befb8d11df9be92a4438cc49554bf6
Approved by: re (delphij)

(cherry picked from commit f08e17c8a251210b58d63b52bfe1a77dccff6e78)

3 years agogrowfs: allow operation on RW-mounted filesystems
Ed Maste [Tue, 2 Mar 2021 22:35:48 +0000 (17:35 -0500)]
growfs: allow operation on RW-mounted filesystems

growfs supports growing mounted filesystems (writes are temporarily
suspended while the grow happens).  Drop the check for fs_clean == 0
to restore this case.  Leave fs_flags check for FS_UNCLEAN or
FS_NEEDSFSCK which represent the state of the filesystem when it was
mounted, and fsck should be run first if they are set.

PR: 253754
Reviewed by: mckusick
Approved by: re (gjb)
Fixes: 6eb925f8450f ("Filesystem utilities that modify the...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29021

(cherry picked from commit 0dcde5cc12744e5188300711a8829e5e6a9cd0de)
(cherry picked from commit b5920128c7ebcf5060605928263a54b31b317993)

3 years agoloader_4th: brand image is aligned right
Toomas Soome [Sat, 6 Mar 2021 08:54:08 +0000 (10:54 +0200)]
loader_4th: brand image is aligned right

With screen border removed, I forgot to update forth brand image
coordinates to avoid image alignment.

(cherry picked from commit 6a3095aa6d0350dda89bac66d26f22a01e2257c4)

Approved by:    re (delphij)

3 years agoImport wireguard fixes from pfSense 2.5
Peter Grehan [Sat, 27 Feb 2021 04:15:04 +0000 (14:15 +1000)]
Import wireguard fixes from pfSense 2.5

Merge the following fixes from https://github.com/pfsense/FreeBSD-src
 1940e7d3  Save address of ingress packets to allow wg to work on HA
 8f5531f1  Fix connection to IPv6 endpoint
 825ed9ee  Fix tcpdump for wg IPv6 rx tunnel traffic
 2ec232d3  Fix issue with replying to INITIATION messages in server mode
 ec77593a  Return immediately in wg_init if in DETACH'd state
 0f0dde6f  Remove unnecessary wg debug printf on transmit
 2766dc94  Detect and fix case in wg_init() where sockets weren't cleaned up
 b62cc7ac  Close the UDP tunnel sockets when the interface has been stopped

Approved by: re (kib)
Obtained from: pfSense 2.5
Relnotes: yes
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 96aabea8bd238b503e949753355dc5b6a857aa9c)

3 years agoarcmsr(4): Fixed no action of hot plugging device on type_F adapter.
Xin LI [Wed, 3 Mar 2021 06:57:20 +0000 (22:57 -0800)]
arcmsr(4): Fixed no action of hot plugging device on type_F adapter.

Many thanks to Areca for continuing to support FreeBSD.

Submitted by: 黃清隆 <ching2048 areca com tw>
Approved by: re (gjb)

(cherry picked from commit 5842073a9b7471831e0da48d29dd984d575f4e9e)
(cherry picked from commit e298c1c3c257446eba06945a0b4755ca30387012)

3 years agoloader: use display pixel density for font autoselection
Toomas Soome [Sat, 20 Feb 2021 08:51:28 +0000 (10:51 +0200)]
loader: use display pixel density for font autoselection

Calculate font size from 16 density independent pixels (dp) by using:
size = 16 * ppi/160 * display_factor

We are specifying font size 16dp, and assuming 1dp = 160ppi.
Also apply scaling factor 2 (display_factor).

(cherry picked from commit becaac3972f1fde4e3c44516399468ba5ca65c9b)

Approved by:    re (gjb)

3 years agoupdate to RC1
Glen Barber [Fri, 5 Mar 2021 00:51:39 +0000 (19:51 -0500)]
update to RC1

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agolinux: fix handling of flags for 32 bit send(2) syscall
Edward Tomasz Napierala [Fri, 5 Feb 2021 17:24:23 +0000 (17:24 +0000)]
linux: fix handling of flags for 32 bit send(2) syscall

Previously the flags were passed as-is, which could resulted
in spurious EAGAIN returned for non-blocking sockets, which
broke some Steam games.

Approved by: re (gjb)
PR: 248065
Reported By: Alex S <iwtcex@gmail.com>
Tested By: Alex S <iwtcex@gmail.com>
Reviewed By: emaste
MFC After: 3 days
Sponsored By: The FreeBSD Foundation

(cherry picked from commit f6e8256a965d5b7a7d43034ea31b2430a3b51066)
(cherry picked from commit 9d930fb09072d21464288df8c834cb8d0b760073)

3 years agoDon't check compat.linux.emul_path before loading linux(4)
Edward Tomasz Napierala [Mon, 8 Feb 2021 21:52:31 +0000 (21:52 +0000)]
Don't check compat.linux.emul_path before loading linux(4)

Fix e40787f900f to make libexec/rc/rc.d/linux retrieve the sysctl
after loading the kernel module which provides it, not before.

Approved by: re (gjb)
Reported By: jkim
Sponsored By: The FreeBSD Foundation

(cherry picked from commit 07cac176fba947381c8111b8e02e8067e7fa542a)
(cherry picked from commit 5dc2e1bcf41f853b31b6d08a5c2d643408e890f3)

3 years agoUse compat.linux.emul_path instead of hardcoded path in /etc/rc.d/linux
Edward Tomasz Napierala [Tue, 2 Feb 2021 14:40:38 +0000 (14:40 +0000)]
Use compat.linux.emul_path instead of hardcoded path in /etc/rc.d/linux

In /etc/rc.d/linux the mounting paths of procfs, sysfs and devfs
are hardcoded to "/compat/linux".  Switching to the content of
compat.linux.emul_path sysctl would allow to switch linuxulator
to different place.

Approved by: re (gjb)
Submitted by: freebsdnewbie_freenet.de
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27807

(cherry picked from commit e40787f900f3c262d5134d342e5a16757dd2193c)
(cherry picked from commit 1b2802ed4ed09746d6870080f85d79a9ccd782b0)

3 years agolibc: fix buffer overrun in getrpcport(3)
Edward Tomasz Napierala [Sun, 31 Jan 2021 21:41:55 +0000 (21:41 +0000)]
libc: fix buffer overrun in getrpcport(3)

Approved by: re (gjb)
Reviewed By: markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27332

(cherry picked from commit 5299d64b2b9f7a25e423ef1785d9402a0ef198d3)
(cherry picked from commit a3576b6207074ba5182be253c26af72f8fb51759)

3 years agoO_RELATIVE_BENEATH: return ENOTCAPABLE instead of EINVAL for abs path
Konstantin Belousov [Sun, 28 Feb 2021 23:59:12 +0000 (01:59 +0200)]
O_RELATIVE_BENEATH: return ENOTCAPABLE instead of EINVAL for abs path

Approved by: re (gjb)

(cherry picked from commit 28cd3a673e0e32b009fd573764956b280d1affe1)

3 years agonameicap_check_dotdot: trim tracker on check
Konstantin Belousov [Sun, 28 Feb 2021 00:15:21 +0000 (02:15 +0200)]
nameicap_check_dotdot: trim tracker on check

Approved by:  re (gjb)

(cherry picked from commit 49c98a4bf3a87ace0df99056fa683805c1645e61)

3 years agoAdd nameicap_cleanup_from(), to clean tracker list starting from some element
Konstantin Belousov [Sun, 28 Feb 2021 00:14:43 +0000 (02:14 +0200)]
Add nameicap_cleanup_from(), to clean tracker list starting from some element

Approved by: re (gjb)

(cherry picked from commit e8a2862aa0384c75603f801625e309a3dae0ed05)

3 years agonameicap_tracker_add: avoid duplicates in the tracker list
Konstantin Belousov [Sun, 28 Feb 2021 00:13:19 +0000 (02:13 +0200)]
nameicap_tracker_add: avoid duplicates in the tracker list

Approved by: re (gjb)

(cherry picked from commit 2388ad7c293fbc89ee239a1adcb87fd158c4e8e9)

3 years agoDo not call nameicap_tracker_add() for dotdot case.
Konstantin Belousov [Sun, 28 Feb 2021 00:12:43 +0000 (02:12 +0200)]
Do not call nameicap_tracker_add() for dotdot case.

Approved by: re (gjb)

(cherry picked from commit 59e749428111c029116a4302a544c7cc18b33772)

3 years agoopen(2): Remove O_BENEATH and AT_BENEATH
Konstantin Belousov [Tue, 16 Feb 2021 03:31:40 +0000 (05:31 +0200)]
open(2): Remove O_BENEATH and AT_BENEATH

Approved by: re (gjb)

(cherry picked from commit 20e91ca36a56b8db1e6677f577ad011b66dd6eb3)

3 years agofhlink(2): the syscalls do not take flag
Konstantin Belousov [Sun, 28 Feb 2021 00:38:11 +0000 (02:38 +0200)]
fhlink(2): the syscalls do not take flag

Approved by: re (gjb)

(cherry picked from commit 600756afb532a86a39fb488f5c4fc7e248921655)

3 years agoFFS extattr: fix handling of the tail
Konstantin Belousov [Mon, 1 Mar 2021 15:24:11 +0000 (17:24 +0200)]
FFS extattr: fix handling of the tail

Approved by: re (gjb)

(cherry picked from commit 8742817ba62ec604156c139727155d36f5fbad06)

3 years agosendfile: Use the pager size to determine the file extent when possible
Mark Johnston [Thu, 25 Feb 2021 15:04:44 +0000 (10:04 -0500)]
sendfile: Use the pager size to determine the file extent when possible

Previously sendfile would issue a VOP_GETATTR and use the returned size,
i.e., the file size.  When paging in file data, sendfile_swapin() will
use the pager to determine whether it needs to zero-fill, most often
because of a hole in a sparse file.  An attempt to page in beyond the
end of a file is treated this way, and occurs when the requested page is
past the end of the pager.  In other words, both the file size and pager
size were used interchangeably.

With ZFS, updates to the pager and file sizes are not synchronized by
the exclusive vnode lock, at least partially due to its use of
MNTK_SHARED_WRITES.  In particular, the pager size is updated after the
file size, so in the presence of a writer concurrently extending the
file, sendfile could incorrectly instantiate "holes" in the page cache
pages backing the file, which manifests as data corruption when reading
the file back from the page cache.  The on-disk copy is unaffected.

Fix this by consistently using the pager size when available.

Approved by: re (gjb)
Reported by: dumbbell
Reviewed by: chs, kib
Tested by: dumbbell, pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28811

(cherry picked from commit faa998f6ff69573fe82765c77c7268ee89ac945e)
(cherry picked from commit 095558ac894977906fbbdf74c34b6d13fea7c8ed)

3 years agotcp: various improvements and fixes to PRR
Richard Scheffenegger [Fri, 19 Feb 2021 12:52:06 +0000 (13:52 +0100)]
tcp: various improvements and fixes to PRR
- Ensure cwnd doesn't shrink to zero with PRR
- use accurate rfc6675_pipe when enabled
- Address two incorrect calculations and enhance readability
- address second instance of cwnd potentially becoming zero
- fix sublte bug due to implicit int to uint typecase in max()
- fix bug due to typo in hand-coded CEILING() function by using howmany() macro
- use int instead of long, and add a missing long typecast
- replace if conditionals with easier to read imax/imin (as in pseudocode)
- Avoid accounting left-edge twice in partial ACK.
- Include new data sent in PRR calculation
- Improve PRR initial transmission timing
- Fix prr_out when pipe < ssthresh

Reviewed By:    #transport, kbowling, tuexen
Reported by:    Liang Tian
Approved by:    re (gjb)
MFC after:      3 days
Sponsored by:   NetApp, Inc.
Differential Revision:  https://reviews.freebsd.org/D28780
Differential Revision:  https://reviews.freebsd.org/D28816
Differential Revision:  https://reviews.freebsd.org/D28813
Differential Revision:  https://reviews.freebsd.org/D28819
Differential Revision:  https://reviews.freebsd.org/D28941
Differential Revision:  https://reviews.freebsd.org/D28953
Differential Revision:  https://reviews.freebsd.org/D28998

(cherry picked from commit 853fd7a2e39802e46bd3d6476529796ac22412d9)
(cherry picked from commit c3aa4ba5dfc084e40e4151b25a0d5f8d24a036ba)

(cherry picked from commit a8e431e1537d056a3f9e466eaceec28c399c220b)
(cherry picked from commit 32ed0ef06b8326271c4665406cac81fa47d0d29c)

(cherry picked from commit 48396dc77922c68377ecac0ead2f8b0b5453c451)
(cherry picked from commit ffbf1b809ef5080afa130c11fa4afce9fef7e7fe)

(cherry picked from commit 31d7a27c6e88c3d5bd0907774ec70176a92da5bb)
(cherry picked from commit 25fb4c363b299c26c35158fa059379af4a007253)

(cherry picked from commit 9e83a6a556ed8d9a2821de5d5f5c7d4b1292c694)
(cherry picked from commit 9596751563dc1819d177fa3ec6660a3bdc18021c)

(cherry picked from commit e9071000c9a04e3f685579500e24da9848944bb1)
(cherry picked from commit 2b43cd2ea26f758d23e8c009cf7521c4ddec7353)

(cherry picked from commit 0b0f8b359d0b94b09cfec35e5d5de01b23c7fbf1)
(cherry picked from commit 05e742af6f548364909ed671f0b3774e54dc77d1)

3 years agoRACK: fix an issue triggered by using the CDG CC module
Michael Tuexen [Tue, 2 Mar 2021 11:32:16 +0000 (12:32 +0100)]
RACK: fix an issue triggered by using the CDG CC module

Obtained from: rrs@
Approved by: re (gjb)
PR: 238741
Sponsored by: Netlix, Inc.

(cherry picked from commit 99adf230061268175a36061130e6adb0882270e8)
(cherry picked from commit ae608d4ee7202cc34603e620bc551547e772c4d2)