]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoregen syscall files after d51198d63b63
Ed Maste [Thu, 13 May 2021 17:58:04 +0000 (13:58 -0400)]
regen syscall files after d51198d63b63

3 years agomakesyscalls.lua: improve generated file style(9) compliance
Ed Maste [Wed, 12 May 2021 20:11:44 +0000 (16:11 -0400)]
makesyscalls.lua: improve generated file style(9) compliance

We generally like to avoid style changes when other changes are not
planned.  In this case there are some makesyscalls.lua changes in the
pipeline, and this cleans up style nits in generated files that were
highlighted by experiments with clang-format.

Reviewed by: brooks, kevans
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30235

3 years agotmpfs: dynamically register tmpfs pager
Konstantin Belousov [Fri, 7 May 2021 19:42:06 +0000 (22:42 +0300)]
tmpfs: dynamically register tmpfs pager

Remove OBJT_SWAP_TMPFS. Move tmpfs-specific swap pager bits into
tmpfs_subr.c.

There is no longer any code to directly support tmpfs in sys/vm, most
tmpfs knowledge is shared by non-anon swap object type implementation.
The tmpfs-specific methods are provided by registered tmpfs pager, which
inherits from the swap pager.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30168

3 years agovm: Add KPI to dynamically register pagers
Konstantin Belousov [Fri, 7 May 2021 19:06:16 +0000 (22:06 +0300)]
vm: Add KPI to dynamically register pagers

Pager is allowed to inherit part of its implementation from the existing
pager, which is done by copying non-NULL virtual method slots.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30168

3 years agosys/vm: remove several other uses of OBJT_SWAP_TMPFS
Konstantin Belousov [Fri, 7 May 2021 18:21:22 +0000 (21:21 +0300)]
sys/vm: remove several other uses of OBJT_SWAP_TMPFS

Mostly in cases where OBJ_SWAP flag works as well, or by reversing the
condition so that object types can be listed.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30168

3 years agovm_object_set_memattr(): handle all object types without listing them explicitly
Konstantin Belousov [Fri, 7 May 2021 18:19:30 +0000 (21:19 +0300)]
vm_object_set_memattr(): handle all object types without listing them explicitly

This avoids the need to know all existing object types in advance, by the
cost of loosing the assert that unknown object type is handled in a sane
manner.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30168

3 years agoprocfs_map: switch to use vm_object_kvme_type
Konstantin Belousov [Mon, 10 May 2021 15:20:42 +0000 (18:20 +0300)]
procfs_map: switch to use vm_object_kvme_type

to get object type, and stop enumerating OBJT_XXX constants.  This also
provides properly a pointer for the vnode, if object backs any.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30168

3 years agovm_object_kvme_type(): reimplement by embedding kvme_type into pagerops
Konstantin Belousov [Fri, 7 May 2021 17:46:51 +0000 (20:46 +0300)]
vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30168

3 years agoarm64: rockchip: Add some DTSO to disable sd/mmc
Emmanuel Vadot [Wed, 21 Apr 2021 13:25:29 +0000 (15:25 +0200)]
arm64: rockchip: Add some DTSO to disable sd/mmc

This helps during developement to reduce the number of mmc controller.

3 years agomodules: Add sdhci_fdt module
Emmanuel Vadot [Wed, 28 Apr 2021 13:57:39 +0000 (15:57 +0200)]
modules: Add sdhci_fdt module

This is a module for sdhci on fdt system

3 years agonetgraph/ng_bridge: become SMP aware
Lutz Donnerhacke [Tue, 12 Jan 2021 21:28:29 +0000 (22:28 +0100)]
netgraph/ng_bridge: become SMP aware

The node ng_bridge underwent a lot of changes in the last few months.
All those steps were necessary to distinguish between structure
modifying and read-only data transport paths.  Now it's done, the node
can perform frame forwarding on multiple cores in parallel.

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

3 years agoUPDATING: Add a note for pkgbase user for commit ca179c4d74f2
Emmanuel Vadot [Thu, 13 May 2021 15:46:08 +0000 (17:46 +0200)]
UPDATING: Add a note for pkgbase user for commit ca179c4d74f2

3 years agopkgbase: Put openssl in its own package
Emmanuel Vadot [Sun, 2 May 2021 15:46:17 +0000 (17:46 +0200)]
pkgbase: Put openssl in its own package

This is useful for upgrade and also to make tiny jail so they won't
depend on FreeBSD-utilities (where openssl was packaged before).

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30081

3 years agopkgbase: Move librt to clibs
Emmanuel Vadot [Mon, 3 May 2021 08:12:26 +0000 (10:12 +0200)]
pkgbase: Move librt to clibs

librt implement the POSIX realtime extension library.
Move it to clibs instead of utilities as a number of ports uses it
so avoid a dependancy on FreeBSD-utilities.

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30088

3 years agonetgraph/ng_bridge: move MACs via control message
Lutz Donnerhacke [Tue, 9 Feb 2021 13:28:48 +0000 (14:28 +0100)]
netgraph/ng_bridge: move MACs via control message

Use the new control message to move ethernet addresses from a link to
a new link in ng_bridge(4).  Send this message instead of doing the
work directly requires to move the loop detection into the control
message processing.  This will delay the loop detection by a few
frames.

This decouples the read-only activity from the modification under a
more strict writer lock.

Reviewed by: manpages (gbe)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28559

3 years agosyslog.3 - Add detail about LOG_PID
Fernando Apesteguía [Mon, 10 May 2021 15:20:06 +0000 (17:20 +0200)]
syslog.3 - Add detail about LOG_PID

Document that LOG_PID is ignored and can not be disabled.
This change was made along with the move from RFC 3164 to RFC 5424 log messages.

PR: 255664
Reported by: des.gaufres@gmail.com
Reviewed by: gbe, jilles
Approved by: gbe (mentor, manpages), jilles

3 years agosort: Hook NetBSD tests up to the build
Mark Johnston [Thu, 13 May 2021 12:57:26 +0000 (08:57 -0400)]
sort: Hook NetBSD tests up to the build

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agosort: Make NetBSD sort tests compatible with our sort
Cyril Zhang [Thu, 13 May 2021 12:50:23 +0000 (08:50 -0400)]
sort: Make NetBSD sort tests compatible with our sort

This diff primarily adds/removes flags to make the tests compatible with
sort.  Two tests are removed.  One test is changed to expect fail due to
a bug.

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

3 years agosort: Cache value of MB_CUR_MAX
Cyril Zhang [Thu, 13 May 2021 12:55:06 +0000 (08:55 -0400)]
sort: Cache value of MB_CUR_MAX

Every usage of MB_CUR_MAX results in a call to __mb_cur_max.  This is
inefficient and redundant.  Caching the value of MB_CUR_MAX in a global
variable removes these calls and speeds up the runtime of sort.  For
numeric sorting, runtime is almost halved in some tests.

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

3 years agosort: Stop "fixing" obsolete key syntax after -- flag
Cyril Zhang [Thu, 13 May 2021 12:52:51 +0000 (08:52 -0400)]
sort: Stop "fixing" obsolete key syntax after -- flag

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

3 years agoposix timers: Check for overflow when converting to ns
Mark Johnston [Thu, 13 May 2021 12:33:37 +0000 (08:33 -0400)]
posix timers: Check for overflow when converting to ns

Disallow a time or timer period value when the conversion to nanoseconds
would overflow.  Otherwise it is possible to trigger a divison by zero
in realtime_expire_l(), where we compute the number of overruns by
dividing by the timer interval.

Fixes: 7995dae9 ("posix timers: Improve the overrun calculation")
Reported by: syzbot+5ab360bd3d3e3c5a6e0e@syzkaller.appspotmail.com
Reported by: syzbot+157b74ff493140d86eac@syzkaller.appspotmail.com
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30233

3 years agofork: Suspend other threads if both RFPROC and RFMEM are not set
Mark Johnston [Thu, 13 May 2021 12:33:23 +0000 (08:33 -0400)]
fork: Suspend other threads if both RFPROC and RFMEM are not set

Otherwise, a multithreaded parent process may trigger races in
vm_forkproc() if one thread calls rfork() with RFMEM set and another
calls rfork() without RFMEM.

Also simplify vm_forkproc() a bit, vmspace_unshare() already checks to
see if the address space is shared.

Reported by: syzbot+0aa7c2bec74c4066c36f@syzkaller.appspotmail.com
Reported by: syzbot+ea84cb06937afeae609d@syzkaller.appspotmail.com
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30220

3 years agoFinal pass of cleanup: Get rid of gotos and general polish.
Poul-Henning Kamp [Thu, 13 May 2021 11:58:50 +0000 (11:58 +0000)]
Final pass of cleanup: Get rid of gotos and general polish.

NB: This changes the outputs, in particular in error conditions,
    in various subtle ways to be more systematic and usable.

3 years agoRewrite and simplify the -n argument processing.
Poul-Henning Kamp [Thu, 13 May 2021 10:55:37 +0000 (10:55 +0000)]
Rewrite and simplify the -n argument processing.

3 years agoRefactor argument processing.
Poul-Henning Kamp [Thu, 13 May 2021 09:52:36 +0000 (09:52 +0000)]
Refactor argument processing.

3 years agotcp: Incorrect KASSERT causes a panic in rack
Randall Stewart [Thu, 13 May 2021 11:36:04 +0000 (07:36 -0400)]
tcp: Incorrect KASSERT causes a panic in rack

Skyzall found an interesting panic in rack. When a SYN and FIN are
both sent together a KASSERT gets tripped where it is validating that
a mbuf pointer is in the sendmap. But a SYN and FIN often will not
have a mbuf pointer. So the fix is two fold a) make sure that the
SYN and FIN split the right way when cloning an RSM SYN on left
edge and FIN on right. And also make sure the KASSERT properly
accounts for the case that we have a SYN or FIN so we don't
panic.

Reviewed by: mtuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D30241

3 years agomod_cc: cross reference CC modules consistently
Michael Tuexen [Thu, 13 May 2021 08:47:45 +0000 (10:47 +0200)]
mod_cc: cross reference CC modules consistently

Reviewed by: bcr, gbe
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D30240

3 years agovfs: fix vnode use count leak in O_EMPTY_PATH support
Mateusz Guzik [Thu, 13 May 2021 09:23:03 +0000 (11:23 +0200)]
vfs: fix vnode use count leak in O_EMPTY_PATH support

The vnode returned by namei_setup is already referenced.

Reported by: pho

3 years agofind(1): Document the -f option
Ceri Davies [Thu, 13 May 2021 08:10:22 +0000 (10:10 +0200)]
find(1): Document the -f option

PR: 223127
Reported by: Mathieu Arnold <mat at FreeBSD dot org>
Reviewed by: bcr, gbe
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D30215

3 years agoRemove references to timed(8)
Ceri Davies [Thu, 13 May 2021 07:53:08 +0000 (09:53 +0200)]
Remove references to timed(8)

There are still references to timed(8) and timedc(8) in the base system,
which were removed in 2018.

PR: 255425
Reported by: Ceri Davies <ceri at submonkey dot net>
Reviewed by: ygy, gbe
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30232

3 years agostress2: Added two new syzkaller reproducers. Update the exclude list
Peter Holm [Thu, 13 May 2021 05:57:32 +0000 (07:57 +0200)]
stress2: Added two new syzkaller reproducers. Update the exclude list

3 years agobhyve/snapshot: provide a way to send other messages/data to bhyve
Robert Wing [Wed, 3 Mar 2021 06:05:47 +0000 (21:05 -0900)]
bhyve/snapshot: provide a way to send other messages/data to bhyve

This is a step towards sending messages (other than suspend/checkpoint)
from bhyvectl to bhyve.

Introduce a new struct, ipc_message - this struct stores the type of
message and a union containing message specific structures for the type
of message being sent.

Reviewed by:    grehan
Differential Revision: https://reviews.freebsd.org/D30221

3 years agovn_open_cred(): disallow O_CREAT | O_EMPTY_PATH
Konstantin Belousov [Wed, 12 May 2021 19:04:44 +0000 (22:04 +0300)]
vn_open_cred(): disallow O_CREAT | O_EMPTY_PATH

This combination does not make sense, and cannot be satisfied by lookup.
In particular, lookup cannot supply dvp, it only can directly return vp.

Reported and reviewed by: markj using syzkaller
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

3 years agortld: initialize default dlerror_seen_val as true
Konstantin Belousov [Tue, 11 May 2021 23:36:09 +0000 (02:36 +0300)]
rtld: initialize default dlerror_seen_val as true

There should be no error after startup.

PR: 255698
Reported by: Eugene M. Kim <astralblue@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agoMore refactoring & polishing.
Poul-Henning Kamp [Wed, 12 May 2021 21:37:00 +0000 (21:37 +0000)]
More refactoring & polishing.

Do not call usage() without telling why.

Extract '-a' mode into a function, and sanitize hexdumping.

Revise manpage to match reality of code.

3 years agoMore refactoring:
Poul-Henning Kamp [Wed, 12 May 2021 21:34:58 +0000 (21:34 +0000)]
More refactoring:

Extract the '-a' mode into a separate function, and simplify the
hexdumping logic.

Dont call usage() without telling why.

3 years agosctp: fix another locking bug in COOKIE handling
Michael Tuexen [Wed, 12 May 2021 21:02:31 +0000 (23:02 +0200)]
sctp: fix another locking bug in COOKIE handling

Thanks to Tolya Korniltsev for reporting the issue for
the userland stack and testing the fix.

MFC after: 3 days

3 years agoCentralize offset width handling, and make it possible to specify explicit endianess.
Poul-Henning Kamp [Wed, 12 May 2021 20:01:14 +0000 (20:01 +0000)]
Centralize offset width handling, and make it possible to specify explicit endianess.

3 years agoCentralize open/close of /dev/iic%d devices
Poul-Henning Kamp [Wed, 12 May 2021 19:43:44 +0000 (19:43 +0000)]
Centralize open/close of /dev/iic%d devices

3 years agotests: Only log critical errors from scapy
Kristof Provost [Wed, 12 May 2021 17:13:40 +0000 (19:13 +0200)]
tests: Only log critical errors from scapy

Since 2.4.5 scapy started issuing warnings about a few different
configurations during our tests. These are harmless, but they generate
stderr output, which upsets atf_check.

Configure scapy to only log critical errors (and thus not warnings) to
fix these tests.

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

3 years agoCorrect location of libcap_random.so in ObsoleteFiles.inc
Dimitry Andric [Wed, 12 May 2021 18:33:46 +0000 (20:33 +0200)]
Correct location of libcap_random.so in ObsoleteFiles.inc

3 years agoFix mbuf leaks in various pru_send implementations
Mark Johnston [Wed, 12 May 2021 13:39:36 +0000 (09:39 -0400)]
Fix mbuf leaks in various pru_send implementations

The various protocol implementations are not very consistent about
freeing mbufs in error paths.  In general, all protocols must free both
"m" and "control" upon an error, except if PRUS_NOTREADY is specified
(this is only implemented by TCP and unix(4) and requires further work
not handled in this diff), in which case "control" still must be freed.

This diff plugs various leaks in the pru_send implementations.

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

3 years agond6: Avoid using an uninitialized sockaddr in nd6_prefix_offlink()
Mark Johnston [Wed, 12 May 2021 15:49:24 +0000 (11:49 -0400)]
nd6: Avoid using an uninitialized sockaddr in nd6_prefix_offlink()

Commit 81728a538 ("Split rtinit() into multiple functions.") removed
the initialization of sa6, but not one of its uses.  This meant that we
were passing an uninitialized sockaddr as the address to
lltable_prefix_free().  Remove the variable outright to fix the problem.
The caller is expected to hold a reference on pr.

Fixes: 81728a538 ("Split rtinit() into multiple functions.")
Reported by: KMSAN
Reviewed by: donner
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30166

3 years agoif: Remove unnecessary validation in the SIOCSIFNAME handler
Mark Johnston [Wed, 12 May 2021 14:05:37 +0000 (10:05 -0400)]
if: Remove unnecessary validation in the SIOCSIFNAME handler

A successful copyinstr() call guarantees that the returned string is
nul-terminated.  Furthermore, the removed check would harmlessly compare
an uninitialized byte with '\0' if the new name is shorter than
IFNAMESIZ - 1.

Reported by: KMSAN
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agoswap_pager: Zero swap info before exporting to userspace
Mark Johnston [Wed, 12 May 2021 13:42:44 +0000 (09:42 -0400)]
swap_pager: Zero swap info before exporting to userspace

Otherwise padding bytes are leaked.

Reported by: KMSAN
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agotruss: Decode FreeBSD 11 mknod(2) and mknodat(2)
Mark Johnston [Wed, 12 May 2021 13:42:11 +0000 (09:42 -0400)]
truss: Decode FreeBSD 11 mknod(2) and mknodat(2)

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agoUpdate the EFI timer to be called once a second
Andrew Turner [Wed, 12 May 2021 08:59:04 +0000 (08:59 +0000)]
Update the EFI timer to be called once a second

There is no need to call it evert 10ms when we need 1s granularity.
Update to update the time every second.

Reviewed by: imp, manu, tsoome
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D30227

3 years agotcp rack: improve initialisation of retransmit timeout
Michael Tuexen [Wed, 12 May 2021 15:58:56 +0000 (17:58 +0200)]
tcp rack: improve initialisation of retransmit timeout

When the TCP is in the front states, don't take the slop variable
into account. This improves consistency with the base stack.

Reviewed by: rrs@
Differential Revision: https://reviews.freebsd.org/D30230
MFC after: 1 week
Sponsored by: Netflix, Inc.

3 years agorelease: fix ports checkout if /usr/ports does not exist
Glen Barber [Wed, 12 May 2021 16:08:59 +0000 (12:08 -0400)]
release: fix ports checkout if /usr/ports does not exist

Reported by: Yasuhiro Kimura
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agorelease: remove logic to locate the svn{,lite} binary
Glen Barber [Wed, 12 May 2021 14:32:03 +0000 (10:32 -0400)]
release: remove logic to locate the svn{,lite} binary

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

3 years agorelease: follow-up to previous commit to use Git for the ports tree
Glen Barber [Wed, 12 May 2021 14:29:53 +0000 (10:29 -0400)]
release: follow-up to previous commit to use Git for the ports tree

MFC after: immediately (pending re approval)
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agorelease: update release.sh to use Git for ports tree checkouts
Glen Barber [Wed, 12 May 2021 14:27:21 +0000 (10:27 -0400)]
release: update release.sh to use Git for ports tree checkouts

MFC after: immediately (pending re approval)
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agosctp: fix locking in case of error handling during a restart
Michael Tuexen [Wed, 12 May 2021 13:29:06 +0000 (15:29 +0200)]
sctp: fix locking in case of error handling during a restart

Thanks to Taylor Brandstetter for finding the issue and providing
a patch for the userland stack.

MFC after: 3 days

3 years agocontrib/bc: update to version 4.0.2
Stefan Eßer [Wed, 12 May 2021 05:49:19 +0000 (07:49 +0200)]
contrib/bc: update to version 4.0.2

Merge commit '2858419a0ee2b8f5827de72c00618bcd69ebc5fc'

This update fixes the initialization of "scale" to 20 if started with
-l and the initial statement leads to an error (e.g. contains a syntax
error). Scale was initialized to 0 in that case.

Another change is the support of job control in interactive mode with
line editing enabled. The control characters have been interpreted as
editing commands only, prior to this version.

MFC after: 3 days

3 years agoVendor import of Gavin D. Howard's bc version 4.0.2
Stefan Eßer [Wed, 12 May 2021 05:35:58 +0000 (07:35 +0200)]
Vendor import of Gavin D. Howard's bc version 4.0.2

3 years agoRevert "Vendor import of Gavin D. Howard's bc version 4.0.2"
Stefan Eßer [Wed, 12 May 2021 05:22:37 +0000 (07:22 +0200)]
Revert "Vendor import of Gavin D. Howard's bc version 4.0.2"

The update had been performed on a check-out of the vendor branch,
but the final push lacked the target designation vendor/bc.

3 years agoVendor import of Gavin D. Howard's bc version 4.0.2
Stefan Eßer [Wed, 12 May 2021 05:15:24 +0000 (07:15 +0200)]
Vendor import of Gavin D. Howard's bc version 4.0.2

3 years agoAdd support for adding default routes for other FIBs
Andrew Fengler [Wed, 12 May 2021 01:59:10 +0000 (01:59 +0000)]
Add support for adding default routes for other FIBs

Make rc.d/routing read defaultrouter_fibN and ipv6_defaultrouter_fibN, and
set it as the default gateway for FIB N, where N is from 1 to (net.fibs - 1)
This allows adding gateways for multiple FIBs in the same format as the main
gateway. (FIB 0)

Reviewed by: olivier, rgrimes, bcr (man page)
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D22706

3 years agolibvmm: explicitly save and restore errno in vm_open()
Robert Wing [Thu, 11 Mar 2021 19:27:43 +0000 (10:27 -0900)]
libvmm: explicitly save and restore errno in vm_open()

In commit 6bb140e3ca895a14, vm_destroy() was replaced with free() to
preserve errno. However, it's possible that free() may change the errno
as well. Keep the free() call, but explicitly save and restore errno.

Noted by: jhb
Fixes: 6bb140e3ca895a14
3 years agoSixteen bit I2c addresses are always little endian.
Poul-Henning Kamp [Tue, 11 May 2021 23:07:06 +0000 (23:07 +0000)]
Sixteen bit I2c addresses are always little endian.

3 years agoPolish source to WARNS=6
Poul-Henning Kamp [Tue, 11 May 2021 22:59:23 +0000 (22:59 +0000)]
Polish source to WARNS=6

3 years agoRemove a write-only variable.
John Baldwin [Tue, 11 May 2021 21:56:23 +0000 (14:56 -0700)]
Remove a write-only variable.

While refactoring an earlier series of changes during review, the
'saved_data' variable stopped being used at the bottom of if_ioctl().

Suggested by: brooks
Reviewed by: brooks, imp, kib
Fixes: d17e0940f79f Rework compat shims in ifioctl().
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D30197

3 years agoEnsure that files with no allocated blocks are trimmed to zero length.
Kirk McKusick [Tue, 11 May 2021 21:51:06 +0000 (14:51 -0700)]
Ensure that files with no allocated blocks are trimmed to zero length.

UFS does not allow files to end with a hole; it requires that the
last block of a file be allocated. As fsck_ffs(8) initially scans
each allocated inode, it tracks the last allocated block in the
inode. It then checks that the inode's size falls in the last
allocated block. If the last allocated block falls before the size,
a `file size beyond end of allocated file' warning is issued and
the file is shortened to reference the last allocated block (to avoid
having it reference a hole at its end). If the last allocated block
falls after the size, a `partially truncated file' warning is issued
and all blocks following the block referenced by the size are freed.

Because of an incorrect unsigned comparison, this test was failing
to handle files with no allocated blocks but non-zero size (which
should have had their size reset to zero). Once that was fixed the
test started incorrectly complaining about short symbolic links
that place the link path in the inode rather than in a disk block.
Because these symbolic links have a non-zero size, but no allocated
blocks, fsck_ffs wanted to zero out their size. This patch has to
detect and avoid changing the size of such symbolic links.

Reported by:  Chuck Silvers
Tested by:    Chuck Silvers
MFC after:    1 week
Sponsored by: Netflix

3 years agocryptodev: Fix some input validation bugs
Mark Johnston [Tue, 11 May 2021 21:36:12 +0000 (17:36 -0400)]
cryptodev: Fix some input validation bugs

- When we do not have a separate IV, make sure that the IV length
  specified by the session is not larger than the payload size.
- Disallow AEAD requests without a separate IV.  crp_sanity() asserts
  that CRYPTO_F_IV_SEPARATE is set for AEAD requests, and some (but not
  all) drivers require it.
- Return EINVAL for AEAD requests if an IV is specified but the
  transform does not expect one.

Reported by: syzbot+c9e8f6ff5cb7fa6a1250@syzkaller.appspotmail.com
Reported by: syzbot+007341439ae295cee74f@syzkaller.appspotmail.com
Reported by: syzbot+46e0cc42a428b3b0a40d@syzkaller.appspotmail.com
Reported by: syzbot+2c4d670173b8bdb947df@syzkaller.appspotmail.com
Reported by: syzbot+220faa5eeb4d47b23877@syzkaller.appspotmail.com
Reported by: syzbot+e83434b40f05843722f7@syzkaller.appspotmail.com
Reviewed by: jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30154

3 years agoImplement cdev_device_add() and cdev_device_del() in the LinuxKPI.
Hans Petter Selasky [Tue, 11 May 2021 18:51:59 +0000 (20:51 +0200)]
Implement cdev_device_add() and cdev_device_del() in the LinuxKPI.

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

3 years agocdev_del() should only put it's kernel object in the LinuxKPI.
Hans Petter Selasky [Tue, 11 May 2021 18:51:35 +0000 (20:51 +0200)]
cdev_del() should only put it's kernel object in the LinuxKPI.

The destructor takes care of the rest.

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

3 years agoImplement read-only VM_SHARED flag in the LinuxKPI.
Hans Petter Selasky [Tue, 11 May 2021 18:49:13 +0000 (20:49 +0200)]
Implement read-only VM_SHARED flag in the LinuxKPI.

For use by mmap(2) callbacks.

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

3 years agoipfw.8: Fix table example
Lutz Donnerhacke [Mon, 10 May 2021 18:31:52 +0000 (20:31 +0200)]
ipfw.8: Fix table example

Fix some erronous lines in the example section.

PR: 248943
Submitted by: Jose Luis Duran
MFC after: 2 weeks
Reviewers: ae, manpages (gbe)
Differential Revision: https://reviews.freebsd.org/D30191

3 years agonetinet6 tests: Fix Python warning
Kristof Provost [Tue, 11 May 2021 13:47:45 +0000 (15:47 +0200)]
netinet6 tests: Fix Python warning

Python 3.8 warns about line 112:
    'SyntaxWarning: "is" with a literal. Did you mean "=="?'

Use '==' as Python suggests.

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

3 years agoxen/blkback: fix reconnection of backend
Roger Pau Monné [Tue, 11 May 2021 10:19:29 +0000 (12:19 +0200)]
xen/blkback: fix reconnection of backend

The hotplug script will be executed only once for each backend,
regardless of the frontend triggering reconnections. Fix blkback to
deal with the hotplug script being executed only once, so that
reconnections don't stall waiting for a hotplug script execution
that will never happen.

As a result of the fix move the initialization of dev_mode, dev_type
and dev_name to the watch callback, as they should be set only once
the first time the backend connects.

This fix is specially relevant for guests wanting to use UEFI OVMF
firmware, because OVMF will use Xen PV block devices and disconnect
afterwards, thus allowing them to be used by the guest OS. Without
this change the guest OS will stall waiting for the block backed to
attach.

Fixes: de0bad00010c ('blkback: add support for hotplug scripts')
MFC after: 1 week
Sponsored by: Citrix Systems R&D

3 years agotcp: In rack, we must only convert restored rtt when the hostcache does restore them.
Randall Stewart [Tue, 11 May 2021 12:15:05 +0000 (08:15 -0400)]
tcp: In rack, we must only convert restored rtt when the hostcache does restore them.

Rack now after the previous commit is very careful to translate any
value in the hostcache for srtt/rttvar into its proper format. However
there is a snafu here in that if tp->srtt is 0 is the only time that
the HC will actually restore the srtt. We need to then only convert
the srtt restored when it is actually restored. We do this by making
sure it was zero before the call to cc_conn_init and it is non-zero
afterwards.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30213

3 years agomrouter: do not loopback packets unconditionally
Wojciech Macek [Fri, 23 Apr 2021 06:49:27 +0000 (08:49 +0200)]
mrouter: do not loopback packets unconditionally

Looping back router multicast traffic signifficantly
stresses network stack. Add possibility to disable or enable
loopbacked based on sysctl value.

Reported by:    Daniel Deville
Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D29947

3 years agomroute: fix race condition during mrouter shutting down
Wojciech Macek [Fri, 23 Apr 2021 03:57:03 +0000 (05:57 +0200)]
mroute: fix race condition during mrouter shutting down

    There is a race condition between V_ip_mrouter de-init
    and ip_mforward handling. It might happen that mrouted
    is cleaned up after V_ip_mrouter check and before
    processing packet in ip_mforward.
    Use epoch call aproach, similar to IPSec which also handles
    such case.

Reported by:    Damien Deville
Obtained from: Stormshield
Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D29946

3 years agotruss: Add missing underscore to compat_prefix for FreeBSD32
Alex Richardson [Tue, 11 May 2021 09:52:56 +0000 (10:52 +0100)]
truss: Add missing underscore to compat_prefix for FreeBSD32

I accidentally dropped this in the final version of D27625, so it didn't
actually work as intended. I found this while testing the MFC to stable/13.

MFC after: immediately
Fixes: 7daca4e2043f ("truss: improved support for decoding compat32 arguments")

3 years agosbin/ipfw: Allow tablearg as hostname
Lutz Donnerhacke [Tue, 11 May 2021 08:22:16 +0000 (10:22 +0200)]
sbin/ipfw: Allow tablearg as hostname

Hostnames starting with "tablearg" are considered as a functional
argument instead of a literal.

Reported by: ae
Reviewers: ae
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30208

3 years agoClean up copyright messages.
Kirk McKusick [Tue, 11 May 2021 06:01:58 +0000 (23:01 -0700)]
Clean up copyright messages.

Reported by:  Yoshihiro Ota
MFC after:    3 days
Differential Revision: https://reviews.freebsd.org/D29354

3 years agocache: fix lockless absolute symlink traversal to non-fp mounts
Mateusz Guzik [Tue, 11 May 2021 03:48:08 +0000 (05:48 +0200)]
cache: fix lockless absolute symlink traversal to non-fp mounts

Said lookups would incorrectly fail with EOPNOTSUP.

Reported by: kib

3 years agopowerpc/radix pmap: Convert stat counters from ulongs to counters
Justin Hibbits [Tue, 11 May 2021 02:23:14 +0000 (21:23 -0500)]
powerpc/radix pmap: Convert stat counters from ulongs to counters

This should help performance a hair, for concurrent stat updates, by
reducing contention on cache lines.

3 years agopowerpc/mmu: Actually use the Radix pmap_align_superpage function
Justin Hibbits [Tue, 11 May 2021 02:23:04 +0000 (21:23 -0500)]
powerpc/mmu: Actually use the Radix pmap_align_superpage function

This was missed in the conversion to ifuncs.  It might help improve
promotion rates.

3 years agonfscl: Delete unneeded redundant MODULE_DEPEND() calls
Rick Macklem [Tue, 11 May 2021 00:34:29 +0000 (17:34 -0700)]
nfscl: Delete unneeded redundant MODULE_DEPEND() calls

There are two module declarations in the nfscl.ko module for "nfscl"
and "nfs".  Both of these declarations had MODULE_DEPEND() calls.
This patch deletes the MODULE_DEPEND() calls for "nfs" to avoid
confusion with respect to what modules this module is dependent upon.

The patch also adds comments explaining why there are two module
declarations within the module.

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

3 years agovfs: Fix error handling in vn_fullpath_hardlink()
Mark Johnston [Tue, 11 May 2021 00:18:00 +0000 (20:18 -0400)]
vfs: Fix error handling in vn_fullpath_hardlink()

vn_fullpath_any_smr() will return a positive error number if the
caller-supplied buffer isn't big enough.  In this case the error must be
propagated up, otherwise we may copy out uninitialized bytes.

Reported by: syzkaller+KMSAN
Reviewed by: mjg, kib
MFC aftr: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30198

3 years agortld: preserve the 'seen' state of the dlerror message in errmsg_save()
Konstantin Belousov [Mon, 10 May 2021 19:02:19 +0000 (22:02 +0300)]
rtld: preserve the 'seen' state of the dlerror message in errmsg_save()

rtld preserves its current error message around calls to user init/fini
lists, to not override original error with potential secondary errors
caused by user code recursing into rtld.  After 4d9128da54f8f8e2a29190,
the preservation of the string itself is not enough, the 'seen'
indicator must be preserved as well.  Otherwise, since new code does not
clear string (it cannot), call to _rtld_error() from errmsg_restore()
revived whatever message was consumed last.

Change errmsg_save() to return structure recording both 'seen' indicator
and the message, if any.

PR: 255698
Reported by: Eugene M. Kim <astralblue@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

3 years agoopenat(2): add O_EMPTY_PATH
Konstantin Belousov [Thu, 6 May 2021 17:16:53 +0000 (20:16 +0300)]
openat(2): add O_EMPTY_PATH

It reopens the passed file descriptor, checking the file backing vnode'
current access rights against open mode. In particular, this flag allows
to convert file descriptor opened with O_PATH, into operable file
descriptor, assuming permissions allow that.

Reviewed by: markj
Tested by: Andrew Walker <awalker@ixsystems.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30148

3 years agonetstat: fix typo from 0471a8c73402
Richard Scheffenegger [Mon, 10 May 2021 18:49:19 +0000 (20:49 +0200)]
netstat: fix typo from 0471a8c73402

3 years agotcp: SACK Lost Retransmission Detection (LRD)
Richard Scheffenegger [Mon, 10 May 2021 16:47:47 +0000 (18:47 +0200)]
tcp: SACK Lost Retransmission Detection (LRD)

Recover from excessive losses without reverting to a
retransmission timeout (RTO). Disabled by default, enable
with sysctl net.inet.tcp.do_lrd=1

Reviewed By: #transport, rrs, tuexen, #manpages
Sponsored by: Netapp, Inc.
Differential Revision: https://reviews.freebsd.org/D28931

3 years agosh: implement persistent history storage
Baptiste Daroussin [Tue, 30 Mar 2021 08:28:08 +0000 (10:28 +0200)]
sh: implement persistent history storage

Implement persistent history storage:
the strategy is simple at start: loads the existing .sh_history file
at exit dump it.

The implementation respects the HISTFILE variable and its POSIX
definition: ~/.sh_history is used if HISTFILE is not set.

to avoid sh to create the history file, set HISTSIZE to 0 or HISTFILE to
en empty value

Co-authored-by: pstef
Reviewed by: jilles
Differential Revision: https://reviews.freebsd.org/D29493

3 years agotcp:Host cache and rack ending up with incorrect values.
Randall Stewart [Mon, 10 May 2021 15:25:51 +0000 (11:25 -0400)]
tcp:Host cache and rack ending up with incorrect values.

The hostcache up to now as been updated in the discard callback
but without checking if we are all done (the race where there are
more than one calls and the counter has not yet reached zero). This
means that when the race occurs, we end up calling the hc_upate
more than once. Also alternate stacks can keep there srtt/rttvar
in different formats (example rack keeps its values in microseconds).
Since we call the hc_update *before* the stack fini() then the
values will be in the wrong format.

Rack on the other hand, needs to convert items pulled from the
hostcache into its internal format else it may end up with
very much incorrect values from the hostcache. In the process
lets commonize the update mechanism for srtt/rttvar since we
now have more than one place that needs to call it.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30172

3 years agoin6_mcast: Return EADDRINUSE when we've already joined the group
Kristof Provost [Tue, 4 May 2021 17:23:15 +0000 (19:23 +0200)]
in6_mcast: Return EADDRINUSE when we've already joined the group

Distinguish between truly invalid requests and those that fail because
we've already joined the group. Both cases fail, but differentiating
them allows userspace to make more informed decisions about what the
error means.

For example. radvd tries to join the all-routers group on every SIGHUP.
This fails, because it's already joined it, but this failure should be
ignored (rather than treated as a sign that the interface's multicast is
broken).

This puts us in line with OpenBSD, NetBSD and Linux.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30111

3 years agoRevert "getty: push assignment to inner block."
Xin LI [Sun, 9 May 2021 16:05:52 +0000 (09:05 -0700)]
Revert "getty: push assignment to inner block."

This reverts commit c7b8bc367f18210d233b0e2185b5ce0d55c9ccaa.

Pointed out by: trasz

3 years agofull(4): Use correct section name for AUTHORS
Gordon Bergling [Sun, 9 May 2021 15:31:52 +0000 (17:31 +0200)]
full(4): Use correct section name for AUTHORS

PR: 255715
Reported by: Christos Margiolis <christos at christosmarg dot xyz>
MFC after: 3 days

3 years agorpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen
Juraj Lutter [Fri, 7 May 2021 21:48:21 +0000 (23:48 +0200)]
rpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen

- Recognize raspberrypi,firmware-ts touchscreen
- Move the driver from ofwbus to simplebus

Reviewed by: manu
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30169

3 years agogetty: push assignment to inner block.
Xin LI [Sun, 9 May 2021 04:53:58 +0000 (21:53 -0700)]
getty: push assignment to inner block.

No functional change.

MFC after: 2 weeks

3 years agogetty: const'ify search pointer.
Xin LI [Sun, 9 May 2021 04:52:41 +0000 (21:52 -0700)]
getty: const'ify search pointer.

No functional change.

MFC after: 2 weeks

3 years agosbin/ipfw: Fix parsing error in table based forward
Lutz Donnerhacke [Fri, 7 May 2021 18:59:34 +0000 (20:59 +0200)]
sbin/ipfw: Fix parsing error in table based forward

The argument parser does not recognise the optional port for an
"tablearg" argument.  Fix simplifies the code by make the internal
representation expicit for the parser.

PR: 252744
MFC: 1 week
Reported by: <bugs.freebsd.org@mx.zzux.com>
Approved by: nc
Tested by: <bugs.freebsd.org@mx.zzux.com>
Differential Revision: https://reviews.freebsd.org/D30164

3 years agoofw: support for a single 'port' DTS property.
Ruslan Bukin [Sat, 8 May 2021 14:41:57 +0000 (15:41 +0100)]
ofw: support for a single 'port' DTS property.

On rk3399 the VOP-little node has a single 'port' property (not a
collection of 'ports' or indexed ports).

Reviewed by: manu
Sponsored by: UKRI
Differential Revision: https://reviews.freebsd.org/D30165

3 years agostress2: Added two new syzkaller reproducers. Update the exclude list
Peter Holm [Sat, 8 May 2021 06:24:42 +0000 (08:24 +0200)]
stress2: Added two new syzkaller reproducers. Update the exclude list

3 years agoMake encode/decode extra time functions inline.
Fedor Uporov [Sat, 8 May 2021 03:42:20 +0000 (06:42 +0300)]
Make encode/decode extra time functions inline.

Mentioned by:   pfg
MFC after:      2 weeks

3 years agonfscl: Add support for va_birthtime to NFSv4
Rick Macklem [Sat, 8 May 2021 00:30:56 +0000 (17:30 -0700)]
nfscl: Add support for va_birthtime to NFSv4

There is a NFSv4 file attribute called TimeCreate
that can be used for va_birthtime.
r362175 added some support for use of TimeCreate.
This patch completes support of va_birthtime by adding
support for setting this attribute to the server.
It also eanbles the client to
acquire and set the attribute for a NFSv4
server that supports the attribute.

Reviewed by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30156

3 years agoThis takes Warners suggested approach to making it so that
Randall Stewart [Fri, 7 May 2021 21:32:32 +0000 (17:32 -0400)]
This takes Warners suggested approach to making it so that
platforms that for whatever reason cannot include the RATELIMIT option
can still work with rack. It adds two dummy functions that rack will
call and find out that the highest hw supported b/w is 0 (which
kinda makes sense and rack is already prepared to handle).

Reviewed by: Michael Tuexen, Warner Losh
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30163

3 years agoFix panic when trying to delete non-existent gateway in multipath route.
Alexander V. Chernikov [Fri, 7 May 2021 20:36:50 +0000 (20:36 +0000)]
Fix panic when trying to delete non-existent gateway in multipath route.

IF non-existend gateway was specified, the code responsible for calculating
 an updated nexthop group, returned the same already-used nexthop group.
After the route table update, the operation result contained the same
 old & new nexthop groups. Thus, the code responsible for decomposing
 the notification to the list of simple nexthop-level notifications,
 was not able to find any differences. As a result, it hasn't updated any
  of the "simple" notification fields, resulting in empty rtentry pointer.
This empty pointer was the direct reason of a panic.

Fix the problem by returning ESRCH when the new nexthop group is the same
 as the old one after applying gateway filter.

Reported by: Michael <michael.adm at gmail.com>
PR: 255665
MFC after: 3 days