]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agosched_ule(4): Use trylock when stealing load.
Alexander Motin [Mon, 2 Aug 2021 02:42:01 +0000 (22:42 -0400)]
sched_ule(4): Use trylock when stealing load.

On some load patterns it is possible for several CPUs to try steal
thread from the same CPU despite randomization introduced.  It may
cause significant lock contention when holding one queue lock idle
thread tries to acquire another one.  Use of trylock on the remote
queue allows both reduce the contention and handle lock ordering
easier.  If we can't get lock inside tdq_trysteal() we just return,
allowing tdq_idled() handle it.  If it happens in tdq_idled(), then
we repeat search for load skipping this CPU.

On 2-socket 80-thread Xeon system I am observing dramatic reduction
of the lock spinning time when doing random uncached 4KB reads from
12 ZVOLs, while IOPS increase from 327K to 403K.

MFC after: 1 month

(cherry picked from commit 8bb173fb5bc33a02d5a4670c9a60bba0ece07bac)

2 years agosched_ule(4): Reduce duplicate search for load.
Alexander Motin [Mon, 2 Aug 2021 02:07:51 +0000 (22:07 -0400)]
sched_ule(4): Reduce duplicate search for load.

When sched_highest() called for some CPU group returns nothing, idle
thread calls it for the parent CPU group.  But the parent CPU group
also includes the CPU group we've just searched, and unless there is
a race going on, it is unlikely we find anything new this time.

Avoid the double search in case of parent group having only two sub-
groups (the most prominent case). Instead of escalating to the parent
group run the next search over the sibling subgroup and escalate two
levels up after if that fail too.  In case of more than two siblings
the difference is less significant, while searching the parent group
can result in better decision if we find several candidate CPUs.

On 2-socket 40-core Xeon system I am measuring ~25% reduction of CPU
time spent inside cpu_search_highest() in both SMT (2x20x2) and non-
SMT (2x20) cases.

MFC after: 1 month

(cherry picked from commit 2668bb2add8d11c56524ce9014b510412f8f6aa9)

2 years agoRefactor/optimize cpu_search_*().
Alexander Motin [Thu, 29 Jul 2021 01:18:50 +0000 (21:18 -0400)]
Refactor/optimize cpu_search_*().

Remove cpu_search_both(), unused for many years.  Without it there is
less sense for the trick of compiling common cpu_search() into separate
cpu_search_lowest() and cpu_search_highest(), so split them completely,
making code more readable.  While there, split iteration over children
groups and CPUs, complicating code for very small deduplication.

Stop passing cpuset_t arguments by value and avoid some manipulations.
Since MAXCPU bump from 64 to 256, what was a single register turned
into 32-byte memory array, requiring memory allocation and accesses.
Splitting struct cpu_search into parameter and result parts allows to
even more reduce stack usage, since the first can be passed through
on recursion.

Remove CPU_FFS() from the hot paths, precalculating first and last CPU
for each CPU group in advance during initialization.  Again, it was
not a problem for 64 CPUs before, but for 256 FFS needs much more code.

With these changes on 80-thread system doing ~260K uncached ZFS reads
per second I observe ~30% reduction of time spent in cpu_search_*().

MFC after: 1 month

(cherry picked from commit aefe0a8c32d370f2fdd0d0771eb59f8845beda17)

2 years agoAMD-vi: Fortify IVHD device_identify process
Ka Ho Ng [Mon, 19 Apr 2021 08:07:03 +0000 (16:07 +0800)]
AMD-vi: Fortify IVHD device_identify process

- Use malloc(9) to allocate ivhd_hdrs list. The previous assumption
  that there are at most 10 IVHDs in a system is not true. A counter
  example would be a system with 4 IOMMUs, and each IOMMU is related
  to IVHDs type 10h, 11h and 40h in the ACPI IVRS table.
- Always scan through the whole ivhd_hdrs list to find IVHDs that has
  the same DeviceId but less prioritized IVHD type.

Sponsored by: The FreeBSD Foundation
MFC with: 74ada297e897
Reviewed by: grehan
Approved by: lwhsu (mentor)
Differential Revision: https://reviews.freebsd.org/D29525

(cherry picked from commit 6fe60f1d5c39c94fc87534e9dd4e9630594e0bec)

2 years agovmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1
Ka Ho Ng [Mon, 2 Aug 2021 09:54:40 +0000 (17:54 +0800)]
vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1

In hw.vmm.create sysctl handler the maximum length of vm name is
VM_MAX_NAMELEN. However in vm_create() the maximum length allowed is
only VM_MAX_NAMELEN - 1 chars. Bump the length of the internal buffer to
allow the length of VM_MAX_NAMELEN for vm name.

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

(cherry picked from commit df95cc76affbbf114c9ff2e4ee011b6f162aa8bd)

2 years agotmpfs: Fix error being cleared after commit c12118f6cec0
Ka Ho Ng [Tue, 24 Aug 2021 16:35:29 +0000 (00:35 +0800)]
tmpfs: Fix error being cleared after commit c12118f6cec0

In tmpfs_link() error was erroneously cleared in commit c12118f6cec0.

Sponsored by: The FreeBSD Foundation
MFC with: c12118f6cec0

(cherry picked from commit a48416f844e3007b4e9f6df125e25cf3a1daad62)

2 years agotmpfs: Fix styles
Ka Ho Ng [Tue, 24 Aug 2021 13:09:21 +0000 (21:09 +0800)]
tmpfs: Fix styles

A lot of return statements were in the wrong style before this commit.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c12118f6cec0ca5f720be6c06d6c59d551461e5a)

2 years agosound: Add an example of basic sound application
Goran Mekić [Wed, 4 Aug 2021 10:04:54 +0000 (18:04 +0800)]
sound: Add an example of basic sound application

This is an example demonstrating the usage of the OSS-compatible APIs
provided by the sound(4) subsystem. It reads frames from a dsp node and
writes them to the same dsp node.

Reviewed by: hselasky, bcr
Differential revision: https://reviews.freebsd.org/D30149

(cherry picked from commit 21d854658801f6ddb91de3a3c3384e90f5d920f2)

2 years agovfs: Add get_write_ioflag helper to calculate ioflag
Ka Ho Ng [Thu, 12 Aug 2021 09:35:34 +0000 (17:35 +0800)]
vfs: Add get_write_ioflag helper to calculate ioflag

Converted vn_write to use this helper.

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

(cherry picked from commit c15384f8963191a238cb4a33382b4d394f1ac0b4)

2 years agointel ethernet: Use ether_gen_addr(9)
Kevin Bowling [Fri, 20 Aug 2021 14:45:30 +0000 (07:45 -0700)]
intel ethernet: Use ether_gen_addr(9)

Use ether_gen_addr(9) for VF MAC generation

Reviewed by: Intel Networking (erj), kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31616

(cherry picked from commit 0e5811a2a9a1b4a7e0c79b73e3b9b9d15d481577)

2 years agonfsd: Fix sanity check for NFSv4.2 Allocate operations
Rick Macklem [Thu, 12 Aug 2021 23:48:28 +0000 (16:48 -0700)]
nfsd: Fix sanity check for NFSv4.2 Allocate operations

The NFSv4.2 Allocate operation sanity checks the aa_offset
and aa_length arguments.  Since they are assigned to variables
of type off_t (signed) it was possible for them to be negative.
It was also possible for aa_offset+aa_length to exceed OFF_MAX
when stored in lo_end, which is uint64_t.

This patch adds checks for these cases to the sanity check.

(cherry picked from commit 06afb53bcd7b6a928bc90acb820383302ea8be9e)

2 years agoApply clang fix for assertion failure compiling multimedia/minitube
Dimitry Andric [Sat, 21 Aug 2021 21:03:37 +0000 (23:03 +0200)]
Apply clang fix for assertion failure compiling multimedia/minitube

Merge commit 79f9cfbc21e0 from llvm git (by Yaxun (Sam) Liu):

  Do not merge LocalInstantiationScope for template specialization

  A lambda in a function template may be recursively instantiated. The recursive
  lambda will cause a lambda function instantiated multiple times, one inside another.
  The inner LocalInstantiationScope should not be marked as MergeWithParentScope
  since it already has references to locals properly substituted, otherwise it causes
  assertion due to the check for duplicate locals in merged LocalInstantiationScope.

  Reviewed by: Richard Smith

  Differential Revision: https://reviews.llvm.org/D98068

Reported by: yuri
PR: 257978

(cherry picked from commit efa485d5c390b745f53761da9159721243c48b7b)

2 years agocrunch: drop WARNS override
Kyle Evans [Thu, 19 Aug 2021 06:33:13 +0000 (01:33 -0500)]
crunch: drop WARNS override

crunchide and crunchgen now build fine with default WARNS

(cherry picked from commit d59c5e023d558161e4f519b88d5209d8bab18bc7)

2 years agocrunchgen: fix remaining issues under WARNS=6
Kyle Evans [Thu, 19 Aug 2021 06:22:16 +0000 (01:22 -0500)]
crunchgen: fix remaining issues under WARNS=6

Entirely variables that should be static, save for one 'no previous
declaration' in mkskel.sh.

(cherry picked from commit bfd70233c3e2bc5c29db6f96fb90b58439908d29)

2 years agocrunchide: static'ify remaining non-exported functions
Kyle Evans [Thu, 19 Aug 2021 06:29:02 +0000 (01:29 -0500)]
crunchide: static'ify remaining non-exported functions

(cherry picked from commit 7ff87026d65c77f90391ead3f2fc752223d16e01)

2 years agocrunchide: address complaints from WARNS=6
Kyle Evans [Thu, 19 Aug 2021 06:17:36 +0000 (01:17 -0500)]
crunchide: address complaints from WARNS=6

- One (1) constify
- One (1) argument is unused
- One (1) local shadows a global
- Various globals that should be static

(cherry picked from commit dd7c7ff192d07912fb7f5874868649c3aa05944a)

2 years agocrunchgen: sprinkle some const-poisoning around
Kyle Evans [Thu, 19 Aug 2021 06:13:13 +0000 (01:13 -0500)]
crunchgen: sprinkle some const-poisoning around

(cherry picked from commit db7f7446b5bcb26c7aaf13c8151b4ae8051c5732)

2 years agopkg: use specific CONFSNAME_${file} for FreeBSD.conf
Kyle Evans [Thu, 18 Feb 2021 04:10:46 +0000 (22:10 -0600)]
pkg: use specific CONFSNAME_${file} for FreeBSD.conf

Setting CONFSNAME directly is a little more complicated for downstream
consumers, as any additional CONFS that are added here will inherit the
group name by default.  This is perhaps arguably a design flaw in CONFS
because inheriting NAME will never give a good result when additional
files are added, but this is a low-effort change.

While we're here, pull FreeBSD.conf.${branch} out into a PKGCONF
variable so one can just drop a new repo config in entirely with a new
naming scheme. CONFSNAME gets set based on chopping anything off after
".conf", so that, e.g.:

- FooBSD.conf => FooBSD.conf
- FooBSD.conf.internal => FooBSD.conf

(cherry picked from commit d35164539b14a6d14fb587e58a0c7a1668d7643a)

2 years agopkg: allow multiple add arguments again
Kyle Evans [Thu, 18 Feb 2021 03:41:53 +0000 (21:41 -0600)]
pkg: allow multiple add arguments again

While pkg(7) add only handles a single 'add' argument, pkg-add(8) fully
handles multiple arguments.

Stop rejecting it, just turn off local-bootstrap mode and proceed to
remote bootstrap if we need it.

While we're here, check if the first argument to pkg add is even a pkg
package. If it's not, also do remote bootstrap instead. Future work
could improve this altogether by picking out a pkg package out of many
and local bootstrap then pass the rest through to the newly installed
pkg.

(cherry picked from commit 40b9f924b189ce8fa871db600b4abc99b03c6a65)

2 years agomalloc(9): Document/complete aligned variants
Adam Fenn [Mon, 2 Aug 2021 20:33:31 +0000 (15:33 -0500)]
malloc(9): Document/complete aligned variants

Comments on a pending kvmclock driver suggested adding a
malloc_aligned() to complement malloc_domainset_aligned(); add it now,
and document both.

(cherry picked from commit 6162cf885c00a0893a0961415f1829942343dcc1)
(cherry picked from commit 04cc0c393c317b6d5e28c8dc80cd1b5ea071f28f)

2 years agodevclass_alloc_unit: move "at" hint test to after device-in-use test
Adam Fenn [Mon, 2 Aug 2021 16:27:17 +0000 (11:27 -0500)]
devclass_alloc_unit: move "at" hint test to after device-in-use test

Only perform this expensive operation when the unit number is a
potential candidate (i.e. not already in use), thereby reducing device
scan time on systems with many devices, unit numbers, and drivers.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #61

(cherry picked from commit 8ca384eb1d429aae866f53abfadafc71ab009dc6)

2 years agortsold: make it work on if_vlan interfaces
Luiz Otavio O Souza [Thu, 19 Aug 2021 09:48:04 +0000 (11:48 +0200)]
rtsold: make it work on if_vlan interfaces

Reviewed by: kp
Obtained from: pfsense
MFC after: 1 week

(cherry picked from commit 1a4d7030bbfec0f830e87bf7c2810f049f8ca8ac)

2 years agolagg: don't update link layer addresses on destroy
Luiz Otavio O Souza [Tue, 17 Aug 2021 14:23:50 +0000 (16:23 +0200)]
lagg: don't update link layer addresses on destroy

When the lagg is being destroyed it is not necessary update the
lladdr of all the lagg members every time we update the primary
interface.

Reviewed by: scottl
Obtained from: pfSense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31586

(cherry picked from commit c138424148f900dc449c757869453120ae3277f3)

2 years agoipfw: use unsigned int for dummynet bandwidth
Luiz Otavio O Souza [Tue, 17 Aug 2021 07:54:40 +0000 (09:54 +0200)]
ipfw: use unsigned int for dummynet bandwidth

This allows the maximum value of 4294967295 (~4Gb/s) instead of previous
value of 2147483647 (~2Gb/s).

Reviewed by: np, scottl
Obtained from: pfSense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31582

(cherry picked from commit 20ffd88ed54fe3fd098ac30bd221275b2a14f52c)

2 years agodhclient: remove patching of static values in BPF programs
Franco Fichtner [Thu, 19 Aug 2021 13:08:59 +0000 (09:08 -0400)]
dhclient: remove patching of static values in BPF programs

Reviewed by: markj

(cherry picked from commit 5851803f4bcab48bddfe1600bda3906c4f83fad5)

2 years agodhclient: skip_to_semi() consumes semicolon already
Franco Fichtner [Thu, 19 Aug 2021 13:11:38 +0000 (09:11 -0400)]
dhclient: skip_to_semi() consumes semicolon already

When invalid statement is found the next statement is skipped even if it
is valid.

Reviewed by: markj

(cherry picked from commit a313b5240a477e0d04294ffd170408d954181daa)

2 years agolibsa: cstyle cleanup of dosfs.c
Toomas Soome [Thu, 19 Aug 2021 14:33:24 +0000 (17:33 +0300)]
libsa: cstyle cleanup of dosfs.c

No functional changes intended.

(cherry picked from commit 3ec0714d6db0060113f6cadac6f4e44640603e8f)

2 years agoloader: open file list should be dynamic
Toomas Soome [Sat, 31 Jul 2021 08:09:48 +0000 (11:09 +0300)]
loader: open file list should be dynamic

Summary:
Open file list is currently created as statically allocated array
(64 items). Once this array is filled up, loader will not be able
to operate with files. In most cases, this mechanism is good enough,
but the problem appears, when we have many disks with zfs pool(s).
In current loader implementation, all discovered zfs pool
configurations are kept in memory and disk devices open - consuming
the open file array. Rewrite the open file mechanism to use
dynamically allocated list.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D31364

(cherry picked from commit 97cbd5e722389a575e820c4e03f38053308f08ea)

2 years agokern: remove deprecated makesyscalls.sh
Kyle Evans [Thu, 29 Jul 2021 03:18:13 +0000 (22:18 -0500)]
kern: remove deprecated makesyscalls.sh

makesyscalls was rewritten in Lua and introduced in d3276301ab.  In the
time since, no objections have risen and a warning was introduced long
ago on invocation of makesyscalls.sh that it would be removed before
FreeBSD 13. Belatedly follow through on that.

(cherry picked from commit e3707726c168eeb0ba06d13873dd71590b77d604)

2 years agoinit: execute /etc/rc.final after all user processes have terminated
Kyle Evans [Tue, 20 Jul 2021 10:40:30 +0000 (05:40 -0500)]
init: execute /etc/rc.final after all user processes have terminated

This can be useful for, e.g., unmounting filesystems that were needed
for shutdown.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #63

(cherry picked from commit 4d1597691916240b9023ee9f15e249503abf67fd)

2 years agokenv: allow listing of static kernel environments
Kyle Evans [Sun, 20 Jun 2021 19:36:10 +0000 (14:36 -0500)]
kenv: allow listing of static kernel environments

The early environment is typically cleared, so these new options
need the PRESERVE_EARLY_KENV kernel config(8) option. These environments
are reported as missing by kenv(1) if the option is not present in the
running kernel.

(cherry picked from commit db0f26439357b78863e61985acd1e5acf75ce73d)

2 years agokern: add an option for preserving the early kenv
Kyle Evans [Sun, 20 Jun 2021 19:29:31 +0000 (14:29 -0500)]
kern: add an option for preserving the early kenv

Some downstream configurations do not store secrets in the
early (loader/static) environments and desire a way to preserve these
for diagnostic reasons.  Provide an option to do so.

(cherry picked from commit 7a129c973b5ba0fa916dfa658d523bec66dbd02d)

2 years agokenv: s/dump/list/ to clarify meaning
Kyle Evans [Mon, 21 Jun 2021 03:11:26 +0000 (22:11 -0500)]
kenv: s/dump/list/ to clarify meaning

The contents of the kenv will be dumped to stdout, while dump could have
also meant 'discard'. Call it 'list' instead.

(cherry picked from commit 46438b5366f9405beb6f76474a5aae822352f012)

2 years agoe1000: Update intel shared code
Kevin Bowling [Thu, 19 Aug 2021 14:59:34 +0000 (07:59 -0700)]
e1000: Update intel shared code

Sync the e1000 shared code with DPDK shared code
"cid-gigabit.2020.06.05.tar.gz released by ND"

Primary focus was on client platforms (ich8lan). More work remains here
but we need an Intel contact for client networking.

Reviewed by: grehan, Intel Networking (erj, earlier rev)
Obtained from: DPDK <http://git.dpdk.org/dpdk/tree/drivers/net/e1000/base>
MFC after: 1 week
Sponsored by: me
Differential Revision: https://reviews.freebsd.org/D31547

(cherry picked from commit fc7682b17f3738573099b8b03f5628dcc8148adb)

2 years agoiflib: Improve mapping of TX/RX queues to CPUs
Patrick Kelsey [Mon, 26 Apr 2021 04:25:59 +0000 (00:25 -0400)]
iflib: Improve mapping of TX/RX queues to CPUs

iflib now supports mapping each (TX,RX) queue pair to the same CPU
(default), to separate CPUs, or to a pair of physical and logical CPUs
that share the same L2 cache.  The mapping mechanism supports unequal
numbers of TX and RX queues, with the excess queues always being
mapped to consecutive physical CPUs.  When the platform cannot
distinguish between physical and logical CPUs, all are treated as
physical CPUs.  See the comment on get_cpuid_for_queue() for the
entire matrix.

The following device-specific tunables influence the mapping process:
dev.<device>.<unit>.iflib.core_offset       (existing)
dev.<device>.<unit>.iflib.separate_txrx     (existing)
dev.<device>.<unit>.iflib.use_logical_cores (new)

The following new, read-only sysctls provide visibility of the mapping
results:
dev.<device>.<unit>.iflib.{t,r}xq<n>.cpu

When an iflib driver allocates TX softirqs without providing reference
RX IRQs, iflib now binds those TX softirqs to CPUs using the above
mapping mechanism (that is, treats them as if they were TX IRQs).
Previously, such bindings were left up to the grouptaskqueue code and
thus fell outside of the iflib CPU mapping strategy.

Reviewed by: kbowling
Tested by: olivier, pkelsey
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D24094

(cherry picked from commit ca7005f1893d199b7c28d5b159e1bdbb55e74543)

2 years agodhclient: support supersede statement for option 54
Fabian Kurtz [Wed, 18 Aug 2021 17:12:48 +0000 (10:12 -0700)]
dhclient: support supersede statement for option 54

PR: 217978
Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: markj
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31503

(cherry picked from commit 0a539a0f005e8acbe4974ede30aa928099c988b9)

2 years agogre: simplify RSS ifdefs
Franco Fichtner [Wed, 18 Aug 2021 17:05:29 +0000 (10:05 -0700)]
gre: simplify RSS ifdefs

Use the early break to avoid else definitions. When RSS gains a
runtime option previous constructs would duplicate and convolute
the existing code.

While here init flowid and skip magic numbers and late default
assignment.

Reviewed by: melifaro, kbowling
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31584

(cherry picked from commit bb250fae9e9e278b681cf3a71ced718700ecf74c)

2 years agoiflib: emulate counters in netmap mode
Stephan de Wit [Wed, 18 Aug 2021 07:17:43 +0000 (00:17 -0700)]
iflib: emulate counters in netmap mode

When iflib devices are in netmap mode the driver
counters are no longer updated making it look from
userspace tools that traffic has stopped.

Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: vmaffione, iflib (erj, gallatin)
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31550

(cherry picked from commit 66fa12d8fb61485780f32f0226e79d3389567496)

2 years agorpc(3): Correct a few common typos in source code comments
Gordon Bergling [Sun, 22 Aug 2021 06:16:09 +0000 (08:16 +0200)]
rpc(3): Correct a few common typos in source code comments

- s/therfore/therefor/
- s/activte/active/

Obtained from: NetBSD

(cherry picked from commit 0d55bc8eb2ab9508c43e135616ca887ed719ea9a)

2 years agoMark some sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 02:17:53 +0000 (22:17 -0400)]
Mark some sysctls as CTLFLAG_MPSAFE.

MFC after: 2 weeks

(cherry picked from commit 67f508db84b8b789db37c60972f255574417b8ed)

2 years agoMark some sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:44:27 +0000 (20:44 -0400)]
Mark some sysctls as CTLFLAG_MPSAFE.

MFC after: 2 weeks

(cherry picked from commit b776de6796fa0cd1b7dfaad75402e10907d47f29)

2 years agogeom(4): Mark all sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:18:46 +0000 (20:18 -0400)]
geom(4): Mark all sysctls as CTLFLAG_MPSAFE.

This code does not use Giant lock for very long time.

MFC after: 2 weeks

(cherry picked from commit c2da954203c0feb933d3be304710e0346c9ed222)

2 years agocam(4): Mark all sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:05:40 +0000 (20:05 -0400)]
cam(4): Mark all sysctls as CTLFLAG_MPSAFE.

This code does not use Giant lock for very long time.

MFC after: 2 weeks

(cherry picked from commit 303477d3253007bb5732deed2daea86b2cbd9aa8)

2 years agobhyve: Fix vq_getchain() error handling bugs in various device models
Mark Johnston [Tue, 24 Aug 2021 18:10:08 +0000 (14:10 -0400)]
bhyve: Fix vq_getchain() error handling bugs in various device models

Reviewed by: grehan, khng
Approved by: so
Security: CVE-2021-29631
Security: FreeBSD-SA-21:13.bhyve

(cherry picked from commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558)

2 years agoFix multiple OpenSSL vulnerabilities.
Gordon Tetlow [Tue, 24 Aug 2021 18:03:46 +0000 (11:03 -0700)]
Fix multiple OpenSSL vulnerabilities.

Approved by: so
Security: SA-21:16.openssl
Security: CVE-2021-3711
Security: CVE-2021-3712

(cherry picked from commit be158ffe54dcc4a633652685afc5e37894e10ea0)

2 years agoFix libfetch out of bounds read.
Gordon Tetlow [Tue, 24 Aug 2021 17:59:01 +0000 (10:59 -0700)]
Fix libfetch out of bounds read.

Approved by: so
Security: SA-21:15.libfetch
Security: CVE-2021-36159

(cherry picked from commit 3be62d49ae2b6f9050f39fe74210c88f35901fa5)

2 years agoFix remote code execution in ggatec(8).
Gordon Tetlow [Tue, 24 Aug 2021 17:40:49 +0000 (10:40 -0700)]
Fix remote code execution in ggatec(8).

Approved by:    so
Security:       SA-21:14.ggatec
Security:       CVE-2021-29630

(cherry picked from commit 515216929c40169cc72b62466ff9238682661613)

2 years agoipfw: fix possible data race between jump cache reading and updating.
Andrey V. Elsukov [Tue, 17 Aug 2021 08:08:28 +0000 (11:08 +0300)]
ipfw: fix possible data race between jump cache reading and updating.

Jump cache is used to reduce the cost of rule lookup for O_SKIPTO and
O_CALLRETURN actions. It uses rules chain id to check correctness of
cached value. But due to the possible race, there is the chance that
one thread can read invalid value. In some cases this can lead to out
of bounds access and panic.

Use thread fence operations to constrain the reordering of accesses.
Also rename jump_fast and jump_linear functions to jump_cached and
jump_lookup_pos respectively.

Submitted by: Arseny Smalyuk
Obtained from: Yandex LLC
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D31484

(cherry picked from commit 322e5efda8578bb9c0a0ab0ef785cd1e1c222c85)

2 years agonetinet tests: delete an interface with pending lookups
Kristof Provost [Tue, 17 Aug 2021 14:19:29 +0000 (16:19 +0200)]
netinet tests: delete an interface with pending lookups

This has been known to trigger panics. It currently doesn't, but we may
as well have a test for it.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e86469075c5e391cc86e5bcd4f252712a69de37e)

2 years agoAdd arp/ndp tests in addition to rtsock ll tests.
Alexander V. Chernikov [Sat, 20 Feb 2021 18:20:24 +0000 (18:20 +0000)]
Add arp/ndp tests in addition to rtsock ll tests.

(cherry picked from commit f17f94cd1b99c61faa08aa988b47805c53b78ac7)

2 years agontb_hw_intel(4): Add CTLFLAG_MPSAFE flags.
Alexander Motin [Wed, 11 Aug 2021 00:03:12 +0000 (20:03 -0400)]
ntb_hw_intel(4): Add CTLFLAG_MPSAFE flags.

I should have added those in 50f16247a1.

MFC after: 2 weeks

(cherry picked from commit 94feb1f1eb4c3527efdbd0b3f556eb3cb37c3318)

2 years agontb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags.
Alexander Motin [Tue, 10 Aug 2021 20:24:48 +0000 (16:24 -0400)]
ntb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags.

Most of the sysctls just read hardware registers.  They don't need
any locking.

MFC after: 2 weeks

(cherry picked from commit 50f16247a110d2ace56f1120304616f3e6ad9763)

2 years agontb_transport(4): Mark callouts MP-safe.
Alexander Motin [Tue, 10 Aug 2021 20:30:12 +0000 (16:30 -0400)]
ntb_transport(4): Mark callouts MP-safe.

The only thing around NTB using Giant lock is NewBus, and these callouts
have nothing to do with it.

MFC after: 2 weeks

(cherry picked from commit c6902e7796bc78df011131a2b8b024faed884b8f)

2 years agoUPDATING: Add a note about OpenSSL defaulting KTLS to off.
John Baldwin [Tue, 17 Aug 2021 21:40:33 +0000 (14:40 -0700)]
UPDATING: Add a note about OpenSSL defaulting KTLS to off.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31444

(cherry picked from commit 671a35b176e4b3c445696a8b423db5f8de26c285)

2 years agoOpenSSL: Add support for Chacha20-Poly1305 to kernel TLS on FreeBSD.
John Baldwin [Tue, 17 Aug 2021 21:40:16 +0000 (14:40 -0700)]
OpenSSL: Add support for Chacha20-Poly1305 to kernel TLS on FreeBSD.

FreeBSD's kernel TLS supports Chacha20 for both TLS 1.2 and TLS 1.3.

NB: This commit has not yet been merged upstream as it is deemed a new
feature and did not make the feature freeze cutoff for OpenSSL 3.0.

Reviewed by: jkim
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31443

(cherry picked from commit 6372fd253e3266c6eb271f49159f1632d527c9bd)

2 years agoOpenSSL: Refactor KTLS tests to better support TLS 1.3.
John Baldwin [Tue, 17 Aug 2021 21:39:58 +0000 (14:39 -0700)]
OpenSSL: Refactor KTLS tests to better support TLS 1.3.

Most of this upstream commit touched tests not included in the
vendor import.  The one change merged in is to remove a constant
only present in an internal header to appease the older tests.

Reviewed by: jkim
Obtained from: OpenSSL (e1fdd5262e4a45ce3aaa631768e877ee7b6da21b)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31442

(cherry picked from commit d6e78ecb0bcd5af750c72745c4c51fe211046bff)

2 years agoOpenSSL: Update KTLS documentation
John Baldwin [Tue, 17 Aug 2021 21:39:32 +0000 (14:39 -0700)]
OpenSSL: Update KTLS documentation

KTLS support has been changed to be off by default, and configuration is
via a single "option" rather two "modes". Documentation is updated
accordingly.

Reviewed by: jkim
Obtained from: OpenSSL (6878f4300213cfd7d4f01e26a8b97f70344da100)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31441

(cherry picked from commit a208223130fb12daac9b4f52be1b3477b03ac521)

2 years agoOpenSSL: Only enable KTLS if it is explicitly configured
John Baldwin [Tue, 17 Aug 2021 21:39:03 +0000 (14:39 -0700)]
OpenSSL: Only enable KTLS if it is explicitly configured

It has always been the case that KTLS is not compiled by default. However
if it is compiled then it was automatically used unless specifically
configured not to. This is problematic because it avoids any crypto
implementations from providers. A user who configures all crypto to use
the FIPS provider may unexpectedly find that TLS related crypto is actually
being performed outside of the FIPS boundary.

Instead we change KTLS so that it is disabled by default.

We also swap to using a single "option" (i.e. SSL_OP_ENABLE_KTLS) rather
than two separate "modes", (i.e. SSL_MODE_NO_KTLS_RX and
SSL_MODE_NO_KTLS_TX).

Reviewed by: jkim
Obtained from: OpenSSL (a3a54179b6754fbed6d88e434baac710a83aaf80)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31440

(cherry picked from commit 62ca9fc1ad569eb3fafd281e03812a598b9856ee)

2 years agoOpenSSL: ktls: Initial support for ChaCha20-Poly1305
John Baldwin [Tue, 17 Aug 2021 21:38:47 +0000 (14:38 -0700)]
OpenSSL: ktls: Initial support for ChaCha20-Poly1305

Linux kernel is going to support ChaCha20-Poly1305 in TLS offload.
Add support for this cipher.

Reviewed by: jkim
Obtained from: OpenSSL (3aa7212e0a4fd1533c8a28b8587dd8b022f3a66f)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31439

(cherry picked from commit 63c6d3e283eb01d32f54e2a153e6719d19e4a80d)

2 years agoOpenSSL: Correct the return value of BIO_get_ktls_*().
John Baldwin [Tue, 17 Aug 2021 21:37:47 +0000 (14:37 -0700)]
OpenSSL: Correct the return value of BIO_get_ktls_*().

BIO_get_ktls_send() and BIO_get_ktls_recv() are documented as
returning either 0 or 1.  However, they were actually returning the
internal value of the associated BIO flag for the true case instead of
1.

Also trim redundant ternary operators.

Reviewed by: jkim
Obtained from: OpenSSL (f16e52b67c9261bdc7e1284a50502a802921ac6d)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31438

(cherry picked from commit 334d228a204c16d1384a978ab9b209e4e7e33275)

2 years agonfs tls: Update for SSL_OP_ENABLE_KTLS.
John Baldwin [Tue, 10 Aug 2021 21:18:43 +0000 (14:18 -0700)]
nfs tls: Update for SSL_OP_ENABLE_KTLS.

Upstream OpenSSL (and the KTLS backport) have switched to an opt-in
option (SSL_OP_ENABLE_KTLS) in place of opt-out modes
(SSL_MODE_NO_KTLS_TX and SSL_MODE_NO_KTLS_RX) for controlling kernel
TLS.

Reviewed by: rmacklem
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31445

(cherry picked from commit c7bb0f47f721a2095ed6100bca595ba68fa5645a)

2 years agoixgbe: Avoid sbuf_trim(9) in sysctl handler
Kevin Bowling [Mon, 23 Aug 2021 16:21:39 +0000 (09:21 -0700)]
ixgbe: Avoid sbuf_trim(9) in sysctl handler

This was an error, we cannot use sbuf_trim(9) in the
ixgbe_sbuf_fw_version function because it also gets called in
the context of sbuf_new_for_sysctl(9). sbuf(9) explains the interaction
with drain functions as used by sbuf_new_for_sysctl(9).

Reviewed by: imp
Fixes: 7660e4ea5cb7
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D31633

(cherry picked from commit 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc)

2 years agoloader: fix multiboot loading on UEFI
Roger Pau Monné [Wed, 11 Aug 2021 14:55:10 +0000 (16:55 +0200)]
loader: fix multiboot loading on UEFI

(cherry picked from commit 5e4279a8f35aa4b46debf728d3f743d64f15aaf8)

2 years agoamd64 UEFI loader: stop copying staging area to 2M physical
Konstantin Belousov [Sat, 10 Jul 2021 19:55:56 +0000 (22:55 +0300)]
amd64 UEFI loader: stop copying staging area to 2M physical

(cherry picked from commit f75caed644a5c8c342a1ea5e7a6d5251f82ed0b1)

2 years agoamd64 pmap_vm_page_alloc_check(): loose the assert
Konstantin Belousov [Sun, 1 Aug 2021 21:58:21 +0000 (00:58 +0300)]
amd64 pmap_vm_page_alloc_check(): loose the assert

(cherry picked from commit 665895db262fa596b347e40f6857b37e0f43b184)

2 years agoamd64 pmap_vm_page_alloc_check(): print more data for failed assert
Konstantin Belousov [Sun, 1 Aug 2021 13:38:17 +0000 (16:38 +0300)]
amd64 pmap_vm_page_alloc_check(): print more data for failed assert

(cherry picked from commit 1a55a3a729cd4424e17308d3e86b54b9a6e68f7b)

2 years agoAdd pmap_vm_page_alloc_check()
Konstantin Belousov [Sat, 10 Jul 2021 19:53:41 +0000 (22:53 +0300)]
Add pmap_vm_page_alloc_check()

(cherry picked from commit 041b7317f75ecc5e1629e2dd6786c8bdbe1b19eb)

2 years agoamd64: do not assume that kernel is loaded at 2M physical
Konstantin Belousov [Sat, 10 Jul 2021 19:48:02 +0000 (22:48 +0300)]
amd64: do not assume that kernel is loaded at 2M physical

(cherry picked from commit e18380e341410ce70d97560a22827591f4b2d373)

2 years agoamd64: stop doing special allocation for the AP startup trampoline
Konstantin Belousov [Thu, 29 Jul 2021 00:22:35 +0000 (03:22 +0300)]
amd64: stop doing special allocation for the AP startup trampoline

(cherry picked from commit b27fe1c3ba2a1302c2866751e0c618b5a697bf30)

2 years agoamd64: rework AP startup
Konstantin Belousov [Sat, 10 Jul 2021 19:38:42 +0000 (22:38 +0300)]
amd64: rework AP startup

(cherry picked from commit d6717f877872e62d9df1e0ce2d8856620c993924)

2 years agoevdev: Use bit_foreach helper macro
Vladimir Kondratyev [Mon, 16 Aug 2021 21:28:37 +0000 (00:28 +0300)]
evdev: Use bit_foreach helper macro

for traversing all bits set in the bitstring(9).

While here move bit_change() definition to common header.

(cherry picked from commit 5f99ae56c9196753ae162ad464c2969ad1a131b6)

2 years agobitstring(3): Add bitstring traversal macros.
Vladimir Kondratyev [Mon, 16 Aug 2021 20:18:58 +0000 (23:18 +0300)]
bitstring(3): Add bitstring traversal macros.

The macro bit_foreach() traverses all set bits in the bitstring in the
forward direction, assigning each location in turn to variable.

The macro bit_foreach_at() traverses all set bits in the bitstring in
the forward direction at or after the zero-based bit index, assigning
each location in turn to variable.

The bit_foreach_unset() and bit_foreach_unset_at() macros which
traverses unset bits are implemented for completeness.

Reviewed by: asomers, dougm

(cherry picked from commit 14a4d6d01335dd233023834e05897377cb70d52a)

2 years agohms(4): Allow attachment to pointer top level collection.
Vladimir Kondratyev [Mon, 16 Aug 2021 20:18:43 +0000 (23:18 +0300)]
hms(4): Allow attachment to pointer top level collection.

to be in line with Microsoft mouse driver [1]

[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/top-level-collections-opened-by-windows-for-system-use

(cherry picked from commit 9b78891df13d12abaf8d0f0b0ca3e7d5f0e857e3)

2 years agops4dshock(4): Fix touchpad width in HID report descriptor
Vladimir Kondratyev [Mon, 16 Aug 2021 20:18:27 +0000 (23:18 +0300)]
ps4dshock(4): Fix touchpad width in HID report descriptor

(cherry picked from commit 9b2b5f42b4fee7fdb6c7653829da71e9706f849b)

2 years agohid: move proper hat switch handling from ps4dshock to hgame
Greg V [Mon, 16 Aug 2021 20:18:09 +0000 (23:18 +0300)]
hid: move proper hat switch handling from ps4dshock to hgame

Generic "DirectInput" HID gamepads need this handling too.

Reviewed by: wulf

(cherry picked from commit 51b2216114546bb13b13002b29fb1263e600a0fc)

2 years agohmt(4): Do not ignore constant usages in HID report descriptor parser
Jack [Mon, 16 Aug 2021 20:17:41 +0000 (23:17 +0300)]
hmt(4): Do not ignore constant usages in HID report descriptor parser

This fixes hmt to work with MELF0411 1FD2:7012 touchscreen

Obtained from: sysutils/iichid

(cherry picked from commit cb910670ac59e11808a629c8375c60200f909217)

2 years agohid: Add extra constant to units of measurement
Vladimir Kondratyev [Mon, 16 Aug 2021 20:13:24 +0000 (23:13 +0300)]
hid: Add extra constant to units of measurement

Some devices like eGalax touchscreens use value of 0x33 instead of 0x13
for inches as unit of measure.

Reported by: Mark Kane <mark_AT_kane_DOT_mn>

(cherry picked from commit be75951af1ec2d69d34a8701700b9bfd2a50679e)

2 years agoevdev: Do not check maximal contact number for MT initialization
Vladimir Kondratyev [Mon, 16 Aug 2021 20:12:01 +0000 (23:12 +0300)]
evdev: Do not check maximal contact number for MT initialization

This allows singletouch devices which use multitouch protocols to work.

Reported by: Mark Kane <mark_AT_kane_DOT_mn>

(cherry picked from commit e40fec4ec9a7a6625b3e332d4f856eb1d05f0def)

2 years agohmt(4): Store Contact Count in separate variable.
Vladimir Kondratyev [Mon, 16 Aug 2021 20:11:36 +0000 (23:11 +0300)]
hmt(4): Store Contact Count in separate variable.

No functional changes.

(cherry picked from commit 95add157e341f2c1ce47eaa19b3c5771705ea20d)

2 years agoe1000: always enable PCSD when RSS hashing
Kevin Bowling [Mon, 16 Aug 2021 17:17:34 +0000 (10:17 -0700)]
e1000: always enable PCSD when RSS hashing

To enable RSS hashing in the NIC, the PCSD bit must be set.

By default, this is never set when RXCSUM is disabled - which
causes problems higher up in the stack.

While here improve the RXCSUM flag assignments when enabling or
disabling IFCAP_RXCSUM.

See also: https://lists.freebsd.org/pipermail/freebsd-current/2020-May/076148.html

Reviewed by: markj, Franco Fichtner <franco@opnsense.org>,
Stephan de Wit <stephan.dewt@yahoo.co.uk>
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31501
Co-authored-by: Stephan de Wit <stephan.dewt@yahoo.co.uk>
Co-authored-by: Franco Fichtner <franco@opnsense.org>
(cherry picked from commit 69e8e8ea3d4be9da6b5bc904a444b51958128ff5)

2 years agolibpfctl: Fix endianness issues
Kristof Provost [Fri, 20 Aug 2021 11:43:15 +0000 (13:43 +0200)]
libpfctl: Fix endianness issues

Several fields are supplied in big-endian format, so we need to convert
them before we display them.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 719b5397c2887bc0619bb6ffb38f67f37bbf13c6)

2 years agoarm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS
Mateusz Guzik [Wed, 21 Jul 2021 03:34:32 +0000 (05:34 +0200)]
arm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS

Stat collection using counter(9) is quite expensive on this platform and
these counters are normally not needed.

In particular we see about 1.5% bump in packet rate using Cortex-A9

Reviewed by: ian
Sponsored by: Rubicon Communications, LLC ("Netgate")
Different Revision: https://reviews.freebsd.org/D31592

(cherry picked from commit aec8ad8a9e6aba2d73c98bd41f2994744aae3d01)

2 years agopf: assert dir state on pf_test{,6}
Mateusz Guzik [Tue, 17 Aug 2021 18:16:09 +0000 (20:16 +0200)]
pf: assert dir state on pf_test{,6}

The intent is to line up various enums so that branching in the lines of:

idx = (dir == PF_IN ? PF_SK_WIRE : PF_SK_STACK);

is avoided.

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 3e875f952af05697807139b460e5124eb5f6137b)

2 years agopf: save on branching in the common case in pf_test
Mateusz Guzik [Tue, 17 Aug 2021 18:04:31 +0000 (20:04 +0200)]
pf: save on branching in the common case in pf_test

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5091ca26507b83ebd5ce677dd26bd10e4bad4153)

2 years agouipc: avoid circular pr_{slow,fast}timos
Kyle Evans [Wed, 18 Aug 2021 17:31:45 +0000 (12:31 -0500)]
uipc: avoid circular pr_{slow,fast}timos

domain_init() gets reinvoked for each vnet on a system, so we must not
alter global state.  Practically speaking, we were creating circular
lists and tying up a softclock thread into an infinite loop.

The breakage here was most easily observed by simply creating a jail
in a new vnet and watching the system suddenly become erratic.

Reported by: markj
Fixes: e0a17c3f063f ("uipc: create dedicated lists for fast ...")
Pointy hat: kevans

(cherry picked from commit d7e1bdfebacc4de25dc51e14a91d66bb429677c9)

2 years agouipc: create dedicated lists for fast and slow timeout callbacks
Mateusz Guzik [Sun, 15 Aug 2021 21:41:47 +0000 (23:41 +0200)]
uipc: create dedicated lists for fast and slow timeout callbacks

This avoids having to walk all possible protocols only to check if they
have one (vast majority does not).

Original patch by kevans@.

Reviewed by: kevans
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e0a17c3f063fd51430fb2b4f5bc667f79d2967c2)

2 years agocoretemp: use x86_msr_op for thermal MSR access
Konstantin Belousov [Mon, 2 Aug 2021 19:53:08 +0000 (22:53 +0300)]
coretemp: use x86_msr_op for thermal MSR access

(cherry picked from commit 4cc6fe1e5b73ce540882753d918bc8208849e9e9)

2 years agox86_msr_op: extend the KPI to allow MSR read and single-CPU operations
Konstantin Belousov [Mon, 2 Aug 2021 19:52:26 +0000 (22:52 +0300)]
x86_msr_op: extend the KPI to allow MSR read and single-CPU operations

(cherry picked from commit d0bc4b466683d17b84f9acafe4c3cc746f860dbf)

2 years agortld: constify most variables holding references to the environment values
Konstantin Belousov [Mon, 16 Aug 2021 16:55:06 +0000 (19:55 +0300)]
rtld: constify most variables holding references to the environment values

(cherry picked from commit aa68b3bb2e11392f4636b3656b0f0bcacec3385a)

2 years agortld: provide private getenv(3)
Konstantin Belousov [Mon, 16 Aug 2021 14:02:48 +0000 (17:02 +0300)]
rtld: provide private getenv(3)

(cherry picked from commit b4b274889145bbc559613b54e7520b95f43e51e6)

2 years agortld: avoid use of of getenv(3) for evaluating rtld env vars (LD_XXX)
Konstantin Belousov [Mon, 16 Aug 2021 12:59:05 +0000 (15:59 +0300)]
rtld: avoid use of of getenv(3) for evaluating rtld env vars (LD_XXX)

(cherry picked from commit bfd4c875a10560aaa2f41e82114df79fde008fdb)

2 years agortld: rework how environment variables are named
Konstantin Belousov [Sun, 15 Aug 2021 18:57:42 +0000 (21:57 +0300)]
rtld: rework how environment variables are named

(cherry picked from commit 451dc2b7cc0c845a3f76f9ee670f16699c49b491)

2 years agolibc tls: use TLS_DTV_OFFSET defined by rtld.h
Konstantin Belousov [Sun, 15 Aug 2021 02:14:26 +0000 (05:14 +0300)]
libc tls: use TLS_DTV_OFFSET defined by rtld.h

(cherry picked from commit 300e08933e80e9fce02d0d2f7a64e3ad27e4ce8e)

2 years agortld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK is set
Fangrui Song [Sun, 15 Aug 2021 04:13:33 +0000 (07:13 +0300)]
rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK is set

(cherry picked from commit 7da378f9de1a042ec0c81ba7ad39a392540d4721)

2 years agortld: Remove calculate_tls_end
Fangrui Song [Sat, 14 Aug 2021 17:02:09 +0000 (20:02 +0300)]
rtld: Remove calculate_tls_end

(cherry picked from commit 8f63fa78e84afd23fa68c82eabfe64763c92d4f5)

2 years agortld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0
Fangrui Song [Sat, 14 Aug 2021 16:56:58 +0000 (19:56 +0300)]
rtld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0

(cherry picked from commit e6c76962031625d51fe4225ecfa15c85155eb13a)

2 years agoufs_dirhash: Correct a typo in a comment
Gordon Bergling [Fri, 20 Aug 2021 07:59:18 +0000 (09:59 +0200)]
ufs_dirhash: Correct a typo in a comment

- s/memry/memory/

(cherry picked from commit 464a166c27bb8947d5de1f617170ef6813587cc3)

2 years agoOptimize res_find().
Alexander Motin [Mon, 9 Aug 2021 01:34:33 +0000 (21:34 -0400)]
Optimize res_find().

When the device name is provided, we can simply run strncmp() for each
line to quickly skip unrelated ones, that is much faster than sscanf()
and only then strcmp().

MFC after: 2 weeks

(cherry picked from commit 696fca3fd491972e615195f2ce94598b9c469cac)

2 years agosigtimedwait: Use a unique wait channel for sleeping
Mark Johnston [Mon, 16 Aug 2021 17:15:25 +0000 (13:15 -0400)]
sigtimedwait: Use a unique wait channel for sleeping

When a sigtimedwait(2) caller goes to sleep, it uses a wait channel of
p->p_sigacts with the proc lock as the interlock.  However, p_sigacts
can be shared between processes if a child is created with
rfork(RFSIGSHARE | RFPROC).  Thus we can end up with two threads
sleeping on the same wait channel using different locks, which is not
permitted.

Fix the problem simply by using a process-unique wait channel, following
the example of sigsuspend.  The actual wait channel value is irrelevant
here, sleeping threads are awoken using sleepq_abort().

Reported by: syzbot+8c417afabadb50bb8827@syzkaller.appspotmail.com
Reported by: syzbot+1d89fc2a9ef92ef64fa8@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c4feb1ab0ae0c0e779af372e4c5f3b9e0d3e1388)

2 years agoftpd: delete dead code
Alan Somers [Tue, 27 Jul 2021 18:14:00 +0000 (12:14 -0600)]
ftpd: delete dead code

Delete code killed by SVN r13139 in 1996.  Little chance that it would
still compile today.

PR: 257317
Reported by: Alan Shearer <sakison@gmail.com>
Sponsored by: Axcient

(cherry picked from commit 674400eb20b65369a88b1cb778d729bc297832c9)