]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoUse an unsigned 64-bit integer for exception class.
John Baldwin [Thu, 27 Jan 2022 18:34:35 +0000 (10:34 -0800)]
Use an unsigned 64-bit integer for exception class.

This matches the type in other unwind headers (LLVM libunwind,
libcxxrt, glibc).

NB: include/unwind.h is not installed but is only used by libthr

Reviewed by: imp, dim, emaste
Differential Revision: https://reviews.freebsd.org/D34049

2 years agotcp: Tidying up the conditionals for unwinding a spurious RTO
Richard Scheffenegger [Thu, 27 Jan 2022 17:59:21 +0000 (18:59 +0100)]
tcp: Tidying up the conditionals for unwinding a spurious RTO

- Use the semantically correct TSTMP_xx macro when comparing
  timestamps. (No functional change)
- check for bad retransmits only when TSopt is present in ACK
  (don't assume there will be a valid TSopt in the TCP options struct)
- exclude tsecr == 0, since that most likely indicates an
  invalid ts echo return (tsecr) value.

Reviewed By: tuexen, #transport
MFC after:   3 days
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D34062

2 years agotcp: Rewind erraneous RTO only while performing RTO retransmissions
Richard Scheffenegger [Thu, 27 Jan 2022 17:35:47 +0000 (18:35 +0100)]
tcp: Rewind erraneous RTO only while performing RTO retransmissions

Under rare circumstances, a spurious retranmission is
incorrectly detected and rewound, messing up various tcpcb values,
which can lead to a panic when SACK is in use.

Reviewed By: tuexen, chengc_netapp.com, #transport
MFC after:   3 days
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D33979

2 years agocp: fix some cases with infinite recursion
Kyle Evans [Thu, 27 Jan 2022 18:02:17 +0000 (12:02 -0600)]
cp: fix some cases with infinite recursion

As noted in the PR, cp -R has some surprising behavior.  Typically, when
you `cp -R foo bar` where both foo and bar exist, foo is cleanly copied
to foo/bar.  When you `cp -R foo foo` (where foo clearly exists), cp(1)
goes a little off the rails as it creates foo/foo, then discovers that
and creates foo/foo/foo, so on and so forth, until it eventually fails.

POSIX doesn't seem to disallow this behavior, but it isn't very useful.
GNU cp(1) will detect the recursion and squash it, but emit a message in
the process that it has done so.

This change seemingly follows the GNU behavior, but it currently doesn't
warn about the situation -- the author feels that the final product is
about what one might expect from doing this and thus, doesn't need a
warning.  The author doesn't feel strongly about this.

PR: 235438
Reviewed by: bapt
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D33944

2 years agortsock: always set m_pkthdr.rcvif when queueing on netisr
Gleb Smirnoff [Thu, 27 Jan 2022 17:41:31 +0000 (09:41 -0800)]
rtsock: always set m_pkthdr.rcvif when queueing on netisr

netisr uses global workstreams and after dequeueing an mbuf it
uses rcvif to get the VNET of the mbuf.  Of course, this is not
needed when kernel is compiled without VIMAGE.  It came out that
routing socket does not set rcvif if compiled without VIMAGE.
Make this assignment not depending on VIMAGE option.

Fixes: 6871de9363e5

2 years agombuf: make M_ASSERT_NO_SND_TAG() as strict as other similar asserts
Gleb Smirnoff [Thu, 27 Jan 2022 17:41:31 +0000 (09:41 -0800)]
mbuf: make M_ASSERT_NO_SND_TAG() as strict as other similar asserts

Fixes: 17cbcf33c3b6

2 years agoRemove SMALL conditionals from gzip
Tom Jones [Thu, 27 Jan 2022 17:24:45 +0000 (17:24 +0000)]
Remove SMALL conditionals from gzip

gzip has SMALL conditionals which enable building a reduced size version
of the binary. These exist as part of the introduction of BSD licensed
gzip in 2004 in NetBSD and appear to have been required to reach a size
for inclusion in their install media. For more information see commits
to gzip in the NetBSD tree on the 28th of March 2004.

SMALL doesn't appear to be hooked up to our build system and
complicates gzip quite a bit.

Reviewed by: kevans, imp
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34047

2 years agotests: fix posix_spawnp_enoexec_fallback_null_argv0
Kyle Evans [Thu, 27 Jan 2022 17:22:49 +0000 (11:22 -0600)]
tests: fix posix_spawnp_enoexec_fallback_null_argv0

This test was written because execvp was found to improperly handle the
argc == 0 case when it falls back from an ENOEXEC.  We could probably
mostly revert it now, but let's just fix the test for the time being and
circle back later to decide if we want to simplify execvp.  The test
will likely remain either way just to make sure execvp isn't working
around the newly enforced restriction with the fallback.

Fixes: 301cb491ea41 ("execvp: fix up the ENOEXEC fallback")
Reported by: jenkins via lwhsu@

2 years agoFix test output when gzip is run with -tlv
Tom Jones [Thu, 27 Jan 2022 17:17:13 +0000 (17:17 +0000)]
Fix test output when gzip is run with -tlv

When run with test, verbose and list we need to parse the file otherwise
the test output is "NOT OK" even for the file is valid.

Reviewed by: kevans, allanjude, imp
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34046

2 years agobsdinstall: Add quotes around error message argument
Tom Jones [Thu, 27 Jan 2022 17:10:06 +0000 (17:10 +0000)]
bsdinstall: Add quotes around error message argument

When error is called with a message with spaces (and probably multiple
lines) these are passed into dialog unquoted and an error message was
presented, wrap with quotes.

Reviewed by: bapt, allanjude
Sponsored by:   Ampere Computing LLC
Sponsored by:   Klara Inc.
Differential Revision: https://reviews.freebsd.org/D33918

2 years agommc_da: create disk(9) for pre-2.0 SD cards
Andriy Gapon [Thu, 27 Jan 2022 16:49:27 +0000 (18:49 +0200)]
mmc_da: create disk(9) for pre-2.0 SD cards

It does not look like there is anything in mmc_da code that actually
requires protocol 2.0 or later.  dev/mmc code also does not have such a
restriction.

Tested with a very old 2GB mini-SD card.  Prior to this change mmc_da
would claim the card but would not expose it to GEOM.

Without MMCCAM:
 mmc0: <MMC/SD bus> on sdhci_pci0
 mmc0: Probing bus
 mmc0: SD probe: OK (OCR: 0x00ff8000)
 mmc0: Current OCR: 0x00ff8000
 mmc0: CMD8 failed, RESULT: 1
 mmc0: Probing cards
 mmc0: New card detected (CID 1c53565344432020100002982e007600)
 mmc0: New card detected (CSD 005e00325f5a83d02db7ffbf96800000)
 mmc0: Card at relative address 0xb368 added:
 mmc0:  card: SD SDC   1.0 SN 0002982E MFG 06/2007 by 28 SV
 mmc0:  quirks: 0
 mmc0:  bus: 4bit, 50MHz (high speed timing)
 mmc0:  memory: 3998720 blocks, erase sector 256 blocks
 mmc0: setting transfer rate to 50.000MHz (high speed timing)
 GEOM: new disk mmcsd0
 mmcsd0: 2GB <SD SDC   1.0 SN 0002982E MFG 06/2007 by 28 SV> at mmc0 50.0MHz/4bit/65535-block
 mmc0: setting bus width to 4 bits high speed timing

With MMCCAM and this change:
 sdda0 at sdhci_slot0 bus 0 scbus2 target 0 lun 0
 sdda0: Relative addr: 0000b368
 Card features: <Memory>
 sdda0: Serial Number 0002982E
 sdda0: SD SDC   1.0 SN 0002982E MFG 06/2007 by 28 SV
 GEOM: new disk sdda0

Reviewed by: manu
MFC after: 3 weeks

2 years agoRevert b58ca5df0bb7 ("vfs: remove the now unused insmntque1")
Mateusz Guzik [Thu, 27 Jan 2022 16:24:32 +0000 (16:24 +0000)]
Revert b58ca5df0bb7 ("vfs: remove the now unused insmntque1")

I was somehow convinced that insmntque calls insmntque1 with a NULL
destructor. Unfortunately this worked well enough to not immediately
blow up in simple testing.

Keep not using the destructor in previously patched filesystems though
as it avoids unnecessary casts.

Noted by: kib
Reported by: pho

2 years agotcp: fix leaks in tcp_chg_pacing_rate error paths
Andrew Gallatin [Thu, 27 Jan 2022 15:35:03 +0000 (10:35 -0500)]
tcp: fix leaks in tcp_chg_pacing_rate error paths

tcp_chg_pacing_rate() is expected to release the hw rate limit table,
but failed to do so in several error cases, leading to ever
increasing counts of flows using the rate.

This patch was mostly done by rrs

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D34058
Reviewed by: hselasky, rrs,  jhb (inital version, outside of Differential)

2 years agoFix a memory leak when ip_output_send() returns EAGAIN due to send tag issues
Andrew Gallatin [Thu, 27 Jan 2022 15:28:15 +0000 (10:28 -0500)]
Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues

When ip_output_send() returns EAGAIN due to issues with send tags (route
change, lagg failover, etc), it must free the mbuf. This is because
ip_output_send() was written as a wrapper/replacement for a direct
call to  if_output(), and the contract with if_output() has
historically been that it owns the mbufs once called. When
ip_output_send() failed to free mbufs, it violated this assumption
and lead to leaked mbufs.

This was noticed when using NIC TLS in combination with hardware
rate-limited connections. When seeing lots of NIC output drops
triggered ratelimit send tag changes, we noticed we were leaking
ktls_sessions, send tags and mbufs. This was due ip_output_send()
leaking mbufs which held references to ktls_sessions, which in
turn held references to send tags.

Many thanks to jbh, rrs, hselasky and markj for their help in
debugging this.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D34054
Reviewed by: hselasky, jhb, rrs
MFC after: 2 weeks

2 years agogeom: Assert that BIO_SPEEDUP BIOs have bio_data set to NULL
Mark Johnston [Thu, 27 Jan 2022 14:58:19 +0000 (09:58 -0500)]
geom: Assert that BIO_SPEEDUP BIOs have bio_data set to NULL

Like BIO_FLUSH, there is no reason for consumers to pass a BIO_SPEEDUP
request with non-NULL bio_data, so assert this.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agoshsec: Allocate data blocks only for BIO_READ/WRITE requests
Mark Johnston [Thu, 27 Jan 2022 14:53:02 +0000 (09:53 -0500)]
shsec: Allocate data blocks only for BIO_READ/WRITE requests

In particular, there is no need to allocate a data block when passing
BIO_FLUSH requests to child providers, and g_io_request() asserts that
bp->bio_data == NULL for such requests.

PR: 255131
Reported and tested by: nvass@gmx.com
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agoAdd PT_GETREGSET
Andrew Turner [Mon, 24 Jan 2022 11:24:17 +0000 (11:24 +0000)]
Add PT_GETREGSET

This adds the PT_GETREGSET and PT_SETREGSET ptrace types. These can be
used to access all the registers from a specified core dump note type.
The NT_PRSTATUS and NT_FPREGSET notes are initially supported. Other
machine-dependant types are expected to be added in the future.

The ptrace addr points to a struct iovec pointing at memory to hold the
registers along with its length. On success the length in the iovec is
updated to tell userspace the actual length the kernel wrote or, if the
base address is NULL, the length the kernel would have written.

Because the data field is an int the arguments are backwards when
compared to the Linux PTRACE_GETREGSET call.

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

2 years agog_mirror: don't fail reads while losing next-to-last disk
Andriy Gapon [Thu, 27 Jan 2022 10:49:04 +0000 (12:49 +0200)]
g_mirror: don't fail reads while losing next-to-last disk

I observed a situation where some read requests failed when a 2-way geom
mirror lost one disk.  The problem appears to be in the logic that skips
retrying a failed request when a mirror has only one active disk.
Generally, that makes sense.  But during a transition from two disks to
one it is possible that the request failed on the failing disk before it
was inactivated and, so, the remaining active disk is the disk that
should be tried.

This change adds an additional check to ensure that it was the (only)
active disk that was already tried.

Reviewed by: mav
MFC after: 3 weeks

2 years agonetpfil tests: re-enable dummynet tests
Kristof Provost [Thu, 27 Jan 2022 09:16:21 +0000 (10:16 +0100)]
netpfil tests: re-enable dummynet tests

These had been disabled due to panics with queued packets keeping
pointers (in m->m_pkthdr.rcvif) to removed interfaces.
This issue has been resolved in 165746f4e4, so the tests can be run
again.

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

2 years agonetpfil tests: test removing interfaces with pending dummynet packets
Kristof Provost [Fri, 19 Nov 2021 22:05:48 +0000 (23:05 +0100)]
netpfil tests: test removing interfaces with pending dummynet packets

Dummynet queues packets with an associated struct ifnet pointer. Ensure
that things do not explode if that interface goes away with packets
still in the queue.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D33065

2 years agolibpfctl: fix creatorid endianness
Kristof Provost [Fri, 21 Jan 2022 16:50:15 +0000 (17:50 +0100)]
libpfctl: fix creatorid endianness

We provide the hostid (which is the state creatorid) to the kernel as a
big endian number (see pfctl/pfctl.c pfctl_set_hostid()), so convert it
back to system endianness when we get it from the kernel.

This avoids a confusing mismatch between the value the user configures
and the value displayed in the state.

MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D33989

2 years agopfctl: improve error reporting for routehost
Kristof Provost [Wed, 5 Jan 2022 20:31:02 +0000 (21:31 +0100)]
pfctl: improve error reporting for routehost

If an invalid (i.e. overly long) interface name is specified error out
immediately, rather than in expand_rule() so we point at the incorrect
line.

PR: 260958
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D34008

2 years agonetisr: serialize/restore m_pkthdr.rcvif when queueing mbufs
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:50 +0000 (21:58 -0800)]
netisr: serialize/restore m_pkthdr.rcvif when queueing mbufs

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33268

2 years agodummynet: use m_rcvif_serialize/restore when queueing packets
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:50 +0000 (21:58 -0800)]
dummynet: use m_rcvif_serialize/restore when queueing packets

This fixed panic with interface being removed while packet
was sitting on a queue.  This allows to pass all dummynet
tests including forthcoming dummynet:ipfw_interface_removal
and dummynet:pf_interface_removal and demonstrates use of
m_rcvif_serialize() and m_rcvif_restore().

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33267

2 years agoifnet/mbuf: provide KPI to serialize/restore m->m_pkthdr.rcvif
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:50 +0000 (21:58 -0800)]
ifnet/mbuf: provide KPI to serialize/restore m->m_pkthdr.rcvif

Supplement ifindex table with generation count and use it to
serialize & restore an ifnet pointer.

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33266
Fun note: git show e6abef09187a

2 years agoifnet: make if_index global
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:44 +0000 (21:58 -0800)]
ifnet: make if_index global

Now that ifindex is static to if.c we can unvirtualize it.  For lifetime
of an ifnet its index never changes.  To avoid leaking foreign interfaces
the net.link.generic.system.ifcount sysctl and the ifnet_byindex() KPI
filter their returned value on curvnet.  Since if_vmove() no longer
changes the if_index, inline ifindex_alloc() and ifindex_free() into
if_alloc() and if_free() respectively.

API wise the only change is that now minimum interface index can be
greater than 1.  The holes in interface indexes were always allowed.

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33672

2 years agotests/sys/net/routing: remove bandaid against old epair(4) panic
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:43 +0000 (21:58 -0800)]
tests/sys/net/routing: remove bandaid against old epair(4) panic

2 years agotests/sys/net/epair: don't leak the interface after the test
Gleb Smirnoff [Thu, 27 Jan 2022 05:08:50 +0000 (21:08 -0800)]
tests/sys/net/epair: don't leak the interface after the test

2 years agonullfs: ansify fs/nullfs/null_subr.c
Mateusz Guzik [Sat, 18 Sep 2021 10:25:40 +0000 (12:25 +0200)]
nullfs: ansify fs/nullfs/null_subr.c

2 years agovfs: remove the now unused insmntque1
Mateusz Guzik [Thu, 27 Jan 2022 00:00:24 +0000 (01:00 +0100)]
vfs: remove the now unused insmntque1

Bump __FreeBSD_version to 1400052.

2 years agounionfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:57:32 +0000 (00:57 +0100)]
unionfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agotmpfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:56:12 +0000 (00:56 +0100)]
tmpfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agonullfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:53:59 +0000 (00:53 +0100)]
nullfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agofdescfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:52:16 +0000 (00:52 +0100)]
fdescfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agodevfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:51:41 +0000 (00:51 +0100)]
devfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agoFix test of ses(4) when there is no SES device exists
Li-Wen Hsu [Wed, 26 Jan 2022 23:11:17 +0000 (07:11 +0800)]
Fix test of ses(4) when there is no SES device exists

glob(3) returns GLOB_NOMATCH if GLOB_NOCHECK or GLOB_NOMAGIC flag is not
passed so ATF_REQUIRE_EQ(r, 0) will cause a precondition check failure if no
/dev/ses* exists.

Remove calling of atf_tc_skip() in ATF_TC_CLEANUP() because it would let
the clean up procedure unfinish.

While here, fix a set-but-not-used warning.

Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D34056

2 years agoRevert "LinuxKPI: Allow wake_up to be executed within a critical section"
Vladimir Kondratyev [Wed, 26 Jan 2022 22:27:01 +0000 (01:27 +0300)]
Revert "LinuxKPI: Allow wake_up to be executed within a critical section"

This change was based on currently reverted commit 7dea0c9e6eba.

This reverts commit 89889ab470b9f1a1cd36913dd219b78efbf484df.

2 years agoRevert "LinuxKPI: Allow spin_lock_irqsave to be called within a critical section"
Vladimir Kondratyev [Wed, 26 Jan 2022 22:27:01 +0000 (01:27 +0300)]
Revert "LinuxKPI: Allow spin_lock_irqsave to be called within a critical section"

This change results in deadlocks on UP systems

This reverts commit 7dea0c9e6eba4dc127cd67667c81fa2c250f1024.

Requested by: kib, hselasky

2 years agosh: Don't add something to a null pointer
Jilles Tjoelker [Sun, 23 Jan 2022 21:15:57 +0000 (22:15 +0100)]
sh: Don't add something to a null pointer

Pointer arithmetic on a null pointer is undefined behavior.

The bug can be reproduced by running bin/sh/tests/builtins/wait6.0 with
UBSAN.

Reported by: Mark Millard
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D34011

2 years agotools/build: Fix the error message used when a host tool is not present
Mark Johnston [Wed, 26 Jan 2022 20:23:44 +0000 (15:23 -0500)]
tools/build: Fix the error message used when a host tool is not present

MFC after: 1 week

2 years agotests: add a basic test for argc == 0
Kyle Evans [Wed, 26 Jan 2022 01:22:03 +0000 (19:22 -0600)]
tests: add a basic test for argc == 0

The kernel should reject such exec()s now, early on. Instead of adding
the needed boilerplate to write a test in C, just add an -n argument for
"(n)ull argv" to the execve helper and exec this other helper that just
exits silently with argv count.

Reviewed by: emaste, kib, markj (all previous version)
Differential Revision: https://reviews.freebsd.org/D34045

2 years agoexecve: disallow argc == 0
Kyle Evans [Tue, 25 Jan 2022 22:47:23 +0000 (16:47 -0600)]
execve: disallow argc == 0

The manpage has contained the following verbiage on the matter for just
under 31 years:

"At least one argument must be present in the array"

Previous to this version, it had been prefaced with the weakening phrase
"By convention."

Carry through and document it the rest of the way.  Allowing argc == 0
has been a source of security issues in the past, and it's hard to
imagine a valid use-case for allowing it.  Toss back EINVAL if we ended
up not copying in any args for *execve().

The manpage change can be considered "Obtained from: OpenBSD"

Reviewed by: emaste, kib, markj (all previous version)
Differential Revision: https://reviews.freebsd.org/D34045

2 years agolimit sort(1) memory usage to 20% of available main memory
Wolfram Schneider [Wed, 26 Jan 2022 19:30:11 +0000 (19:30 +0000)]
limit sort(1) memory usage to 20% of available main memory

By default BSD sort(1) uses 90% (or at least 50%?) of the available
main memory. That is good for performance for a single job, but not
for a shared OS. For a long running script the performance is less
important than the stability of the server.  Also, if a server
with 64GB RAM starts swapping, the performance goes south and
hurts other running applications.

Note: this change does not affect the weekly cron job to
rebuild the locate database. The FreeBSD locate.updatedb
use the -presort option (find -s)

2 years agobsnmp: Fix two typos in error messages
Gordon Bergling [Wed, 26 Jan 2022 19:25:40 +0000 (20:25 +0100)]
bsnmp: Fix two typos in error messages

- s/responce/response/

MFC after: 1 week

2 years agohwpmc(4): Fix a typo in a sysctl description
Gordon Bergling [Wed, 26 Jan 2022 19:18:57 +0000 (20:18 +0100)]
hwpmc(4): Fix a typo in a sysctl description

- s/avalable/available/

MFC after: 3 days

2 years agozfs: Fix zvol_cdev_open locking
Ryan Moeller [Wed, 26 Jan 2022 18:33:23 +0000 (18:33 +0000)]
zfs: Fix zvol_cdev_open locking

First open locking changes were correctly applied to zvol_geom_open but
incorrectly applied to zvol_cdev_open, causing spa_namespace_lock to be
held indefinitely.

Make the first open locking in zvol_cdev_open match zvol_geom_open.

This change has been accepted upstream in openzfs/zfs#13016 but is not
yet merged.

Reviewed by: mav
Fixes: e92ffd9b6268
Sponsored by: iXsystems, Inc.

2 years agopkgbase: bhyve: Tag the kbdlayout file to be in the bhyve package
Emmanuel Vadot [Wed, 26 Jan 2022 12:17:52 +0000 (13:17 +0100)]
pkgbase: bhyve: Tag the kbdlayout file to be in the bhyve package

2 years agoextra_tcp_stacks: Fix two typos in source code comments
Gordon Bergling [Wed, 26 Jan 2022 17:02:55 +0000 (18:02 +0100)]
extra_tcp_stacks: Fix two typos in source code comments

- s/differnt/different/

MFC after; 3 days

2 years agomergemaster(8): Fix a typo in an error message
Gordon Bergling [Wed, 26 Jan 2022 16:59:49 +0000 (17:59 +0100)]
mergemaster(8): Fix a typo in an error message

- s/differnt/different/

MFC after: 3 days

2 years agosupport more than 2 billion file names for counting (-c) or limits (-l limit)
Wolfram Schneider [Wed, 26 Jan 2022 16:15:23 +0000 (16:15 +0000)]
support more than 2 billion file names for counting (-c) or limits (-l limit)

- this fix (harmless) integer overflows for very large partitions (>1PB)
- code cleanup

2 years agoswitch to 64 bit integers for counting bigrams
Wolfram Schneider [Wed, 26 Jan 2022 16:11:51 +0000 (16:11 +0000)]
switch to 64 bit integers for counting bigrams

This fixes an integer overflow for very large partitions around 35 billion
filenames (>2PB). However, in an artificially worst case it may occurs
by only 17 mio filenames on a partition.

2 years agogeom: Add HiFive boot partitions
Ed Maste [Tue, 12 Oct 2021 18:51:24 +0000 (14:51 -0400)]
geom: Add HiFive boot partitions

As documented in the HiFive Unmatched Software Reference Manual.

Reviewed by: imp, mhorne
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34010

2 years agogpart.8: minor tidying
Ed Maste [Wed, 26 Jan 2022 15:53:31 +0000 (10:53 -0500)]
gpart.8: minor tidying

Reported by: igor(1)

2 years agopowerpc: Enable LLDB on all powerpc architectures
Piotr Kubaj [Wed, 26 Jan 2022 14:02:28 +0000 (15:02 +0100)]
powerpc: Enable LLDB on all powerpc architectures

While LLDB on powerpc and powerpcspe builds as-is, on powerpc64 and
powerpc64le it requires adding a couple of additional source files
to build.

Differential review: https://reviews.freebsd.org/D34043
Approved by: dim, imp, emaste

2 years agoImplement a function to get the next TCP- and TLS- receive sequence number.
Hans Petter Selasky [Wed, 26 Jan 2022 11:53:13 +0000 (12:53 +0100)]
Implement a function to get the next TCP- and TLS- receive sequence number.

This function will be used by coming TLS hardware receive offload support.

Differential Revision: https://reviews.freebsd.org/D32356
Discussed with: jhb@
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agoAdd definitions for TLS receive tags using the existing send tag infrastructure.
Hans Petter Selasky [Wed, 26 Jan 2022 11:33:47 +0000 (12:33 +0100)]
Add definitions for TLS receive tags using the existing send tag infrastructure.

Although send tags are strictly used for transmit, the name might be changed
in the future to be more generic.

The TLS receive tags support regular IPv4 and IPv6 traffic, and also over any
VLAN. If prio-tagging is enabled, VLAN ID zero, this must be checked in the
network driver itself when creating the TLS RX decryption offload filter.

TLS receive tags have a modify callback to tell the network driver about
the progress of decryption. Currently decryption is done IP packet by IP
packet, even if the IP packet contains a partial TLS record. The modify
callback allows the network driver to keep track of TCP sequence numbers
pointing to the beginning of TLS records after TCP packet reassembly.
These callbacks only happen when encrypted or partially decrypted data is
received and are used to verify the decryptions starting point for the
hardware. Typically the hardware will guess where TLS headers start and
needs help from the software to know if the guess was correct. This is
the purpose of the modify callback.

Differential Revision: https://reviews.freebsd.org/D32356
Discussed with: jhb@
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agombuf(9): Assert receive mbufs don't carry a send tag.
Hans Petter Selasky [Wed, 26 Jan 2022 11:13:53 +0000 (12:13 +0100)]
mbuf(9): Assert receive mbufs don't carry a send tag.

Else we would start leaking reference counts.

Discussed with: jhb@
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agombuf(9): Properly declare some function macros when debugging is disabled.
Hans Petter Selasky [Wed, 26 Jan 2022 11:00:12 +0000 (12:00 +0100)]
mbuf(9): Properly declare some function macros when debugging is disabled.

No functional change intended.

MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agoman(1): Add full search (-K) flag
Fernando ApesteguĂ­a [Tue, 25 Jan 2022 12:12:27 +0000 (13:12 +0100)]
man(1): Add full search (-K) flag

This flag allows a full text search on man pages. Although this is a last resort
option, it can be useful to pin point a certain man page.

It can be used with -S to narrow the search.

Unlike the Linux version, the search takes place in the rendered text so it
avoids false-positives when the text is found in comments in the source files.

It relies on `grep(1)` and `mandoc(1)` to do its job.

Add flag documentation and EXAMPLES to the manual page (bump .Dd).

Usage example:

man -w -K '\<arm\>' -S 1:8

Reviewed By: ceri, emaste, pauamma_gundo.com
Approved by: manpages (bcr@), debdrup@
Differential Revision: https://reviews.freebsd.org/D30984

2 years agolinuxkpi: i2c: Add MODULE_DEPEND for iicbus
Emmanuel Vadot [Wed, 26 Jan 2022 09:42:20 +0000 (10:42 +0100)]
linuxkpi: i2c: Add MODULE_DEPEND for iicbus

MFC after: 1 month
MFC with: 1961a14a4743
Fixes: 1961a14a4743 ("linuxkpi: Add i2c support")
Reported by: GregV
Sponsored by: Beckhoff Automation GmbH & Co. KG

2 years agoadd overlay for enabling spi0 on allwinner h3
Andriy Gapon [Wed, 24 Nov 2021 16:36:34 +0000 (18:36 +0200)]
add overlay for enabling spi0 on allwinner h3

At least on Orange Pi PC Plus it is routed to the 40-pin header, so it
can used to communicate with external devices.

MFC after: 2 weeks

2 years agoadd overlay for enabling i2c1 on allwinner h3
Andriy Gapon [Wed, 3 Nov 2021 11:37:17 +0000 (13:37 +0200)]
add overlay for enabling i2c1 on allwinner h3

At least on Orange Pi PC Plus it is routed to the 40-pin header, so it
can used to communicate with external devices.

MFC after: 2 weeks

2 years agocpucontrol(8): Fix a typo in an error message
Gordon Bergling [Wed, 26 Jan 2022 09:36:42 +0000 (10:36 +0100)]
cpucontrol(8): Fix a typo in an error message

- s/incorret/incorrect/

MFC after: 1 week

2 years agoextra_tcp_stacks: Fix a few common typos
Gordon Bergling [Wed, 26 Jan 2022 09:35:17 +0000 (10:35 +0100)]
extra_tcp_stacks: Fix a few common typos

TCP_BBR:
- Fix a typo introducted in 1b90dfa5d2b0, which was reported by tuexen@

TCP_RACK:
- Correct two sysctl descriptions: s/corret/correct/

tcp_bbr(4): Also fix s/measurment/measurement/ in the man page

MFC after: 1 week

2 years agoadd overlay for enabling serial1 / uart1 on rk3328
Andriy Gapon [Tue, 18 Jan 2022 07:26:14 +0000 (09:26 +0200)]
add overlay for enabling serial1 / uart1 on rk3328

On Rock64 the uart is routed to pins on the "Pi-2" header, so it is
potentially useful.

Pin mapping:
----------------------------
| ID | Name     | Function |
----------------------------
| 15 | GPIO3_A4 | TX       |
| 16 | GPIO3_A5 | RTS      |
| 18 | GPIO3_A6 | RX       |
| 22 | GPIO3_A7 | CTS      |
----------------------------

MFC after: 2 weeks

2 years agoadd overlay for enabling i2c0 on rk3328
Andriy Gapon [Fri, 26 Nov 2021 16:30:08 +0000 (18:30 +0200)]
add overlay for enabling i2c0 on rk3328

On Rock64 it is routed to pins 3 and 5 of the so called Pi-2 header.

MFC after: 2 weeks

2 years agocam_get_device: resolve path links before parsing device name
Andriy Gapon [Sat, 27 Nov 2021 18:49:08 +0000 (20:49 +0200)]
cam_get_device: resolve path links before parsing device name

The CAM subsystem uses bus:taget:lun tuple to address peripherals.  But
for convenience many userland programs such as camcontrol accept devices
names such as da0.  There is a libcam function, cam_open_device, to
support that.  It first calls cam_get_device() to parse the device name
as a driver name and a unit (and handle some special device name
prefixes) and then uses cam_lookup_pass() to find a matching pass
device.

This change extends cam_get_device() to apply realpath(3) to the device
name before parsing it.  This will allow to use tools such as camcontrol
and smartctl with symbolic links that could be friendlier (more
distinguished) names for devices.

MFC after: 3 weeks
Relnotes: maybe

2 years agosdhci: fix dumping support in MMCCAM configuration
Andriy Gapon [Wed, 26 Jan 2022 07:16:31 +0000 (09:16 +0200)]
sdhci: fix dumping support in MMCCAM configuration

This change fixes interaction with recently added sddadump.

MFC after: 1 week

2 years agompr/mps: Fix a race in diagnostic reset
Warner Losh [Tue, 25 Jan 2022 23:23:03 +0000 (16:23 -0700)]
mpr/mps: Fix a race in diagnostic reset

There's a small race in freezing the simq when performing a diagnostic
reset. During this time, a transaction can slip through and encounter
the target id of 0. If we're still in diagnostic reset when we detect
this, return a CAM_DEVICE_NOT_THERE status. Instead, freeze the queue
and return a requeue status, similar to what we do when we're resetting
a target and a transaction get here. The race is unavoidable due to
separate locks for queue and SIM, but easy enough to detect and make
harmless.

Sponsored by: Netflix
Reviewed by: scottl, mav
Differential Revision: https://reviews.freebsd.org/D34017

2 years agoRemove a stale comment.
John Baldwin [Wed, 26 Jan 2022 01:19:36 +0000 (17:19 -0800)]
Remove a stale comment.

The intr_disable as a macro was only a problem on arm and mips and
is no longer relevant after the mips removal.

2 years agoopencrypto/xform_*.h: Trim scope of included headers.
John Baldwin [Tue, 25 Jan 2022 23:21:22 +0000 (15:21 -0800)]
opencrypto/xform_*.h: Trim scope of included headers.

Reviewed by: markj, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34022

2 years agoopencrypto/cryptodev.h: Add includes to make more self-contained.
John Baldwin [Tue, 25 Jan 2022 23:20:46 +0000 (15:20 -0800)]
opencrypto/cryptodev.h: Add includes to make more self-contained.

Reviewed by: markj, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34021

2 years agodp83822phy: Add missing MII_PHY_END to avoid buffer overread on probe
Jessica Clarke [Tue, 25 Jan 2022 20:24:28 +0000 (20:24 +0000)]
dp83822phy: Add missing MII_PHY_END to avoid buffer overread on probe

Found by: CHERI
Fixes: 0c9156faeccb ("Introduce DP83822 PHY driver")

2 years agodp83867phy: Add missing MII_PHY_END to avoid buffer overread on attach
Jessica Clarke [Tue, 25 Jan 2022 20:24:27 +0000 (20:24 +0000)]
dp83867phy: Add missing MII_PHY_END to avoid buffer overread on attach

Found by: CHERI
Fixes: e85c94b8d6ca ("Introduce DP83867 PHY driver")

2 years agolibthr: Use TLS_TCB_* in _tcb_[cd]tor.
John Baldwin [Tue, 25 Jan 2022 19:38:34 +0000 (11:38 -0800)]
libthr: Use TLS_TCB_* in _tcb_[cd]tor.

This matches libc and rtld in using the alignment (TLS_TCB_ALIGN) from
machine/tls.h instead of hardcoding 16.

Reviewed by: kib
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D34023

2 years agoStop trying to strip 'eb' suffixes from ARM MACHINE_ARCH.
John Baldwin [Tue, 25 Jan 2022 19:37:29 +0000 (11:37 -0800)]
Stop trying to strip 'eb' suffixes from ARM MACHINE_ARCH.

armeb is no longer a supported MACHINE_ARCH.

Reviewed by: imp, emaste
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D34019

2 years agoStop trimming 'hf' suffixes from MACHINE_ARCH.
John Baldwin [Tue, 25 Jan 2022 19:31:17 +0000 (11:31 -0800)]
Stop trimming 'hf' suffixes from MACHINE_ARCH.

This was only used for MIPS hard-float architectures.

Reviewed by: imp
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D34018

2 years agolocate statistics: non zero exit on corrupt database
Wolfram Schneider [Tue, 25 Jan 2022 16:55:58 +0000 (16:55 +0000)]
locate statistics: non zero exit on corrupt database

2 years agobhyve/block_if: allow DIOCGMEDIASIZE ioctl
Robert Wing [Tue, 25 Jan 2022 16:44:13 +0000 (07:44 -0900)]
bhyve/block_if: allow DIOCGMEDIASIZE ioctl

This is needed to get mediasize of the device after a resize event.

I missed this earlier as I was building WITH_BHYVE_SNAPSHOT, which
disables capsicum.

Reviewed by: khng, markj
Fixes: ae9ea22e14bf ("bhyve: get mediasize for character devices when ...")
Differential Revision: https://reviews.freebsd.org/D34013

2 years agostop on error and display the statstics anyway
Wolfram Schneider [Tue, 25 Jan 2022 15:58:29 +0000 (15:58 +0000)]
stop on error and display the statstics anyway

PR: 32686

2 years ago__sflush(): on write error, if nothing was written, reset FILE state back
Konstantin Belousov [Sun, 23 Jan 2022 06:52:59 +0000 (08:52 +0200)]
__sflush(): on write error, if nothing was written, reset FILE state back

otherwise the data is just dropped.  Check for current position equal to
the buffer base at the entry of the function; if not equal, setvbuf()
was done from the write method and it is not our business to override
the decision.

PR: 76398
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34007

2 years agoBump __FreeBSD_version for LinuxKPI changes
Emmanuel Vadot [Tue, 25 Jan 2022 15:13:38 +0000 (16:13 +0100)]
Bump __FreeBSD_version for LinuxKPI changes

Sponsored by: Beckhoff Automation GmbH & Co. KG

2 years agolinuxkpi: Add i2c support
Emmanuel Vadot [Thu, 4 Nov 2021 09:42:37 +0000 (10:42 +0100)]
linuxkpi: Add i2c support

Add i2c support to linuxkpi. This is needed by drm-kmod.
For every i2c_adapter added by i2c_add_adapter we add a child to the
device named "lkpi_iic". This child handle the conversion between
Linux i2c_msgs to FreeBSD iic_msgs.
For every i2c_adapter added by i2c_bit_add_bus we add a child to the
device named "lkpi_iicbb". This child handle the conversion between
Linux i2c_msgs to FreeBSD iic_msgs.
With the help of iic(4), this expose the i2c controller to userspace
allowing a user to query DDC information from a monitor.
e.g.: i2c -f /dev/iic0 -a 0x28 -c 128 -d r
will query the standard EDID from the monitor if plugged.

The bitbang part (lkpi_iicbb) isn't tested at all for now as I don't have
compatible hardware (all my hardware have native i2c controller).

Tested on: Intel (SandyBridge, Skylake, ApolloLake)
Tested on: AMD (Picasso, Polaris (amd64 and arm64))

MFC after: 1 month
Reviewed by: hselasky
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D33053

2 years agoRevert "linux: Provide dummy seccomp(2)"
Edward Tomasz Napierala [Thu, 20 Jan 2022 22:25:15 +0000 (22:25 +0000)]
Revert "linux: Provide dummy seccomp(2)"

This reverts commit 56981629f91fcdd358ccb41081ff6dcc2edac12f.

Wrong patch; fails to build on i386.

2 years agolinux: Provide dummy seccomp(2)
Edward Tomasz Napierala [Tue, 25 Jan 2022 11:53:56 +0000 (11:53 +0000)]
linux: Provide dummy seccomp(2)

Don't emit warnings; this isn't any different from a Linux kernel
built without OPTIONS_SECCOMP, so the userspace already needs to know
how to deal with it.  This is also similar with how we handle seccomp
in linux_prctl().

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D33808

2 years agolocate: change from BSD-4-clause to BSD-3-clause
Baptiste Daroussin [Tue, 25 Jan 2022 08:17:36 +0000 (09:17 +0100)]
locate: change from BSD-4-clause to BSD-3-clause

We have the authorization from the University of California to remove
the advertising clause for a while, wosch@ who also hold a copyright
on this code also approved the relicensing

Approved by: wosch@
MFC after: 3 days

2 years agofetch(1): more fixes for soft failure handling
Eugene Grosbein [Tue, 25 Jan 2022 05:46:07 +0000 (12:46 +0700)]
fetch(1): more fixes for soft failure handling

Fix logic error introduced in my commit
bf599c03f09dea0f7e188e002b42d782af6841c3

Also, authorization errors should not be considered as soft failures.

2 years agotests/net*: destroy interface from inside a jail
Gleb Smirnoff [Tue, 25 Jan 2022 05:08:03 +0000 (21:08 -0800)]
tests/net*: destroy interface from inside a jail

There is no guarentee that upon return of 'jail -r' all jail resources
will be released.  The test suite used to rely on that.  Recent changes
to the PCB zones made jails delay releasing their resources, which ended
with interface leak in the test suite.

Fix that by executing 'ifconfig foo0 destroy' inside the jail, instead
of doing 'jail -r' and expecting interfaces to pop up back immediately
in the parent jail.

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33942

2 years agoif_clone: correctly destroy a clone from a different vnet
Gleb Smirnoff [Tue, 25 Jan 2022 05:07:16 +0000 (21:07 -0800)]
if_clone: correctly destroy a clone from a different vnet

Try to live with cruel reality fact - if_vmove doesn't move an
interface from previous vnet cloning infrastructure to the new
one.  Let's admit this as design feature and make it work better.

* Delete two blocks of code that would fallback to vnet0, if a
  cloner isn't found.  They didn't do any good job and also whole
  idea of treating vnet0 as special one is wrong.
* When deleting a cloned interface, lookup its cloner using it's
  home vnet.

With this change simple sequence works correctly:

  ifconfig foo0 create
  jail -c name=jj persist vnet vnet.interface=foo0
  jexec jj ifconfig foo0 destroy

Differential revision: https://reviews.freebsd.org/D33942

2 years agoif_vmove: improve restoration in cloner's ifgroup membership
Gleb Smirnoff [Tue, 25 Jan 2022 05:06:59 +0000 (21:06 -0800)]
if_vmove: improve restoration in cloner's ifgroup membership

* Do a single call into if_clone.c instead of two.  The cloner
  can't disappear since the interface sits on its list.
* Make restoration smarter - check that cloner with same name
  exists in the new vnet.

Differential revision: https://reviews.freebsd.org/D33941

2 years agotests/netinet: add test for IPv6 NS and CARP
Thomas Steen Rasmussen [Tue, 25 Jan 2022 05:02:47 +0000 (21:02 -0800)]
tests/netinet: add test for IPv6 NS and CARP

PR: 193280
Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D33859

2 years agond6: use CARP link level address in SLLAO for NS sent out
Thomas Steen Rasmussen [Tue, 25 Jan 2022 05:02:47 +0000 (21:02 -0800)]
nd6: use CARP link level address in SLLAO for NS sent out

When sending an NS, check if we are using a IPv6 CARP address
and if we do, then put proper CARP link level address into
ND_OPT_SOURCE_LINKADDR option and also put PACKET_TAG_CARP tag
on the packet.  The latter will enforce CARP link level address
at the data link layer too, which might be necessary for broken
implementations.
The code really follows what NA sending code has been doing since
introduction of carp(4).  While here, bring to style(9) the whole
block of code.

PR: 193280
Differential revision: https://reviews.freebsd.org/D33858

2 years agoice_ddp: Update to 1.3.27.0
Eric Joyner [Wed, 1 Dec 2021 20:48:36 +0000 (12:48 -0800)]
ice_ddp: Update to 1.3.27.0

This is intended to be used with forthcoming ice(4) driver version 1.34.2.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Sponsored by: Intel Corporation

2 years agoiflib: Allow drivers to determine which queue to TX on
Eric Joyner [Thu, 29 Jul 2021 23:24:14 +0000 (16:24 -0700)]
iflib: Allow drivers to determine which queue to TX on

Adds a new function pointer to struct if_txrx in order to allow
drivers to set their own function that will determine which queue
a packet should be sent on.

Since this includes a kernel ABI change, bump the __FreeBSD_version
as well.

(This motivation behind this is to allow the driver to examine the
UP in the VLAN tag and determine which queue to TX on based on
that, in support of HW TX traffic shaping.)

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: kbowling@, stallamr@netapp.com
Tested by: jeffrey.e.pieper@intel.com
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D31485

2 years agoatsectl: Remove.
John Baldwin [Tue, 25 Jan 2022 00:40:02 +0000 (16:40 -0800)]
atsectl: Remove.

This was used in the BERI Altera DE4 that ran CHERI MIPS.

Approved by: brooks

2 years agoBump __FreeBSD_version for the addition of <crypto/curve25519.h>.
John Baldwin [Mon, 24 Jan 2022 23:28:36 +0000 (15:28 -0800)]
Bump __FreeBSD_version for the addition of <crypto/curve25519.h>.

Sponsored by: The FreeBSD Foundation

2 years agocrypto: Remove xform.c and compile xform_*.c standalone.
John Baldwin [Mon, 24 Jan 2022 23:27:40 +0000 (15:27 -0800)]
crypto: Remove xform.c and compile xform_*.c standalone.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33995

2 years agoxform_*.c: Add headers when needed to compile standalone.
John Baldwin [Mon, 24 Jan 2022 23:27:40 +0000 (15:27 -0800)]
xform_*.c: Add headers when needed to compile standalone.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33994

2 years agoRetire now-unused M_XDATA.
John Baldwin [Mon, 24 Jan 2022 23:27:39 +0000 (15:27 -0800)]
Retire now-unused M_XDATA.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33993

2 years agoIPsec: Use protocol-specific malloc types instead of M_XDATA.
John Baldwin [Mon, 24 Jan 2022 23:27:39 +0000 (15:27 -0800)]
IPsec: Use protocol-specific malloc types instead of M_XDATA.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33992