]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
14 months agoamd64: Avoid copying td_frame from kernel procs
Mark Johnston [Sat, 25 Sep 2021 14:15:31 +0000 (10:15 -0400)]
amd64: Avoid copying td_frame from kernel procs

When creating a new thread, we unconditionally copy td_frame from the
creating thread.  For threads which never return to user mode, this is
unnecessary since td_frame just points to the base of the stack or a
random interrupt frame.

If KASAN is configured this copying may also trigger false positives
since the td_frame region may contain poisoned stack regions.  It was
not noticed before since thread0 used a dummy proc0_tf trapframe, and
kernel procs are generally created by thread0.  Since commit
df8dd6025af88a99d34f549fa9591a9b8f9b75b1, though, we call
cpu_thread_alloc(&thread0) when initializing FPU state, which
reinitializes thread0.td_frame.

Work around the problem by not copying the frame unless the copying
thread came from user mode.  While here, de-duplicate the copying and
remove redundant re(initialization) of td_frame.

Reported by: syzbot+2ec89312bffbf38d9aec@syzkaller.appspotmail.com
Reviewed by: kib
Fixes: df8dd6025af8
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32057

(cherry picked from commit ca1e447b1048b26b855d7f7fbcdad78309e4d741)

14 months agossh: default VerifyHostKeyDNS to no, following upstream
Ed Maste [Fri, 17 Feb 2023 01:26:41 +0000 (20:26 -0500)]
ssh: default VerifyHostKeyDNS to no, following upstream

Revert to upstream's default.  Using VerifyHostKeyDNS may depend on a
trusted nameserver and network path.

This reverts commit 83c6a5242c80160fff76fb85454938761645b0c4.

Reported by: David Leadbeater, G-Research
Reviewed by: gordon
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38648

(cherry picked from commit 41ff5ea22cb95deb9e7415510eb2f5f00b91537a)

14 months agoDelete obsolete Solaris compat header file stdlib.h
Zhenlei Huang [Thu, 23 Feb 2023 18:00:09 +0000 (02:00 +0800)]
Delete obsolete Solaris compat header file stdlib.h

This drops function `getexecname()` redirection.

Historically `getexecname()` is a compatibility definition. Since
openzfs has its own implementation of function `getexecname()` in libspl
and has been merged into base, the compat header file stdlib.h is
no longer needed and should not be used.

Also without this fix libspl will end up an incompatible version of
`getprogname()` with libc. In particular, if zfs is enabled, programs
such as pgrep in /rescue can be wrongly statically linked with libspl
and will not function properly.

PR: 269738
Reviewed by: markj
Fixes: 9e5787d2284e Merge OpenZFS support in to HEAD
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38733

(cherry picked from commit 7f0ebf0876c82a098bd5815ea6bf3a8efa6dd6f3)

14 months agotmpfs: support the nosymfollow mount option
Konstantin Belousov [Thu, 23 Feb 2023 13:15:17 +0000 (15:15 +0200)]
tmpfs: support the nosymfollow mount option

PR: 269772

(cherry picked from commit 15df90218bb62df96ce27f47ad9953f4c1f37900)

14 months agoEnsure .inc files are regenerated when llvm/clang tblgen binaries change
Dimitry Andric [Sat, 25 Feb 2023 15:25:57 +0000 (16:25 +0100)]
Ensure .inc files are regenerated when llvm/clang tblgen binaries change

When doing a fully incremental build (with WITHOUT_CLEAN enabled), from
a commit before llvm 15 was merged (3264f6b88fce), to a commit after
that, a number of .inc files were not regenerated. This could lead to
unexpected compilation errors when these .inc files were included from
llvm-project sources, similar to:

  In file included from /usr/src/contrib/llvm-project/clang/lib/CodeGen/CGBuiltin.cpp:8268:
  /usr/obj/usr/src/amd64.amd64/lib/clang/libclang/clang/Basic/arm_mve_builtin_cg.inc:279:18: error: no matching constructor for initialization of 'clang::CodeGen::Address'
    Address Val2 = Address(Val1, CharUnits::fromQuantity(2));
                   ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Work around this by making the .inc files dependent on the tblgen binary
used for generating them. E.g., we can relatively safely assume that if
the binary gets updated, the .inc files must also be updated. (Although
this is not 100% optimal, the gain by complicating things even more is
probaby not worth the effort.)

MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38770

(cherry picked from commit ab80f0b21fbb9c44d40e6f7a99090188f4ed2f71)

15 months agonetlink: make the maximum allowed netlink socket buffer runtime tunable.
Alexander V. Chernikov [Mon, 27 Feb 2023 10:44:54 +0000 (10:44 +0000)]
netlink: make the maximum allowed netlink socket buffer runtime tunable.

Dumping large routng tables (>1M paths with multipath) require the socket
 buffer which is larger than the currently defined limit.
Allow the limit to be set in runtime, similar to kern.ipc.maxsockbuf.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 1 day

(cherry picked from commit 28a5d88f7091d1fc72f4f1bd8562d3c8b15883f5)

15 months agoFix a slew of mdoc warnings/errors.
Christian Brueffer [Tue, 12 Apr 2022 21:52:54 +0000 (23:52 +0200)]
Fix a slew of mdoc warnings/errors.

MFC requested by meeena in IRC.

share/man/man9/VOP_SETLABEL.9 and share/man/man9/hz.9 omitted since
they didn't exist in 13-STABLE.

share/man/man9/mod_cc.9 omitted as some of the changes are in text
not applicable to 13-STABLE.

(cherry picked from commit 320686674b3c8ce3ffe135c421a22d063917ee46)

Approved by: carlavilla (mentor)

15 months agolinprocfs(4): Fixup process size in the /proc/pid/stat file
Dmitry Chagin [Sun, 26 Feb 2023 13:42:22 +0000 (16:42 +0300)]
linprocfs(4): Fixup process size in the /proc/pid/stat file

According to the Linux sources the kernel exposes a proces virtual
memory size via proc filesystem into the three files - stat, status
and statm. This is the struct mm->total_vm value adjusted to the
corresponding units - bytes, kilobytes and pages.

The fix is based on a fernape@ analysis.

PR: 265937
Reported by: Ray Bellis
MFC after: 3 days

(cherry picked from commit a55b5a9aed3981fcec205e246436991d138c78a2)

15 months agolinux(4): Trim unused opt_usb.h from modules Makefiles
Dmitry Chagin [Tue, 14 Feb 2023 14:46:33 +0000 (17:46 +0300)]
linux(4): Trim unused opt_usb.h from modules Makefiles

MFC after: 2 weeks

(cherry picked from commit 825fbd087e6150eaf601612a5e7468ddc808e004)

15 months agolinux(4): Rename linux_timer.h to linux_time.h
Dmitry Chagin [Tue, 14 Feb 2023 14:46:33 +0000 (17:46 +0300)]
linux(4): Rename linux_timer.h to linux_time.h

To avoid confusing people, rename linux_timer.h to linux_time.h,
as linux_timer.c is the implementation of timer syscalls only,
while linux_time.c contains implementation of all stuff declared
in linux_time.h.

MFC after: 2 weeks

(cherry picked from commit c8a79231a5a74fc4263ec3d18c6519a974efb529)

15 months agolinux(4): Cleanup includes under arm64/linux
Dmitry Chagin [Tue, 14 Feb 2023 14:46:33 +0000 (17:46 +0300)]
linux(4): Cleanup includes under arm64/linux

Cleanup unneeded includes, sort the rest according to style(9).
No functional changes.

MFC after: 2 weeks

(cherry picked from commit 55d3e181fc10edb4810f33009b65342c3e23dd88)

15 months agolinux(4): Cleanup includes under x86/linux
Dmitry Chagin [Tue, 14 Feb 2023 14:46:33 +0000 (17:46 +0300)]
linux(4): Cleanup includes under x86/linux

Cleanup unneeded includes, sort the rest according to style(9).
No functional changes.

MFC after: 2 weeks

(cherry picked from commit 496a9a4f60716b3ba236c3f20639da03fefe3a3f)

15 months agolinux(4): Cleanup includes under amd64/linux
Dmitry Chagin [Tue, 14 Feb 2023 14:46:32 +0000 (17:46 +0300)]
linux(4): Cleanup includes under amd64/linux

Cleanup unneeded includes, sort the rest according to style(9).
No functional changes.

MFC after: 2 weeks

(cherry picked from commit 2456a45929328ce73a40ef6577600b0f1e2cced6)

15 months agolinux(4): Cleanup includes under i386/linux
Dmitry Chagin [Tue, 14 Feb 2023 14:46:32 +0000 (17:46 +0300)]
linux(4): Cleanup includes under i386/linux

Cleanup unneeded includes, sort the rest according to style(9).
No functional changes.

MFC after: 2 weeks

(cherry picked from commit f4a512a5f187d9139c04111784fe811572bc0ed6)

15 months agolinux(4): Cleanup includes under compat/linux
Dmitry Chagin [Tue, 14 Feb 2023 14:46:32 +0000 (17:46 +0300)]
linux(4): Cleanup includes under compat/linux

Cleanup unneeded includes, sort the rest according to style(9).
No functional changes.

MFC after: 2 weeks

(cherry picked from commit d8e53d94fae90cf3c83db5af0eaba0be0f55e00a)

15 months agolinux(4): Cleanup sys/sysctl.h from linux_misc.h
Dmitry Chagin [Tue, 14 Feb 2023 14:46:32 +0000 (17:46 +0300)]
linux(4): Cleanup sys/sysctl.h from linux_misc.h

Leftover after c5156c77 (r374538).

MFC after: 2 weeks

(cherry picked from commit e2028292e54a4541d1e80159c78516a0b3332e0c)

15 months agolinux(4): Fix brackets of local include opt_inet6
Dmitry Chagin [Tue, 14 Feb 2023 14:46:32 +0000 (17:46 +0300)]
linux(4): Fix brackets of local include opt_inet6

MFC after: 2 weeks

(cherry picked from commit 77f66834b059ae8327b731a19794788eed59178c)

15 months agolinux(4): Cleanup sys/uio.h where linux_uitl.h is included
Dmitry Chagin [Tue, 14 Feb 2023 14:46:31 +0000 (17:46 +0300)]
linux(4): Cleanup sys/uio.h where linux_uitl.h is included

MFC after: 2 weeks

(cherry picked from commit acbbd5c0393345f13aa4b902e2c1ac83b7e39b59)

15 months agolinux(4): Move uselib() to i386
Dmitry Chagin [Tue, 14 Feb 2023 14:46:31 +0000 (17:46 +0300)]
linux(4): Move uselib() to i386

This obsolete system call is not supported by glibc. In ancient libc
versions (before glibc 2.0), uselib() was used to load the shared
libraries with names found in an array of names in the binary.
On Linux, since 3.15, this system call is available only when
the kernel is configured with the CONFIG_USELIB option.

It doesn't look like anyone needs this syscall for others Linuxulators,
so move it to the corresponding MD Linuxulator.

MFC after: 2 weeks

(cherry picked from commit 50c85a32d9c667779494850b6238b8d7ec13da75)

15 months agolinux(4): Cleanup abi_compat.h include from linux_timer.h
Dmitry Chagin [Tue, 14 Feb 2023 14:46:31 +0000 (17:46 +0300)]
linux(4): Cleanup abi_compat.h include from linux_timer.h

Leftover after timespec copyin/copyout routines was implemented.

MFC after: 2 weeks

(cherry picked from commit 86f9efef2c44f6be007cbc9ab383ee6a277d5880)

15 months agolinux(4): Cleanup sys/queue.h from linux.h
Dmitry Chagin [Tue, 14 Feb 2023 14:46:31 +0000 (17:46 +0300)]
linux(4): Cleanup sys/queue.h from linux.h

Leftover after converting futexes to the umtx API.

NFC after: 2 weeks

(cherry picked from commit 007986714c78c8e087038fb05442f17da1171bfa)

15 months agolinux(4): Cleanup sys/sysent.h from linux_util
Dmitry Chagin [Tue, 14 Feb 2023 14:46:31 +0000 (17:46 +0300)]
linux(4): Cleanup sys/sysent.h from linux_util

Include sys/sysent.h directly where it needed. The linux_util.h included
in a most source files of the Linuxulator, avoid collecting a rarely used
includes here.

MFC after: 2 weeks

(cherry picked from commit 513eb69edf382923bff1b09edda64010d89f74bd)

15 months agolinux(4): Cleanup vm includes from linux_util.h
Dmitry Chagin [Tue, 14 Feb 2023 14:46:30 +0000 (17:46 +0300)]
linux(4): Cleanup vm includes from linux_util.h

Include vm headers directly where they needed. The linux_util.h included
in a most source files of the Linuxulator, avoid collecting a rarely used
includes here.

MFC after: 2 weeks

(cherry picked from commit 31e938c531dcbb708dbcd0e1d0a4ea80dcc82300)

15 months agolinux(4): Cleanup unneeded includes from linux_util.h
Dmitry Chagin [Tue, 14 Feb 2023 14:46:30 +0000 (17:46 +0300)]
linux(4): Cleanup unneeded includes from linux_util.h

MFC after: 2 weeks

(cherry picked from commit 81e7a800552196a65c9c8b3fef82c2ef6c8058ff)

15 months agosrc.conf: regen man page
Ed Maste [Tue, 28 Feb 2023 21:42:53 +0000 (16:42 -0500)]
src.conf: regen man page

This hadn't been regenerated on the stable branch after some MFCs.

Sponsored by: The FreeBSD Foundation

15 months agoDo not delete objdump when WITH_LLVM_BINUTILS is true
Ed Maste [Sun, 25 Sep 2022 19:29:38 +0000 (15:29 -0400)]
Do not delete objdump when WITH_LLVM_BINUTILS is true

WITH_LLVM_BINUTILS links /usr/bin/objdump to llvm-objdump, and similarly
for the man page.  Do not delete them in `make delete-old`.

PR: 266603
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d1a351be19d4bd03918d44ea33fa7c09655f810a)

15 months agolibdwarf: Add some constants from DWARF 5
Mark Johnston [Tue, 7 Feb 2023 19:33:27 +0000 (14:33 -0500)]
libdwarf: Add some constants from DWARF 5

This is not exhaustive - DWARF 5 has some new enumeration types not
implemented here - but I think I caught all the ones that are extended
in DWARF 5, plus the new compilation unit type (DW_UT_*), needed when
parsing .debug_info headers.

These were useful when extending libdwarf/ctfconvert/readelf to handle
DWARF generated by gcc 12, which is version 5 by default.

Reviewed by: emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38273

(cherry picked from commit 7bb441c866781ec14b3e79a4f3e95fd319ab7ff9)

15 months agobhyve: add emulation for qemu's fwcfg data port
Corvin Köhne [Wed, 11 Aug 2021 08:00:34 +0000 (10:00 +0200)]
bhyve: add emulation for qemu's fwcfg data port

The data port returns the data of the fwcfg item.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38333

(cherry picked from commit b11081dca76b8e283495632b86b41539ee013857)

15 months agobhyve: add emulation for the qemu fwcfg selector port
Corvin Köhne [Wed, 11 Aug 2021 07:59:16 +0000 (09:59 +0200)]
bhyve: add emulation for the qemu fwcfg selector port

The selector port is used to select the desired fwcfg item.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38332

(cherry picked from commit 151d8131a817e7a6a629e9bb7fde4d7a158e5211)

15 months agobhyve: add basic qemu fwcfg implementation
Corvin Köhne [Wed, 11 Aug 2021 07:58:15 +0000 (09:58 +0200)]
bhyve: add basic qemu fwcfg implementation

qemu's fwcfg and bhyve's fwctl are both used to configure ovmf. qemu's
fwcfg is much more powerfull than bhyve's fwctl. For that reason, add
support for qemu's fwcfg.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38331

(cherry picked from commit 9b99de77f16029dd55326e0210072b14ec1ad960)

15 months agobhyve: maintain a list of acpi devices
Corvin Köhne [Thu, 7 Oct 2021 14:14:31 +0000 (16:14 +0200)]
bhyve: maintain a list of acpi devices

The list is used to generate the dsdt entry for every acpi device.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D3830

(cherry picked from commit fbd045021d9ffdae5e5bb20e1d1890fd4b46498e)

15 months agobhyve: add helper func to write a dsdt entry
Corvin Köhne [Thu, 7 Oct 2021 13:58:27 +0000 (15:58 +0200)]
bhyve: add helper func to write a dsdt entry

The guest will check the dsdt to detect acpi devices. Therefore, add a
helper function to create such a dsdt entry for an acpi device.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38329

(cherry picked from commit 682a522d61223920f23a202aa57901f38bdfd8dd)

15 months agobhyve: add helper func to add acpi resources
Corvin Köhne [Thu, 7 Oct 2021 13:57:01 +0000 (15:57 +0200)]
bhyve: add helper func to add acpi resources

These helper function can be used to assign acpi resources to an
acpi_device.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38328

(cherry picked from commit 13a1df5b85e992570f45248bfe9d581dc182b755)

15 months agobhyve: add helper struct for acpi device handling
Corvin Köhne [Thu, 7 Oct 2021 13:54:46 +0000 (15:54 +0200)]
bhyve: add helper struct for acpi device handling

To simplify the handling of different acpi devices like qemu fwcfg or a
tpm, add a helper struct. It will handle the reporting of acpi
resources.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38327

(cherry picked from commit 1231f047c3ed46ca6041df62f2b71f6e879bbb40)

15 months agoapic: prevent divide by zero in CPU frequency init
Mina Galić [Tue, 28 Feb 2023 02:58:45 +0000 (19:58 -0700)]
apic: prevent divide by zero in CPU frequency init

If a CPU for some reason returns 0 as CPU frequency, we currently panic
on the resulting divide by zero when trying to initialize the CPU(s) via
APIC. When this happens, we'll fallback to measuring the frequency
instead.

PR: 269767
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/664

(cherry picked from commit 499171a98c8813e4dc6e085461d5c47750efa555)

15 months agostand: fix build userboot without zfs
Michael Paepcke [Tue, 28 Feb 2023 02:58:03 +0000 (19:58 -0700)]
stand: fix build userboot without zfs

Fix regression in building userboot -DWITHOUT_LOADER_ZFS

Fixes: e307eb94ae520
MFC After: 3 days
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/665

(cherry picked from commit 4d59545d0cacb5881e2515eecce15e8478f07276)

15 months agovnet: Make vnet_sys[un]init() static
Zhenlei Huang [Tue, 21 Feb 2023 16:22:23 +0000 (00:22 +0800)]
vnet: Make vnet_sys[un]init() static

These two functions are intended to be used only when allocating or
destroying vnet instances.

No functional change intended.

Reviewed by: kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37955

(cherry picked from commit fb9b76e05247e014f5faa554161028f6aa409bfd)

15 months agoping: Fix unsigned integer underflow resuling in a ping -R segfault
Cy Schubert [Thu, 23 Feb 2023 05:43:17 +0000 (21:43 -0800)]
ping: Fix unsigned integer underflow resuling in a ping -R segfault

ping -R (F_RROUTE) will loop at ping.c:1381 until it segfaults or
the unsigned int hlen happens to be less than the size of an IP header:

slippy$ ping -R 192.168.0.101
PING 192.168.0.101 (192.168.0.101): 56 data bytes
64 bytes from 192.168.0.101: icmp_seq=0 ttl=63 time=1.081 ms
RR:  192.168.0.1
192.168.0.101
192.168.0.101
10.1.1.254
10.1.1.91
unknown option bb
unknown option 32
unknown option 6
...
unknown option 96
unknown option 2d
Segmentation fault

The reason for this is while looping through loose source routing (LSRR)
and strict source routing (SSRR), hlen will become smaller than the IP
header. It may even become negative. This should terminate the loop.
However, when hlen is unsigned, an integer underflow occurs becoming a
large number causing the loop to continue virtually forever until hlen
is either by chance smaller than the lenghth of an IP header or it
segfaults.

Reviewed by: asomers
Fixes: 46d7b45a267b
Differential Revision: https://reviews.freebsd.org/D38744

(cherry picked from commit 70960bb86a3ba5b6f5c4652e613e6313a7ed1ac1)

15 months agovm_fault: Fix a race in vm_fault_soft_fast()
Mark Johnston [Mon, 13 Feb 2023 21:24:40 +0000 (16:24 -0500)]
vm_fault: Fix a race in vm_fault_soft_fast()

When vm_fault_soft_fast() creates a mapping, it release the VM map lock
before unbusying the top-level object.  Without the map lock, however,
nothing prevents the VM object from being deallocated while still busy.

Fix the problem by unbusying the object before releasing the VM map
lock.  If vm_fault_soft_fast() fails to create a mapping, the VM map
lock is not released, so those cases don't need to change.

Reported by: syzkaller
Reviewed by: kib (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38527

(cherry picked from commit d0991948182a1a149ee84f1b9c4d3e30450c8f0b)

15 months agonetlink: fix NOINET6 build.
Alexander V. Chernikov [Fri, 24 Feb 2023 10:19:12 +0000 (10:19 +0000)]
netlink: fix NOINET6 build.

Reported by: Michael Paepcke <bugs.fbsd@paepcke.de>
PR: 269787
MFC after: 3 days

(cherry picked from commit efeb8003117073d29bf82c8a69e036b8dbd78352)

15 months agonetlink: fix addition of blackhole/reject routes.
Alexander V. Chernikov [Thu, 23 Feb 2023 17:38:18 +0000 (17:38 +0000)]
netlink: fix addition of blackhole/reject routes.

* Make nhop_set_blackhole() set all necessary properties for the
 nexthop
* Make nexthops blackhole/reject based on the rtm_type netlink
 property instead of using rtflags.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit d2deebe21b591336fbd8915b37d409b25da54d4d)

15 months agoUpdate leap-seconds to latest leap-seconds.3676924800 (expires 2023-12-28)
Dimitry Andric [Fri, 24 Feb 2023 12:17:16 +0000 (13:17 +0100)]
Update leap-seconds to latest leap-seconds.3676924800 (expires 2023-12-28)

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

(cherry picked from commit df2fbbfa71b8ecc9e9e75ce85a635aade9c691cb)

15 months agoarm ti: Fix a typo in a kernel message
Gordon Bergling [Wed, 22 Feb 2023 08:43:49 +0000 (09:43 +0100)]
arm ti: Fix a typo in a kernel message

- s/adress/address/

(cherry picked from commit 49bf65be44adc3fbcc64a672530e52afb5cf5555)

15 months agoctf: Remove unused function prototype for getpname()
Zhenlei Huang [Sun, 26 Feb 2023 04:18:25 +0000 (12:18 +0800)]
ctf: Remove unused function prototype for getpname()

This function prototype should have been removed along with the
implementation.

Fixes: 3dd552426409 ctfdump: Use getprogname()
MFC after: 1 day

(cherry picked from commit f8e1aa85fed08d5f689cb36d65a76d191f6500dd)

15 months agoMFC: ARM release build: enable IPv6 SLAAC by default
Joerg Wunsch [Sun, 12 Feb 2023 21:26:52 +0000 (22:26 +0100)]
MFC: ARM release build: enable IPv6 SLAAC by default

When building ARM release images, enable IPv6 SLAAC by default in
addition to IPv4 DHCP.

Unlike amd64 (and other desktop/server) releases, ARM releases on SoC
setups are usually deployed by just using the installation image, so
there is no interactive network configuration. Not having IPv6
included by default is kind of an anachronism these days, given that
FreeBSD with the KAME project once pioneered IPv6 technology.

(cherry picked from commit 57228a49333505aebbc992f3799819667630f255)

15 months agolinux(4): Fixup the interface name translation in netlink
Dmitry Chagin [Thu, 23 Feb 2023 08:01:18 +0000 (11:01 +0300)]
linux(4): Fixup the interface name translation in netlink

Netlink should translate a FreeBSD interface name to a Linux
interface name.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38715
MFC after: 3 days

(cherry picked from commit e55e4a6ba3f4cd31d47b74574ea7370d5ab14b48)

15 months agolinux(4): Consolidate a FreeBSD interface names translation code
Dmitry Chagin [Thu, 23 Feb 2023 08:00:29 +0000 (11:00 +0300)]
linux(4): Consolidate a FreeBSD interface names translation code

We have some amount of interface names translation functions which are
differs by bugs implementation. Consolidates it in a one place.

Fixup loopback interface names translation and use ifnet methods and
accessors, where possible.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38714
MFC after: 3 days
X-MFC with: 32fdc75fe7

(cherry picked from commit 3ab3c9c29cf0e5df8dbbaaf2003456445534bad8)

15 months agolinux(4): Use predefined constant instead of hardcoded value
Dmitry Chagin [Thu, 23 Feb 2023 07:59:34 +0000 (10:59 +0300)]
linux(4): Use predefined constant instead of hardcoded value

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38713
MFC after: 3 days

(cherry picked from commit 200fe6e3a0c8f2fc4fb8f48abd6528418a8a370c)

15 months agolinux(4): Move use_real_names knob to the linux.c
Dmitry Chagin [Tue, 14 Feb 2023 14:46:32 +0000 (17:46 +0300)]
linux(4): Move use_real_names knob to the linux.c

MI linux.[c|h] are the module independent in terms of the Linux emulation
layer (ie, intended for both ISA - 32 & 64 bit), analogue of MD linux.h.
There must be a code here that cannot be placed into the corresponding by
common sense MI source and header files, i.e., code is machine independent,
but ISA dependent.
For the use_real_names knob, the code must be placed into the
linux_socket.[c|h], however linux_socket is ISA dependent.

MFC after: 2 weeks

(cherry picked from commit 32fdc75fe7276083d446964055b0de0e29970b7c)

15 months agolinux(4): Get rid of the opt_compat.h include.
Dmitry Chagin [Sun, 12 Feb 2023 17:24:32 +0000 (20:24 +0300)]
linux(4): Get rid of the opt_compat.h include.

Since e013e369 COMPAT_LINUX, COMPAT_LINUX32 build options are removed,
so include of opt_compat.h is no more needed.

MFC after: 2 weeks

(cherry picked from commit 10d16789a383a5b9e007dfd4c2e7844e044eaf7d)

15 months agomodules: Add missing opt_*.h files for stand-alone compile
Warner Losh [Sat, 29 Oct 2022 14:49:20 +0000 (08:49 -0600)]
modules: Add missing opt_*.h files for stand-alone compile

Standalone compile that we at least create these opt_*.h files.

Sponsored by: Netflix

(cherry picked from commit 010175a76d0676ff8d9b8d54276aff093abbc3f2)

15 months agoctfdump: Use getprogname()
Zhenlei Huang [Thu, 23 Feb 2023 16:28:35 +0000 (00:28 +0800)]
ctfdump: Use getprogname()

Also remove no longer used function `getpname()`.

Reviewed by: markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38740

(cherry picked from commit 3dd5524264095ed8612c28908e13f80668eff2f9)

15 months agokern/sysv_ipc.c: use ANSI C function definition
Konstantin Belousov [Tue, 21 Feb 2023 14:00:22 +0000 (16:00 +0200)]
kern/sysv_ipc.c: use ANSI C function definition

(cherry picked from commit 836e4b371b6eacc8a7e14cdf30fbced59c343455)

15 months agonetlink: clear IPv6 embedded scope when dumping route gateways.
Alexander V. Chernikov [Tue, 21 Feb 2023 12:25:58 +0000 (12:25 +0000)]
netlink: clear IPv6 embedded scope when dumping route gateways.

Reported by: zarychtam@plan-b.pwste.edu.pl
MFC after: 3 days

(cherry picked from commit b9b2184322da85e1f4d52e3b0a6322dd214210ec)

15 months agonetlink: fix IPv6 route addition with link-local gateway
Alexander V. Chernikov [Mon, 20 Feb 2023 14:24:01 +0000 (14:24 +0000)]
netlink: fix IPv6 route addition with link-local gateway

Currently kernel assumes that IPv6 gateway address is in "embedded"
 form - that is, for the link-local IPv6 addresses, interface index
 is embedded in bytes 2 and 3 of the address.
Fix address embedding in netlink by wrapping nhop_set_gw() in the
 netlink-specific nl_set_nexthop_gw(), which does such embedding
 automatically.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit c7c348162101a70b1f99299578dabe1d3b100e48)

15 months agotesting: handling non-root users with VNETs in pytest-based tests.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:31:34 +0000 (14:31 +0000)]
testing: handling non-root users with VNETs in pytest-based tests.

Currently isolation and resource requirements are handled directly
 by the kyua runner, based on the requirements specified by the test.
It works well for simple tests, but may cause discrepancy with tests
 doing complex pre-setups. For example, all tests that perform
 VNET setups require root access to properly function.

This change adds additional handling of the "require_user" property
 within the python testing framework. Specifically, it requests
 root access if the test class signals its root requirements and
 drops privileges to the desired user after performing the pre-setup.

Differential Revision: https://reviews.freebsd.org/D37923
MFC after: 2 weeks

(cherry picked from commit 6332ef8941999b0c074d1ece0e1e108447c70b98)

15 months agonetlink: fix style(9) after c3d3f3594fdf.
Alexander V. Chernikov [Fri, 24 Feb 2023 10:37:51 +0000 (10:37 +0000)]
netlink: fix style(9) after c3d3f3594fdf.

No functional changes.

Reported by: karels

15 months agonetlink: Fix "version introduced" documentation.
Tom Hukins [Fri, 24 Feb 2023 10:25:35 +0000 (10:25 +0000)]
netlink: Fix "version introduced" documentation.

netlink(4) and associated features will exist in FreeBSD 14.0 but they
will also exist in 13.2, an older version, from commits such as 02b958b
and b309249.

Pull Request: #651
MFC after: 1 day

15 months agonproc: denote an incompatiblity with Linux
Mateusz Guzik [Wed, 15 Feb 2023 20:17:27 +0000 (20:17 +0000)]
nproc: denote an incompatiblity with Linux

On Linux _NPROCESSORS_CONF reports CPU threads disabled by the kernel,
while it does not on FreeBSD.

Flip _NPROCESSORS_ONLN to _NPROCESSORS_CONF. While it keeps reporting
the same value, it will automagically unbreak should someone change the
above.

(cherry picked from commit 059320b8c8de73a90514879cd1e2da397584cfde)

15 months agoAdd nproc(1)
Mateusz Guzik [Sat, 4 Feb 2023 23:33:48 +0000 (23:33 +0000)]
Add nproc(1)

This program prints the number of CPU threads it can run on, while
respecting cpusets (or not, depending on switches).

It aims to be compatible with nproc as found in GNU coreutils.

Reviewed by: des
Reviewed by: pstef
Differential Revision: https://reviews.freebsd.org/D38386

(cherry picked from commit 48bfd3597654490cdc43bf0f591a539d3a28b590)

15 months agovmm: Fix AP startup compatibility for old bhyve executables
Mark Johnston [Thu, 9 Feb 2023 20:52:35 +0000 (15:52 -0500)]
vmm: Fix AP startup compatibility for old bhyve executables

These changes unbreak AP startup when using a 13.1-RELEASE bhyve
executable with a newer kernel:
- Correct the destination mask for the VM_EXITCODE_IPI message generated
  by an INIT or STARTUP IPI in vlapic_icrlo_write_handler().
- Only initialize vlapics on active vCPUs.  13.1-RELEASE bhyve activates
  AP vCPUs only after the BSP starts them with an IPI, and vmm now
  allocates vcpu structures lazily, so the STARTUP handling in
  vm_handle_ipi() could trigger a page fault.
- Fix an off-by-one setting the vcpuid in a VM_EXITCODE_SPINUP_AP
  message.

Fixes: 7c326ab5bb9a ("vmm: don't lock a mtx in the icr_low write handler")
Reviewed by: jhb, corvink
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38446

(cherry picked from commit b265a2e0d76422f4007e96dd7295ed0aeb846e2d)

15 months agoMFV: zlib 1.2.13.
Xin LI [Fri, 17 Feb 2023 07:57:24 +0000 (23:57 -0800)]
MFV: zlib 1.2.13.

Relnotes: yes

(cherry picked from commit e37bb444aa945ed0725766e986698a09bd61b1b2)

15 months agohastd and hastctl: use zlib's crc32 implementation.
Xin LI [Fri, 3 Feb 2023 07:14:21 +0000 (23:14 -0800)]
hastd and hastctl: use zlib's crc32 implementation.

(cherry picked from commit 6998572a74a98721781ecd5b6829435259f9825a)
(cherry picked from commit fdbfaefefa585537273955fc88d7daf5e86c6f2d)

15 months agoe1000: Fix packet loss on 11th gen and later
Kevin Bowling [Thu, 9 Feb 2023 00:32:54 +0000 (17:32 -0700)]
e1000: Fix packet loss on 11th gen and later

Ungate DMA clock on TGP and later to avoid packet loss.

A similar fix appears in Linux 639e298f432fb058a9496ea16863f53b1ce935fe

This may be needed as far back as SPT but no confirmation from intel or
other OS yet.

Obtained from: OpenBSD (if_em_hw.c 1.116)
Sponsored by: BBOX.io

(cherry picked from commit 56365902147791994157c3a8f75784dafd46dbd8)

15 months agoe1000: Add support for future client platforms
Kevin Bowling [Thu, 9 Feb 2023 01:14:41 +0000 (18:14 -0700)]
e1000: Add support for future client platforms

Sponsored by: BBOX.io

(cherry picked from commit 905ae5881bdc1b9742e08d660d787204c08d6022)

15 months agoe1000: Remove redundant disable_ulp for ich8lan
Kevin Bowling [Wed, 8 Feb 2023 23:17:03 +0000 (16:17 -0700)]
e1000: Remove redundant disable_ulp for ich8lan

This call only makes sense for ich8lan, and the shared code does it in
e1000_setup_init_funcs() above this deletion.

Obtained from: DPDK
Sponsored by: BBOX.io
Pull Request: https://github.com/freebsd/freebsd-src/pull/539

(cherry picked from commit d36fbdb08ff567393a698aaf16f726275901ec96)

15 months ago.github: Attempt to fix and increase robustness of macOS action
Jessica Clarke [Thu, 30 Jun 2022 20:03:26 +0000 (21:03 +0100)]
.github: Attempt to fix and increase robustness of macOS action

Homebrew has added LLVM 14 and made that the default version, but GitHub
continues to install LLVM 13 for now, so it ends up only accessible via
the versioned name and not the unversioned one. We also add an explicit
installation of llvm@13 so that, if GitHub updates the image to using
LLVM 14, the action continues to work, albeit slightly more slowly. This
also ensures the compiler label remains correct rather than outdated, as
has occurred in the past, and that we don't get new versions of LLVM
before we're ready for them, which is especially relevant for stable
branches. This all mirrors how the Ubuntu jobs are configured.

(cherry picked from commit 22f731486e80fdbf679712b2a99605ba97a50264)

15 months ago.github: Restrict permissions on cross-build jobs.
Alex [Thu, 9 Feb 2023 20:12:17 +0000 (12:12 -0800)]
.github: Restrict permissions on cross-build jobs.

(cherry picked from commit aca7ff471acffb59f0f9e2cc4de6363872444fcc)

15 months agoccr,ccp: Fix argument order to sglist_append_vmpages.
John Baldwin [Mon, 6 Feb 2023 21:51:57 +0000 (13:51 -0800)]
ccr,ccp: Fix argument order to sglist_append_vmpages.

The offset comes before the byte count.

Reported by: br
Reviewed by: asomers, markj
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D38375

(cherry picked from commit 70efe1a2fe13642732e56c7f040fe63f62bc6a6b)

15 months ago.github: Switch to v3 of actions/checkout.
John Baldwin [Wed, 21 Dec 2022 00:27:17 +0000 (16:27 -0800)]
.github: Switch to v3 of actions/checkout.

GitHub is emitting a warning that v2 is deprecated due to using
Node.js 12.

Reported by: GitHub
Reviewed by: arichardson, emaste
Differential Revision: https://reviews.freebsd.org/D37769

(cherry picked from commit 54f3a781a2ff980034dfe13ff6323c96fc587f1b)

15 months agoptrace.2: Fix warnings from igor.
John Baldwin [Thu, 15 Dec 2022 19:25:27 +0000 (11:25 -0800)]
ptrace.2: Fix warnings from igor.

Reviewed by: pauamma, imp
Differential Revision: https://reviews.freebsd.org/D37689

(cherry picked from commit 120eff994aeb31671c144a1835c62d9d8789a5a0)

15 months agorc.d/*: Use startmsg instead of echo on start messages
Jose Luis Duran [Sun, 13 Mar 2022 17:54:39 +0000 (18:54 +0100)]
rc.d/*: Use startmsg instead of echo on start messages

By rc.conf(5), setting rc_startmsgs="NO" should silence start messages.

Fix a few rc scripts by using startmsg.

PR: 255207
Reported by: Jose Luis Duran <jlduran@gmail.com>
Reviewed by: imp, 0mp
Approved by: imp (src)
Differential Revision: https://reviews.freebsd.org/D34514

(cherry picked from commit 19a6267d61a0c3bd6cd56f19ca3f8a67a54f675c)

15 months agoIntroduce startmsg and use it in rc scripts
Jose Luis Duran [Sun, 13 Mar 2022 17:48:06 +0000 (18:48 +0100)]
Introduce startmsg and use it in rc scripts

startmsg is a new rc.subr(8) function function to be used instead of
echo(1) when for boot messages. It replaces the often forgotten

    check_startmsgs && echo ...

with

    startmsg ...

No functional change intended.

I adjusted the commit message and did some final clean-ups of the patch
before committing.

PR: 255207
Reported by: Jose Luis Duran <jlduran@gmail.com>
Reviewed by: imp, 0mp
Approved by: imp (src)
Differential Revision: https://reviews.freebsd.org/D34514

(cherry picked from commit 325ebf37d8efc6488754051fcc2b1aaa40cefd8b)

15 months agoe1000: bump driver version
Kevin Bowling [Wed, 8 Feb 2023 19:25:58 +0000 (12:25 -0700)]
e1000: bump driver version

Incrementing these to avoid confusion in users; we are on par with these
out of tree versions.

Reviewed by: erj
Sponsored by: BBOX.io
Pull Request: https://github.com/freebsd/freebsd-src/pull/540

(cherry picked from commit 647f2d2bc0cb9357ac083bf2aae4b669167dd66b)

15 months agoe1000: fix I219 hang on reset
Kevin Bowling [Wed, 8 Feb 2023 19:21:45 +0000 (12:21 -0700)]
e1000: fix I219 hang on reset

Clear the rings before reset to avoid a HW hang.

Inspired by em-7.7.8 and DPDK (1fc9701238edcf0541289b9ae15565b6d9d7ab30)

Reviewed by: erj
Sponsored by: BBOX.io
Pull Request: https://github.com/freebsd/freebsd-src/pull/540

(cherry picked from commit ae1dca798e0f826de46f4ec11914ba4c91928d7a)

15 months agonfscl: Fix interaction between mmap'd and VOP_WRITE file updates
Rick Macklem [Wed, 8 Feb 2023 22:25:01 +0000 (14:25 -0800)]
nfscl: Fix interaction between mmap'd and VOP_WRITE file updates

asomers@ found a problem with the NFS client, where a write to
an NFS mounted file done via mmap(2) was lost when fspacectl(2)
was done before it.  This turned out to be caused by clearing the
dirty bit on pages when the client was doing commit RPCs,
due to the second argument to vfs_busy_pages() being set to 1.
Commit RPCs tell the server to commit previously written data to
stable storage.  However, Commit RPCs do not write data from the
client to the server.  As such, if the dirty bit on the page has
been set by a mmap'd write to an address in the page, it should
not be cleared.  Clearing it causes the mmap'd write to by lost.

This patch fixes the problem by changing the 2nd argument to
vfs_busy_pages() to 0 for this case.

I doubt this bug has affected many, since it was inherited from
the old NFS client and was in 4.3 FreeBSD twenty years ago.
Although fspacectl(2) is FreeBSD 14 specific, a write(2) would
cause the same failure.

PR: 269328

(cherry picked from commit 847967bc4e198a258b030a5864e64e029e7452e5)

15 months agoFix per-jail zfs.mount_snapshot setting
Allan Jude [Sat, 18 Feb 2023 01:44:34 +0000 (01:44 +0000)]
Fix per-jail zfs.mount_snapshot setting

When jail.conf set the nopersist flag during startup, it was
incorrectly destroying the per-jail ZFS settings.

PR: 260160
Reported by: imp (previous version), mm (upstream), freqlabs (upstream)
MFC after: immediately
Sponsored by: Modirum MDPay
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38662

(cherry picked from commit 8b04c1cbfc1cb71a1ce53b3a7855f1d45866fcfb)

15 months agoixl(4): Fix MAC/VLAN filters accounting
Krzysztof Galazka [Wed, 15 Feb 2023 22:28:01 +0000 (14:28 -0800)]
ixl(4): Fix MAC/VLAN filters accounting

- Account for a filter required to enable reception of untagged frames
while registering and unregistering VLANs to avoid trying to add more
filters than HW supports

- While adding MAC/VLAN filters, pre-set matching method field in the
Admin Queue Command response buffer to expected error value to work
around an issue with some FW versions, which do not update that field if
operation fails, and be able correctly track which filters were
configured in HW.

- Remove unused IXL_MAX_FILTERS macro definition

- Update number of available MAC/VLAN filters as in newer FW versions it
was decreased by one.

- Simplify i40e_dma_mem structure

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: Gowtham Kumar Ks <gowtham.kumar.ks@intel.com>
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D37457

(cherry picked from commit 1d02c6b1b859e9f611bc8fe27ca3d2c16ec128c1)

15 months agoixgbe(4): Filter out spurious link up indication
Krzysztof Galazka [Wed, 15 Feb 2023 22:35:40 +0000 (14:35 -0800)]
ixgbe(4): Filter out spurious link up indication

Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: Gowtham Kumar Ks <gowtham.kumar.ks@intel.com>
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D38395

(cherry picked from commit 04a5e6d7cadd06b10169c3c3a560649e7dc7444c)

15 months agoBump __FreeBSD_version after linuxkpi changes.
Emmanuel Vadot [Tue, 21 Feb 2023 08:21:29 +0000 (09:21 +0100)]
Bump __FreeBSD_version after linuxkpi changes.

Needed to have graphics/drm-515-kmod working.

Sponsored by: Beckhoff Automation GmbH & Co. KG

15 months agolinuxkpi: Add more suspend defines
Emmanuel Vadot [Fri, 17 Feb 2023 13:49:52 +0000 (14:49 +0100)]
linuxkpi: Add more suspend defines

Needed by drm 5.15-lts

Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit a0fdaf9a7b34b6f8fdab747f7a198158e66b57ab)

15 months agollvm: make sure to use ELFv2 ABI on powerpc64
Piotr Kubaj [Thu, 16 Feb 2023 23:49:43 +0000 (00:49 +0100)]
llvm: make sure to use ELFv2 ABI on powerpc64

Currently LLVM is more or less set up to use ELFv2, but it still defaults to
ELFv1 in some places. This causes lld to generate broken binaries when used
with LTO.

PR: 269455
Approved by: dim
MFC after: 3 days

(cherry picked from commit a1ffc2fe9ce54a498c410dcab86495569dbaa7cc)

15 months agokern: physmem: improve region coalescing logic
Kyle Evans [Thu, 28 Oct 2021 04:40:08 +0000 (23:40 -0500)]
kern: physmem: improve region coalescing logic

The existing logic didn't take into account newly inserted mappings
wholly contained by an existing region (or vice versa), nor did it
account for weird overlap scenarios.  The latter is probably unlikely
to happen, but the former may happen in UEFI: BootServicesData allocated
within a large chunk of ConventionalMemory.  This situation blows up vm
initialization.

While we're here, remove the "exact match" logic as it's likely wrong;
if an exact match exists with conflicting flags, for instance, then we
should probably be doing something else.  The new logic takes into
account exact matches as part of the overlapping efforts.

Reviewed by: kib, mhorne (both earlier version)
Differential Revision: https://reviews.freebsd.org/D32701

(cherry picked from commit 7771f2a0c94fc2f7b9ce1565a49e52dba1e7381d)

15 months agocpuset: Adapt sched_affinity compat shims to the stable/13
Dmitry Chagin [Mon, 20 Feb 2023 17:28:36 +0000 (20:28 +0300)]
cpuset: Adapt sched_affinity compat shims to the stable/13

Use compat shims to run the stable/13 world on a kernels which
does not support CPU_WHICH_TIDPID.

This is direct commit to the stable/13.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38677

15 months agopcb: Move an assignment into in_pcbdisconnect()
Mark Johnston [Fri, 3 Feb 2023 15:57:37 +0000 (10:57 -0500)]
pcb: Move an assignment into in_pcbdisconnect()

All callers of in_pcbdisconnect() clear the local address, so let's just
do that in the function itself.

Note that the inp's local address is not a parameter to the inp hash
functions.  No functional change intended.

Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D38362

(cherry picked from commit 2589ec0f365777faacf36bd1eb24706538836b17)

15 months agoman4: Add a manual page for kvmclock
Mark Johnston [Fri, 3 Feb 2023 15:54:50 +0000 (10:54 -0500)]
man4: Add a manual page for kvmclock

Reviewed by: pauamma, imp, kib
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38343

(cherry picked from commit a2286a1f4651f9369cacb82bb1777920f5a86fdc)

15 months agopvclock: Export a vDSO page even without rdtscp available
Mark Johnston [Fri, 3 Feb 2023 15:54:23 +0000 (10:54 -0500)]
pvclock: Export a vDSO page even without rdtscp available

When the cycle counter is "stable", i.e., synchronized across vCPUs by
the hypervisor, userspace can use a serialized rdtsc instead of relying
on rdtscp, just like the kernel timecounter does.  This can be useful
for performance in guests where the hypervisor hides rdtscp for some
reason.

To avoid breaking compatibility with older userspace which expects
rdtscp to be usable when pvclock exports timekeeping info, hide this
feature behind a sysctl.

Reviewed by: kib
Tested by: Shrikanth R Kamath <kshrikanth@juniper.net>
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38342

(cherry picked from commit 2bed14192cec1abcdc4e02ca7b18dafd868095ef)

15 months agolibc: Fall back to rdtsc when using pvclock and rdtscp is not available
Mark Johnston [Fri, 3 Feb 2023 15:53:20 +0000 (10:53 -0500)]
libc: Fall back to rdtsc when using pvclock and rdtscp is not available

In preparation for a follow-up revision wherein kvmclock may export
timekeeping info to userspace even in the absence of AMDID_RDTSCP, fall
back to using rdtsc when rdtscp isn't available.  This mimics
pvclock_read_time_info() in the kernel.

Reviewed by: kib
Tested by: Shrikanth R Kamath <kshrikanth@juniper.net>
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38341

(cherry picked from commit 26d105199ec89d6eaec8a9ca70e3b05ca65e3aac)

15 months agoshm: Document shm_create_largepage()
Mark Johnston [Fri, 3 Feb 2023 15:55:30 +0000 (10:55 -0500)]
shm: Document shm_create_largepage()

While here, move notes about FreeBSD-specific functionality to the
COMPATIBILITY section, and document the ECAPMODE error for shm_open().

Reviewed by: pauamma, kib
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38282

(cherry picked from commit 5f03f96fbefbb5c68a5d7d06728ff5b4a05f87b0)

15 months agolua: reduce diffs between luaconf.h copies
Ed Maste [Mon, 20 Feb 2023 16:19:35 +0000 (09:19 -0700)]
lua: reduce diffs between luaconf.h copies

Upstream luaconf.h is contrib/lua/src/luaconf.h.dist, while userland lua
and loader lua have copies in lib/liblua/luaconf.h and
stand/liblua/luaconf.h.

Adjust whitespace, VCS tags, etc. to match upstream's version, for ease
of comparison.

Reviewed By: imp
Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38206

(cherry picked from commit ec965063070e5753c166cf592c9336444b74720a)

15 months agostand: Update mfc notes
Warner Losh [Mon, 20 Feb 2023 16:09:07 +0000 (09:09 -0700)]
stand: Update mfc notes

Using some automation I found a few mistakes in my earlier list and also
a change merged without a cherry-pick -x (and evidentally changed as
well, since git log --cherry didn't know it had been merged). Fix them
so I can use this list with my experimental mfc script.

Sponsored by: Netflix

This is a direct commit to stable/13

15 months agond6: fix panic in lltable_drop_entry_queue()
Alexander V. Chernikov [Sun, 15 Jan 2023 15:10:48 +0000 (15:10 +0000)]
nd6: fix panic in lltable_drop_entry_queue()

nd6_resolve_slow() can be called without mbuf. If the LLE entry
 is not reachable, nd6_resolve_slow() will add this NULL mbuf to
 the holdchain via lltable_append_entry_queue, which will "append"
 NULL to the end of the queue (effectively no-op) and bump la_numhold
 value. When this entry gets freed, the kernel will panic due to the
 inconsistency between the amount of mbufs in the queue and the value
 of la_numhold.

Fix the panic by checking of mbuf is not NULL prior to inserting it
 into the holdchain.

Reported by: kib
MFC after: 3 days

(cherry picked from commit 6468b6b23e08d9bd02c8cb74ec0ff389ed74c3bb)

15 months agonetinet6: Fix mbuf leak in NDP
Arseny Smalyuk [Tue, 31 May 2022 20:04:51 +0000 (20:04 +0000)]
netinet6: Fix mbuf leak in NDP

Mbufs leak when manually removing incomplete NDP records with pending packet via ndp -d.
It happens because lltable_drop_entry_queue() rely on `la_numheld`
counter when dropping NDP entries (lles). It turned out NDP code never
increased `la_numheld`, so the actual free never happened.

Fix the issue by introducing unified lltable_append_entry_queue(),
common for both ARP and NDP code, properly addressing packet queue
maintenance.

Reviewed By: melifaro
Differential Revision: https://reviews.freebsd.org/D35365
MFC after: 2 weeks

(cherry picked from commit d18b4bec98f1cf3c51103a22c0c041e6238c44c7)

15 months agonetlink: fix OOB read in genetlink
Alexander V. Chernikov [Sat, 18 Feb 2023 17:24:59 +0000 (17:24 +0000)]
netlink: fix OOB read in genetlink

CID: 1498863
MFC after: 1 day

(cherry picked from commit 8f7455a9265f4952f885b06c08c57fcce6f16e5c)

15 months agonetlink: simplify temporary address allocation in rtnl_handle_getlink().
Alexander V. Chernikov [Fri, 17 Feb 2023 17:57:44 +0000 (17:57 +0000)]
netlink: simplify temporary address allocation in rtnl_handle_getlink().

MFC after: 3 days

(cherry picked from commit 45356a1864c79680c6911b48a18b14a88a7d07fa)

15 months agonetlink: fix interface dump.
Alexander V. Chernikov [Thu, 16 Feb 2023 13:17:58 +0000 (13:17 +0000)]
netlink: fix interface dump.

The current code missed interface addition when reallocating
 temporary buffer.
Tweak the code to perform the reallocation first and add
 interface afterwards unconditionally.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit 86fd0bdba540132ae298457e160b651f61d1db6b)

15 months agofibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail.
Alexander V. Chernikov [Sat, 11 Feb 2023 15:43:23 +0000 (15:43 +0000)]
fibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail.

Reported by: olivier
Tested by: olivier
Reviewed by: kp, glebius
Differential Revision: https://reviews.freebsd.org/D38505
MFC after: 1 week

(cherry picked from commit 69e7d9b7e6b369b760e1f189af2e25587b56a102)

15 months agonetlink: return optional metadata with the operation result.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:53:44 +0000 (14:53 +0000)]
netlink: return optional metadata with the operation result.

Some operations like interface creation may need to return metadata
 - in this case, interface name - back to the caller if the operation
 is successful.
This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the
operation reply message via `nlmsg_report_cookie()`.
Additionally, on successful interface creation, interface index and
 interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME
 TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38283
MFC after: 1 week

(cherry picked from commit 25c2dd2f2c6c6144d59d463c95f0471301d6efaa)

15 months agonetlink: call genetlink notification handler upon successful family
Alexander V. Chernikov [Fri, 17 Feb 2023 17:58:53 +0000 (17:58 +0000)]
netlink: call genetlink notification handler upon successful family
search.

MFC after: 3 days

(cherry picked from commit 7cbe771f013f6cf3316910648f6d46641cad7f44)

15 months agocleanvar: Be more careful when cleaning up /var.
Xin LI [Mon, 13 Feb 2023 04:56:17 +0000 (20:56 -0800)]
cleanvar: Be more careful when cleaning up /var.

The cleanvar script uses find -delete to remove stale files under /var,
which could lead to unwanted removal of files in some unusual scenarios.
For example, when a mounted fdescfs(5) is present under /var/run/samba/fd,
find(1) could descend into a directory that is out of /var/run and remove
files that should not be removed.

To mitigate this, modify the script to use find -x, which restricts the
find scope to one file system only instead of descending into mounted
file systems.

PR: 269213

(cherry picked from commit 39e8c2a29a860bdb69ffcfbc06de4d4ad103b458)