]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agotools/tools/locale: skip control character widths
Yuri Pankov [Wed, 23 Dec 2020 12:49:25 +0000 (15:49 +0300)]
tools/tools/locale: skip control character widths

Do not explicitly encode control characters widths as 0
allowing wcwidth() to return the proper implicit value for
non-printable characters (-1).

Reported by: naddy

3 years agopf: Use counter(9) for pf_state byte/packet tracking
Kristof Provost [Wed, 23 Dec 2020 08:37:59 +0000 (09:37 +0100)]
pf: Use counter(9) for pf_state byte/packet tracking

This improves cache behaviour by not writing to the same variable from
multiple cores simultaneously.

pf_state is only used in the kernel, so can be safely modified.

Reviewed by: Lutz Donnerhacke, philip
MFC after: 1 week
Sponsed by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27661

3 years agopf tests: Verify (tcp) checksum modification on unaligned options
Kristof Provost [Sat, 19 Dec 2020 15:06:03 +0000 (16:06 +0100)]
pf tests: Verify (tcp) checksum modification on unaligned options

It turns out pf incorrectly updates the TCP checksum if the TCP option
we're modifying is not 2-byte algined with respect to the start of the
packet.

Create a TCP packet with such an option and throw it through a scrub
rule, which will update timestamps and modify the packet.

PR: 240416
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27688

3 years agopf tests: Sort Makefile entries
Kristof Provost [Sat, 19 Dec 2020 14:27:33 +0000 (15:27 +0100)]
pf tests: Sort Makefile entries

MFC after: 1 week

3 years agopf: Fix unaligned checksum updates
Kristof Provost [Sun, 20 Dec 2020 20:06:32 +0000 (21:06 +0100)]
pf: Fix unaligned checksum updates

The algorithm we use to update checksums only works correctly if the
updated data is aligned on 16-bit boundaries (relative to the start of
the packet).

Import the OpenBSD fix for this issue.

PR: 240416
Obtained from: OpenBSD
MFC after: 1 week
Reviewed by: tuexen (previous version)
Differential Revision: https://reviews.freebsd.org/D27696

3 years agoNo need to stop XHCI endpoints in disabled state.
Hans Petter Selasky [Wed, 23 Dec 2020 10:54:42 +0000 (11:54 +0100)]
No need to stop XHCI endpoints in disabled state.

Some AMD XHCI implementations apparently assert a permanent
internal failure if this happens.

Submitted by: ali.abdallah@suse.com
PR: 251503
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoRemove not needed variable initialization.
Hans Petter Selasky [Wed, 23 Dec 2020 10:37:44 +0000 (11:37 +0100)]
Remove not needed variable initialization.
And switch from int to bool while at it.

Reviewed by: melifaro@
Differential Revision: https://reviews.freebsd.org/D27725
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agox86: stop punishing VMs with low priority for TSC timecounter
Konstantin Belousov [Mon, 21 Dec 2020 17:02:31 +0000 (19:02 +0200)]
x86: stop punishing VMs with low priority for TSC timecounter

I suspect that virtualization techniques improved from the time when we
have to effectively disable TSC use in VM.  For instance, it was reported
(complained) in https://github.com/JuliaLang/julia/issues/38877 that
FreeBSD is groundlessly slow on AWS with some loads.

Remove the check and start watching for complaints.

Reviewed by: emaste, grehan
Discussed with: cperciva
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27629

3 years agovxlan: stop checking CSUM_ENCAP_VXLAN when converting inner CSUM flags into normal...
Konstantin Belousov [Mon, 21 Dec 2020 16:59:26 +0000 (18:59 +0200)]
vxlan: stop checking CSUM_ENCAP_VXLAN when converting inner CSUM flags into normal, for decapsulation.

The packet, if processed at this point, was already parsed to be UDP
directed to a vxlan port.

Connect-X 4+ does not provide easy method to infer which parser
processed the packet, so driver cannot set the flag without a lot of
efforts which are only to satisfy the formal requirements.

Reviewed by: bryanv, np
Sponsored by: Mellanox Technologies/NVidia Networking
Differential revision: https://reviews.freebsd.org/D27449
MFC after: 1 week

3 years agopsm(4): Always initialize Synaptics touchpad report range with defaults
Vladimir Kondratyev [Tue, 22 Dec 2020 20:44:42 +0000 (23:44 +0300)]
psm(4): Always initialize Synaptics touchpad report range with defaults

Otherwise libinput refuses to recoginize some Synaptics touchpads with
"kernel bug: device has min == max on ABS_X" message in Xorg.log.

PR: 251149
Reported-by: Jens Grassel <freebsd-ports@jan0sch.de>
Tested-by: Jens Grassel <freebsd-ports@jan0sch.de>
MFC-after: 2 weeks

3 years agoacpi_wmi(4): Allow attachment to ACPI node if EC is not found
Vladimir Kondratyev [Mon, 21 Dec 2020 15:48:50 +0000 (18:48 +0300)]
acpi_wmi(4): Allow attachment to ACPI node if EC is not found

Conducted tests showed that Embedded Controller is not mandatory for
WMI extensions to work.

Reported-by: yuripv
Reviewed-by: avg
MFC-after: 2 weeks
Differential-Revision: https://reviews.freebsd.org/D27653

3 years agocyapa(4): Add support for evdev protocol
Vladimir Kondratyev [Mon, 21 Dec 2020 15:44:28 +0000 (18:44 +0300)]
cyapa(4): Add support for evdev protocol

Tested-by: Matthias Apitz <guru@unixarea.de>
MFC-after: 2 weeks

3 years agocyapa(4): Make button detection matching ChromeOS driver
Vladimir Kondratyev [Mon, 21 Dec 2020 15:24:09 +0000 (18:24 +0300)]
cyapa(4): Make button detection matching ChromeOS driver

Tested-by: Matthias Apitz <guru@unixarea.de>
MFC-after: 2 weeks

3 years agoImprove address generation in the early arm64 boot
Andrew Turner [Wed, 23 Dec 2020 07:24:07 +0000 (07:24 +0000)]
Improve address generation in the early arm64 boot

The adr instruction allows for an address of +-1M from the instruction.
If we replace these with an adrp and an add instruction we can generate
an address +-4G. The adrp will get an address of the 4k page the label
is within, and the add uses the :lo12: prefix to add just the low bits
to this address.

This will allow us to move things around with fewer issues than if we
needed to keep them within the +-1MB range.

Sponsored by: Innovate UK

3 years agocache: fix up cache_hold_vnode comment
Mateusz Guzik [Wed, 23 Dec 2020 07:23:08 +0000 (07:23 +0000)]
cache: fix up cache_hold_vnode comment

3 years agonetgraph: Fix ng_ether's shutdown handing
Mark Johnston [Wed, 23 Dec 2020 05:11:16 +0000 (00:11 -0500)]
netgraph: Fix ng_ether's shutdown handing

When tearing down a VNET, netgraph sends shutdown messages to all of the
nodes before detaching interfaces (SI_SUB_NETGRAPH comes before
SI_SUB_INIT_IF in teardown order).  ng_ether nodes handle this by
destroying themselves without detaching from the parent ifnet.  Then,
when ifnets go away they detach their ng_ether nodes again, triggering a
use-after-free.

Handle this by modifying ng_ether_shutdown() to detach from the ifnet.
If the shutdown was triggered by an ifnet being destroyed, we will clear
priv->ifp in the ng_ether detach callback, so priv->ifp may be NULL.

Also get rid of the printf in vnet_netgraph_uninit().  It can be
triggered trivially by ng_ether since ng_ether_shutdown() persists the
node unless NG_REALLY_DIE is set.

PR: 233622
Reviewed by: afedorov, kp, Lutz Donnerhacke
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27662

3 years agoRemove unused includes.
Xin LI [Wed, 23 Dec 2020 05:04:36 +0000 (21:04 -0800)]
Remove unused includes.

3 years agonewvers.sh: fix sense of git dirty check
Ed Maste [Wed, 23 Dec 2020 04:31:15 +0000 (23:31 -0500)]
newvers.sh: fix sense of git dirty check

Previously we reported -dirty for an unmodified tree, and no -dirty if
there were changes.

PR: 252028
Reported by: John Kennedy

3 years agoMark the repository has been converted to Git
Li-Wen Hsu [Wed, 23 Dec 2020 04:27:27 +0000 (12:27 +0800)]
Mark the repository has been converted to Git

This is the first Git commit to src.

Sponsored by: The FreeBSD Foundation

3 years agoMark the repository as being converted to Git.
Li-Wen Hsu [Sun, 20 Dec 2020 02:59:44 +0000 (02:59 +0000)]
Mark the repository as being converted to Git.

This is the last Subversion commit to src.

Sponsored by: The FreeBSD Foundation

3 years agoFilter TCP connections to SO_REUSEPORT_LB listen sockets by NUMA domain
Andrew Gallatin [Sat, 19 Dec 2020 22:04:46 +0000 (22:04 +0000)]
Filter TCP connections to SO_REUSEPORT_LB listen sockets by NUMA domain

In order to efficiently serve web traffic on a NUMA
machine, one must avoid as many NUMA domain crossings as
possible. With SO_REUSEPORT_LB, a number of workers can share a
listen socket. However, even if a worker sets affinity to a core
or set of cores on a NUMA domain, it will receive connections
associated with all NUMA domains in the system. This will lead to
cross-domain traffic when the server writes to the socket or
calls sendfile(), and memory is allocated on the server's local
NUMA node, but transmitted on the NUMA node associated with the
TCP connection. Similarly, when the server reads from the socket,
he will likely be reading memory allocated on the NUMA domain
associated with the TCP connection.

This change provides a new socket ioctl, TCP_REUSPORT_LB_NUMA. A
server can now tell the kernel to filter traffic so that only
incoming connections associated with the desired NUMA domain are
given to the server. (Of course, in the case where there are no
servers sharing the listen socket on some domain, then as a
fallback, traffic will be hashed as normal to all servers sharing
the listen socket regardless of domain). This allows a server to
deal only with traffic that is local to its NUMA domain, and
avoids cross-domain traffic in most cases.

This patch, and a corresponding small patch to nginx to use
TCP_REUSPORT_LB_NUMA allows us to serve 190Gb/s of kTLS encrypted
https media content from dual-socket Xeons with only 13% (as
measured by pcm.x) cross domain traffic on the memory controller.

Reviewed by: jhb, bz (earlier version), bcr (man page)
Tested by: gonzo
Sponsored by: Netfix
Differential Revision: https://reviews.freebsd.org/D21636

3 years agoOptionally bind ktls threads to NUMA domains
Andrew Gallatin [Sat, 19 Dec 2020 21:46:09 +0000 (21:46 +0000)]
Optionally bind ktls threads to NUMA domains

When ktls_bind_thread is 2, we pick a ktls worker thread that is
bound to the same domain as the TCP connection associated with
the socket. We use roughly the same code as netinet/tcp_hpts.c to
do this. This allows crypto to run on the same domain as the TCP
connection is associated with. Assuming TCP_REUSPORT_LB_NUMA
(D21636) is in place & in use, this ensures that the crypto source
and destination buffers are local to the same NUMA domain as we're
running crypto on.

This change (when TCP_REUSPORT_LB_NUMA, D21636, is used) reduces
cross-domain traffic from over 37% down to about 13% as measured
by pcm.x on a dual-socket Xeon using nginx and a Netflix workload.

Reviewed by: jhb
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21648

3 years agolibc: Fix most issues reported by mandoc
Gordon Bergling [Sat, 19 Dec 2020 14:54:28 +0000 (14:54 +0000)]
libc: Fix most issues reported by mandoc

- varios "new sentence, new line" warnings
- varios "sections out of conventional order" warnings
- varios "unusual Xr order" warnings
- varios "missing section argument" warnings
- varios "no blank before trailing delimiter" warnings
- varios "normalizing date format" warnings

MFC after: 1 month

3 years agotrim(8): Fix a few issues reported by mandoc
Gordon Bergling [Sat, 19 Dec 2020 13:56:19 +0000 (13:56 +0000)]
trim(8): Fix a few issues reported by mandoc

- new sentence, new line
- unusual Xr order: ioctl(2) after da(4)
- unusual Xr order: sysexits(3) after nda(4)

MFC after: 1 week

3 years agozonectl(8): Fix a few issues reported by mandoc
Gordon Bergling [Sat, 19 Dec 2020 13:51:46 +0000 (13:51 +0000)]
zonectl(8): Fix a few issues reported by mandoc

- Add missing quotation mark for a comment above the .Dd
- inserting missing end of block: Sh breaks Bd
- skipping paragraph macro: Pp before Bl
- skipping paragraph macro: Pp before Bd
- empty block: Bd

MFC after: 1 week

3 years agonfsv4(4): Fix a few issues reported by mandoc
Gordon Bergling [Sat, 19 Dec 2020 13:45:39 +0000 (13:45 +0000)]
nfsv4(4): Fix a few issues reported by mandoc

- new sentence, new line
- function name without markup: rtalloc()
- function name without markup: VOP_RECLAIM()

MFC after: 1 week

3 years agobluetooth: Fix a mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 13:36:59 +0000 (13:36 +0000)]
bluetooth: Fix a mandoc related issues

- new sentence, new line
- sections out of conventional order: Sh FILES
- unusual Xr order: bthost(1) after bthidd(8)
- no blank before trailing delimiter
- whitespace at end of input line
- sections out of conventional order: Sh EXIT STATUS

MFC after: 1 week

3 years agompsutil(8): Remove trailing whitespace
Gordon Bergling [Sat, 19 Dec 2020 13:23:26 +0000 (13:23 +0000)]
mpsutil(8): Remove trailing whitespace

MFC after: 1 week

3 years agobhyvectl(8): Normalize the man page date
Gordon Bergling [Sat, 19 Dec 2020 13:21:40 +0000 (13:21 +0000)]
bhyvectl(8): Normalize the man page date

MFC after: 1 week

3 years agocamdd(8): Fix the man page date
Gordon Bergling [Sat, 19 Dec 2020 13:17:25 +0000 (13:17 +0000)]
camdd(8): Fix the man page date

The comment before the .Dd macro was missing a quotation mark, so that
the date of the man page was always today.

MFC after: 3 days

3 years agoconfig: Fix a few mandoc related errors
Gordon Bergling [Sat, 19 Dec 2020 13:11:44 +0000 (13:11 +0000)]
config: Fix a few mandoc related errors

- new sentence, new line
- no blank before trailing delimiter

MFC after: 1 week

3 years agodevctl(8): Correct "sections out of conventional order" error
Gordon Bergling [Sat, 19 Dec 2020 13:05:54 +0000 (13:05 +0000)]
devctl(8): Correct "sections out of conventional order" error

MFC after: 1 week

3 years agopatch(1): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 13:00:17 +0000 (13:00 +0000)]
patch(1): Fix a few mandoc related issues

- no blank before trailing delimiter

MFC after: 1 week

3 years agouname(1): Fix a typo in the man page date
Gordon Bergling [Sat, 19 Dec 2020 12:55:27 +0000 (12:55 +0000)]
uname(1): Fix a typo in the man page date

MFC after: 3 days

3 years agoident(1): Normalizing date format
Gordon Bergling [Sat, 19 Dec 2020 12:54:00 +0000 (12:54 +0000)]
ident(1): Normalizing date format

MFC after: 3 days

3 years agoipfw(8): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 12:47:40 +0000 (12:47 +0000)]
ipfw(8): Fix a few mandoc related issues

- no blank before trailing delimiter
- missing section argument: Xr inet_pton
- skipping paragraph macro: Pp before Ss
- unusual Xr order: syslogd after sysrc
- tab in filled text

There were a few multiline NAT examples which used the .Dl macro with
tabs. I converted them to .Bd, which is a more suitable macro for that case.

MFC after: 1 week

3 years agoping(8): Fix a mandoc related issue
Gordon Bergling [Sat, 19 Dec 2020 11:57:47 +0000 (11:57 +0000)]
ping(8): Fix a mandoc related issue

- unusual Xr punctuation: none before traceroute6(8)

3 years agonvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section
Gordon Bergling [Sat, 19 Dec 2020 11:47:38 +0000 (11:47 +0000)]
nvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section

- inserting missing end of block: Ss breaks Bl
- skipping paragraph macro: Pp before Ss
- referenced manual not found: Xr nvme 4 (2 times)
- unknown standard specifier: St The

The macro .St can only be used for standards known by mdoc(7). So add a
SEE ALSO section and add a reference to the NVM Express Base Specification.

MFC after: 2 weeks

3 years agoEnsure a minimum packet length before creating a mbuf in if_ure.
Hans Petter Selasky [Sat, 19 Dec 2020 11:03:54 +0000 (11:03 +0000)]
Ensure a minimum packet length before creating a mbuf in if_ure.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agodevd.conf(5): Fix a mandoc related issue
Gordon Bergling [Sat, 19 Dec 2020 11:03:04 +0000 (11:03 +0000)]
devd.conf(5): Fix a mandoc related issue

- sections out of conventional order: Sh SEE ALSO

MFC after: 1 week

3 years agoMove SYSCTL_ADD_PROC() to unlocked context in if_ure to avoid lock order reversal.
Hans Petter Selasky [Sat, 19 Dec 2020 11:00:11 +0000 (11:00 +0000)]
Move SYSCTL_ADD_PROC() to unlocked context in if_ure to avoid lock order reversal.

MFC after: 1 week
Reported by: Mark Millard <marklmi@yahoo.com>
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agosysctl(9): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 10:31:25 +0000 (10:31 +0000)]
sysctl(9): Fix a few mandoc related issues

- missing comma before name: Nm SYSCTL_UQUAD
- bad NAME section content: text

MFC after: 1 week

3 years agoofw_bus_status_okay(9): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 10:26:40 +0000 (10:26 +0000)]
ofw_bus_status_okay(9): Fix a few mandoc related issues

- missing comma before name: Nm ofw_bus_status_okay
- missing comma before name: Nm ofw_bus_node_status_okay
- skipping paragraph macro: Pp after Sh

MFC after: 1 week

3 years agoofw_bus_is_compatible(9): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 10:24:36 +0000 (10:24 +0000)]
ofw_bus_is_compatible(9): Fix a few mandoc related issues

- missing comma before name: Nm ofw_bus_is_compatible_strict
- missing comma before name: Nm ofw_bus_node_is_compatible
- missing comma before name: Nm ofw_bus_search_compatible
- skipping paragraph macro: Pp after Sh

MFC after: 1 week

3 years agofail(9): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 10:20:22 +0000 (10:20 +0000)]
fail(9): Fix a few mandoc related issues

- function name without markup: return()
- function name without markup: print()

MFC after: 1 week

3 years agodriver(9): Fix a mandoc related issue
Gordon Bergling [Sat, 19 Dec 2020 10:18:21 +0000 (10:18 +0000)]
driver(9): Fix a mandoc related issue

- sections out of conventional order: Sh SEE ALSO

MFC after: 1 week

3 years agobhnd_erom(9): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 10:15:58 +0000 (10:15 +0000)]
bhnd_erom(9): Fix a few mandoc related issues

- skipping paragraph macro: Pp before Bl
- skipping paragraph macro: Pp after Ss
- skipping paragraph macro: Pp at the end of Ss
- unusual Xr punctuation: none before bhnd_driver_get_erom_class(9)
- unusual Xr punctuation: none before bus_space(9)

MFC after: 1 week

3 years agobhnd(9): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 10:11:37 +0000 (10:11 +0000)]
bhnd(9): Fix a few mandoc related issues

- skipping paragraph macro: Pp before Bl
- skipping paragraph macro: Pp at the end of Ss
- missing section argument: Xr device_set_desc
- unusual Xr punctuation: none before bhnd_erom(9)

MFC after: 1 week

3 years agodisk(9): Fix a few mandoc related errors
Gordon Bergling [Sat, 19 Dec 2020 09:55:02 +0000 (09:55 +0000)]
disk(9): Fix a few mandoc related errors

- function name without markup: g_io_deliver()
- function name without markup: disk_gone()
- sections out of conventional order: Sh SEE ALSO
- referenced manual not found: Xr MAKE_DEV 9

Actually the man page of MAKE_DEV has never existed.

MFC after: 3 days

3 years agoaccept_filter(9): Fix a mandoc related error
Gordon Bergling [Sat, 19 Dec 2020 09:40:05 +0000 (09:40 +0000)]
accept_filter(9): Fix a mandoc related error

- no blank before trailing delimiter

3 years agortld-elf: link udivmoddi4 from compiler_rt
Ryan Libby [Sat, 19 Dec 2020 08:38:31 +0000 (08:38 +0000)]
rtld-elf: link udivmoddi4 from compiler_rt

This fixes the gcc9 build of rtld-elf32 on amd64, which needed an
implementation of udivmoddi4.

rtld-elf uses certain functions normally found in libc, and so it
includes certain files from libc in its own build.  It has two
mechanisms to include files from libc: one that rebuilds source files in
the rtld-elf environment, and one that extracts object files from a
purpose-built no-SSP PIC archive.

In addition to libc functions, rtld-elf may need to link functions
normally found in libcompiler_rt (formerly libgcc).  Now, add an ability
to rebuild libcompiler_rt source files in the rtld-elf environment.  We
don't yet have a need for an object file extraction mechanism.

libcompiler_rt could also supply udivdi3 and umoddi3, but leave them
alone for now.

Reviewed by: arichardson, kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27665

3 years agortld-libc: fix incremental build
Ryan Libby [Sat, 19 Dec 2020 08:38:27 +0000 (08:38 +0000)]
rtld-libc: fix incremental build

ar cr is an update of an archive, not a creation of a new one.  During
incremental builds (e.g. with meta mode) the archive was not getting
cleaned, and so could retain now-deleted objects from previous builds.
Now, delete the archive before creating/updating it.

Reviewed by: arichardson, bdrewery, kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27663

3 years agokern: cpuset: allow jails to modify child jails' roots
Kyle Evans [Sat, 19 Dec 2020 03:30:06 +0000 (03:30 +0000)]
kern: cpuset: allow jails to modify child jails' roots

This partially lifts a restriction imposed by r191639 ("Prevent a superuser
inside a jail from modifying the dedicated root cpuset of that jail") that's
perhaps beneficial after r192895 ("Add hierarchical jails."). Jails still
cannot modify their own cpuset, but they can modify child jails' roots to
further restrict them or widen them back to the modifying jails' own mask.

As a side effect of this, the system root may once again widen the mask of
jails as long as they're still using a subset of the parent jails' mask.
This was previously prevented by the fact that cpuset_getroot of a root set
will return that root, rather than the root's parent -- cpuset_modify uses
cpuset_getroot since it was introduced in r327895, previously it was just
validating against set->cs_parent which allowed the system root to widen
jail masks.

Reviewed by: jamie
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27352

3 years agologin(1): when exporting variables check the result of setenv(3)
Pedro F. Giffuni [Sat, 19 Dec 2020 03:07:38 +0000 (03:07 +0000)]
login(1): when exporting variables check the result of setenv(3)

When exporting a variable we correctly check all the preconditions that
could make setenv(3) fail. Checking the setenv(3) return value seems
redundant, but given that login(1) is critical, it doesn't hurt to have
a post-check.

This change is based on the "Principles of Secure Coding" course by
Matthew Bishop, PhD., which specifically discusses this code in FreeBSD.

(This change redoes r368776 due to a silly mistake)

3 years agoRevert r368776:
Pedro F. Giffuni [Sat, 19 Dec 2020 02:42:14 +0000 (02:42 +0000)]
Revert r368776:
login(1): when exporting variables check the result of setenv(3)

mismatch: the return value upon error is -1, so the code was not
doing nothing.

3 years agologin(1): when exporting variables check the result of setenv(3)
Pedro F. Giffuni [Sat, 19 Dec 2020 02:23:53 +0000 (02:23 +0000)]
login(1): when exporting variables check the result of setenv(3)

When exporting a variable we correctly check all the preconditions that
could make setenv(3) fail. Checking the setenv(3) return value seems
redundant, but given that login(1) is critical, it doesn't hurt to have
a post-check.

This change is based on the "Principles of Secure Coding" course by
Matthew Bishop, PhD., which specifically discusses this code in FreeBSD.

Differential Revision: https://reviews.freebsd.org/D26966

3 years agoRemove redundand redefinion, fixing build.
Konstantin Belousov [Sat, 19 Dec 2020 01:46:47 +0000 (01:46 +0000)]
Remove redundand redefinion, fixing build.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agousb: Replace ITUNERNET vendor with MICROCHIP and improve product names
Jessica Clarke [Fri, 18 Dec 2020 23:31:36 +0000 (23:31 +0000)]
usb: Replace ITUNERNET vendor with MICROCHIP and improve product names

These Mini-Box LCDs are using Microchip components and sub-licensed product
IDs. Whilst here, update the constant names and descriptions for the products
to use the names listed on the manufacturer's website rather than vague ones.
The picoLCD 4x20 is named that on the manufacturer's website so prefer that
name, even though linux-usb.org lists it with the numbers reversed as one might
expect.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D27670

3 years agoRename pass4check() to freeblock() and move from pass4.c to inode.c.
Kirk McKusick [Fri, 18 Dec 2020 23:28:27 +0000 (23:28 +0000)]
Rename pass4check() to freeblock() and move from pass4.c to inode.c.
The new name more accurately describes what it does and the file move
puts it with other similar functions. Done in preparation for future
cleanups. No functional differences intended.

Sponsored by: Netflix
Historic Footnote: my last FreeBSD svn commit

3 years agoAdd ELF flag to disable ASLR stack gap.
Konstantin Belousov [Fri, 18 Dec 2020 23:14:39 +0000 (23:14 +0000)]
Add ELF flag to disable ASLR stack gap.

Also centralize and unify checks to enable ASLR stack gap in a new
helper exec_stackgap().

PR: 239873
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agoproc.h: Reformat P_ and P2_ definitions.
Konstantin Belousov [Fri, 18 Dec 2020 23:11:27 +0000 (23:11 +0000)]
proc.h: Reformat P_ and P2_ definitions.

Use traditional explicit leading zero format for hex numbers.
Align P2_ hex values.
Wrap long lines by splitting comments.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agostrerror.3: Fix whitespace issue introduced in r368714
Jessica Clarke [Fri, 18 Dec 2020 22:10:17 +0000 (22:10 +0000)]
strerror.3: Fix whitespace issue introduced in r368714

MFC with: 368714

3 years agoSwitch direct rt fields access in rtsock.c to newly-create field acessors.
Alexander V. Chernikov [Fri, 18 Dec 2020 22:00:57 +0000 (22:00 +0000)]
Switch direct rt fields access in rtsock.c to newly-create field acessors.

rtsock code was build around the assumption that each rtentry record
 in the system radix tree is a ready-to-use sockaddr. This assumptions
 turned out to be not quite true:
* masks have their length tweaked, so we have rtsock_fix_netmask() hack
* IPv6 addresses have their scope embedded, so we have another explicit
 deembedding hack.

Change the code to decouple rtentry internals from rtsock code using
 newly-created rtentry accessors. This will allow to eventually eliminate
 both of the hacks and change rtentry dst/mask format.

Differential Revision: https://reviews.freebsd.org/D27451

3 years agoSkip the vm.pmap.kernel_maps sysctl by default.
John Baldwin [Fri, 18 Dec 2020 20:41:23 +0000 (20:41 +0000)]
Skip the vm.pmap.kernel_maps sysctl by default.

This sysctl node can generate very verbose output, so don't trigger it
for sysctl -a or sysctl vm.pmap.

Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D27504

3 years agoriscv: report additional known SBI implementations
Mitchell Horne [Fri, 18 Dec 2020 20:10:30 +0000 (20:10 +0000)]
riscv: report additional known SBI implementations

These implementation IDs are defined in the SBI spec, so we should print
their name if detected.

Submitted by: Danjel Qyteza <danq1222@gmail.com>
Reviewed by: jhb, kp
Differential Revision: https://reviews.freebsd.org/D27660

3 years agoarm64: rk3399: Export the watchdog clock
Emmanuel Vadot [Fri, 18 Dec 2020 16:55:54 +0000 (16:55 +0000)]
arm64: rk3399: Export the watchdog clock

This clock is used by the watchdog IP and can be controlled only
in the secure world.

3 years agoamd64: use register macros for gdb_cpu_getreg()
Mitchell Horne [Fri, 18 Dec 2020 16:16:03 +0000 (16:16 +0000)]
amd64: use register macros for gdb_cpu_getreg()

Prefer these newly-added definitions to bare values.

MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

3 years agoamd64: allow gdb(4) to write to most registers
Mitchell Horne [Fri, 18 Dec 2020 16:09:24 +0000 (16:09 +0000)]
amd64: allow gdb(4) to write to most registers

Similar to the recent patch to arm's gdb stub in r368414, allow GDB to
update the contents of most general purpose registers.

Reviewed by: cem, jhb, markj
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
NetApp PR: 44
Differential Revision: https://reviews.freebsd.org/D27642

3 years agoacpi: Ensure that adjacent memory affinity table entries are coalesced
Mark Johnston [Fri, 18 Dec 2020 16:04:48 +0000 (16:04 +0000)]
acpi: Ensure that adjacent memory affinity table entries are coalesced

The SRAT may contain multiple distinct entries that together describe a
contiguous region of physical memory.  In this case we were not
coalescing the corresponding entries in the memory affinity table, which
led to fragmented phys_avail[] entries.  Since r338431 the vm_phys_segs[]
entries derived from phys_avail[] will be coalesced, resulting in a
situation where vm_phys_segs[] entries do not have a covering
phys_avail[] entry.  vm_page_startup() will not add such segments to the
physical memory allocator, leaving them unused.

Reported by: Don Morris <dgmorris@earthlink.net>
Reviewed by: kib, vangyzen
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27620

3 years agoFix the ipfw service status output when ipfw.ko isn't loaded
Mark Johnston [Fri, 18 Dec 2020 16:02:28 +0000 (16:02 +0000)]
Fix the ipfw service status output when ipfw.ko isn't loaded

Reported by: lme
Reviewed by: lme
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27657

3 years agovirtio_mmio: Fix feature negotiation copy-paste issue in r361943
Jessica Clarke [Fri, 18 Dec 2020 15:07:14 +0000 (15:07 +0000)]
virtio_mmio: Fix feature negotiation copy-paste issue in r361943

This caused us to write to the low half of the feature word twice, once with
the high bits and once with the low bits. Common legacy device implementations
seem to be fairly lenient about being able to write to the feature bits
multiple times, but Arm's models use a stricter implementation that will ignore
the second write. This fixes using vtnet(4) on those models.

Reported by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Pointy hat: jrtc27

3 years agoFix abort in jemalloc extent coalescing.
Marcin Wojtas [Fri, 18 Dec 2020 10:09:21 +0000 (10:09 +0000)]
Fix abort in jemalloc extent coalescing.

Fix error in extent_try_coalesce_impl(), which could cause abort
to happen when trying to coalesce extents backwards. The error could
happen because of how extent_before_get() function works. This function
gets address of previous extent, by subtracting page size from current
extent address. If current extent is located at PAGE_SIZE offset, this
address resolved to 0x0000. An assertion in rtree_leaf_elm_lookup
then caused the running program to abort.

This problem was discovered when trying to build world on 32-bit
machines with ASLR and PIE enabled. The problem was encountered
on armv7 and i386 machines, but most likely other 32-bit
architectures are affected as well.

While this patch fixes one problem with buildworld on 32-bit platforms
with ASLR, the build still fails, however it happens much later
and due to lack of memory.

The change is aligned with accepted fix in the upstream Jemalloc
repository (https://github.com/jemalloc/jemalloc/pull/1973).
As it doesn't apply on top of Jemalloc tree, its updated version
was eventually merged: https://github.com/jemalloc/jemalloc/pull/2003

PR: 249937
Submitted by: Dawid Gorecki <dgr@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D27025

3 years agotools/tools/locale: fix static-colldef
Yuri Pankov [Fri, 18 Dec 2020 08:43:06 +0000 (08:43 +0000)]
tools/tools/locale: fix static-colldef

3 years agoMFV r368746:
Xin LI [Fri, 18 Dec 2020 04:23:20 +0000 (04:23 +0000)]
MFV r368746:

Apply upstream fix 08968baec1122a58bb90d8f97ad948a75f8a5d69:

Fix error cases when udp-connect is set and send() returns an error

Obtained from: unbound git
MFC after: 3 days

3 years agotools/tools/locale: install generated files in current src checkout
Yuri Pankov [Fri, 18 Dec 2020 04:01:05 +0000 (04:01 +0000)]
tools/tools/locale: install generated files in current src checkout

3 years agopci_iov: When pci_iov_detach(9) is called, destroy VF children
Konstantin Belousov [Fri, 18 Dec 2020 03:46:50 +0000 (03:46 +0000)]
pci_iov: When pci_iov_detach(9) is called, destroy VF children

instead of bailing out with EBUSY if there are any.

If driver module is unloaded, or just device is forcibly detached from
the driver, there is no way for driver to correctly unload otherwise.
Esp. if there are resources dedicated to the VFs which prevent turning
down other resources.

Reviewed by: jhb
Sponsored by: Mellanox Technologies / NVidia Networking
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27615

3 years agoFix issues with various VNC clients.
Peter Grehan [Fri, 18 Dec 2020 00:38:48 +0000 (00:38 +0000)]
Fix issues with various VNC clients.

- support VNC version 3.3 (macos "Screen Sharing" builtin client)
- wait until client has requested an update prior to sending framebuffer data
- don't send an update if no framebuffer updates detected
- increase framebuffer poll frequency to 30Hz, and double that when
  kbd/mouse input detected
- zero uninitialized array elements in rfb_send_server_init_msg()
- fix overly large allocation in rfb_init()
- use atomics for flags shared between input and output threads
- use #defines for constants

 This work was contributed by Marko Kiiskila, with reuse of some earlier
work by Henrik Gulbrandsen.

Clients tested :
FreeBSD-current
 - tightvnc
 - tigervnc
 - krdc
 - vinagre

Linux (Ubuntu)
 - krdc
 - vinagre
 - tigervnc
 - xtightvncviewer
 - remmina

MacOS
 - VNC Viewer
 - TigerVNC
 - Screen Sharing (builtin client)

Windows 10
 - Tiger VNC
 - VNC Viewer (cursor lag)
 - UltraVNC (cursor lag)

o/s independent
 - noVNC (browser) using websockify relay

PR: 250795
Submitted by: Marko Kiiskila <marko@apache.org>
Reviewed by: jhb (bhyve)
MFC after: 3 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27605

3 years agoApply upstream fix 08968baec1122a58bb90d8f97ad948a75f8a5d69:
Xin LI [Thu, 17 Dec 2020 23:35:18 +0000 (23:35 +0000)]
Apply upstream fix 08968baec1122a58bb90d8f97ad948a75f8a5d69:

Fix error cases when udp-connect is set and send() returns an error

Approved by: git-admin (uqs)

3 years agoice: quiet -Wredundant-decls
Ryan Libby [Thu, 17 Dec 2020 22:53:45 +0000 (22:53 +0000)]
ice: quiet -Wredundant-decls

Reapply r364240 after driver update in r365617.

Reviewed by: lwhsu
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27561

3 years agoVFS_QUOTACTL: Remove needless casts of arg
Brooks Davis [Thu, 17 Dec 2020 21:58:10 +0000 (21:58 +0000)]
VFS_QUOTACTL: Remove needless casts of arg

The argument is a void * so there's no need to cast it to caddr_t.

Update documentation to match function decleration.

Reviewed by: freqlabs
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27093

3 years agonet tests: Re-enable most if_clone tests
Kristof Provost [Thu, 17 Dec 2020 21:54:25 +0000 (21:54 +0000)]
net tests: Re-enable most if_clone tests

All but one of these (tap_ipv6_up_stress) currently pass, so we should enable
them so we don't regress.

3 years agoFix f_pkt_into_t typo.
Alexander Motin [Thu, 17 Dec 2020 21:02:58 +0000 (21:02 +0000)]
Fix f_pkt_into_t typo.

MFC after: 1 week

3 years agoUse __containerof() instead of home-rolled versions.
John Baldwin [Thu, 17 Dec 2020 20:45:10 +0000 (20:45 +0000)]
Use __containerof() instead of home-rolled versions.

Reviewed by: imp, hselasky
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27582

3 years agoDescribe the commit message template our git hook script produces
Ed Maste [Thu, 17 Dec 2020 20:31:45 +0000 (20:31 +0000)]
Describe the commit message template our git hook script produces

Reported by: rpokala

3 years agoUse a template assembly file for firmware object files.
John Baldwin [Thu, 17 Dec 2020 20:31:17 +0000 (20:31 +0000)]
Use a template assembly file for firmware object files.

Similar to r366897, this uses the .incbin directive to pull in a
firmware file's contents into a .fwo file.  The same scheme for
computing symbol names from the filename is used as before to maximize
compatiblity and not require rebuilding existing .fwo files for
NO_CLEAN builds.  Using ld -o binary requires extra hacks in linkers
to either specify ABI options (e.g. soft- vs hard-float) or to ignore
ABI incompatiblities when linking certain objects (e.g.  object files
with only data).  Using the compiler driver avoids the need for these
hacks as the compiler driver is able to set all the appropriate ABI
options.

Reviewed by: imp, markj
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27579

3 years agoCleanups to *ERR* compat shims.
John Baldwin [Thu, 17 Dec 2020 20:28:53 +0000 (20:28 +0000)]
Cleanups to *ERR* compat shims.

- Use [u]intptr_t casts to convert pointers to integers.

- Change IS_ERR* to return bool instead of long.

Reviewed by: manu
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27577

3 years agochmod +x the git commit message prep hook
Ed Maste [Thu, 17 Dec 2020 20:11:31 +0000 (20:11 +0000)]
chmod +x the git commit message prep hook

3 years agoAdd initial version of git commit message preparation hook
Ed Maste [Thu, 17 Dec 2020 19:58:29 +0000 (19:58 +0000)]
Add initial version of git commit message preparation hook

Start with a slightly modified version of the SVN commit template, to
allow developers to experiment.  This will be updated in the future as
our process and techniques evolve.

This can be installed by copying or symlinking into the .git/hooks/
directory.

Feedback from: cem, jhb
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27633

3 years agoFix a race in tty_signal_sessleader() with unlocked read of s_leader.
Konstantin Belousov [Thu, 17 Dec 2020 19:51:39 +0000 (19:51 +0000)]
Fix a race in tty_signal_sessleader() with unlocked read of s_leader.

Since we do not own the session lock, a parallel killjobc() might
reset s_leader to NULL after we checked it.  Read s_leader only once
and ensure that compiler is not allowed to reload.

While there, make access to t_session somewhat more pretty by using
local variable.

PR: 251915
Submitted by: Jakub Piecuch <j.piecuch96@gmail.com>
MFC after: 1 week

3 years agoUpdate the unbound version number from r368478.
Cy Schubert [Thu, 17 Dec 2020 19:50:41 +0000 (19:50 +0000)]
Update the unbound version number from r368478.

Updating the version number is an extra manual step.

Pointy hat to: cy
Reported by: Herbert J. Skuhra <herbert _ gojira.at>
MFC after: 3 days

3 years agofd: reimplement close_range to avoid spurious relocking
Mateusz Guzik [Thu, 17 Dec 2020 18:52:30 +0000 (18:52 +0000)]
fd: reimplement close_range to avoid spurious relocking

3 years agoaudit: rework AUDIT_SYSCLOSE
Mateusz Guzik [Thu, 17 Dec 2020 18:52:04 +0000 (18:52 +0000)]
audit: rework AUDIT_SYSCLOSE

This in particular avoids spurious lookups on close.

3 years agofd: refactor closefp in preparation for close_range rework
Mateusz Guzik [Thu, 17 Dec 2020 18:51:09 +0000 (18:51 +0000)]
fd: refactor closefp in preparation for close_range rework

3 years agolualoader: fix lua-lint run
Kyle Evans [Thu, 17 Dec 2020 18:29:30 +0000 (18:29 +0000)]
lualoader: fix lua-lint run

luacheck rightfully complains that i is unused in the show-module-options
loop at the end (it was used for some debugging in the process).

We've added a new pager module that's compiled in, so declare that as an
acceptable global.

3 years agolualoader: cli: provide a show-module-options loader command
Kyle Evans [Thu, 17 Dec 2020 18:24:36 +0000 (18:24 +0000)]
lualoader: cli: provide a show-module-options loader command

This effectively dumps everything lualoader knows about to the console using
the libsa pager; that particular lua interface was added in r368591.

A pager stub implementation has been added that just dumps the output as-is
as a compat shim for older loader binaries that do not have lpager. This
stub should be moved into a more appropriate .lua file if we add anything
else that needs the pager.

3 years ago[ng_socket] Don't take the SOCKBUF_LOCK() twice in the RX data path.
Aleksandr Fedorov [Thu, 17 Dec 2020 18:15:07 +0000 (18:15 +0000)]
[ng_socket] Don't take the SOCKBUF_LOCK() twice in the RX data path.

This is just a minor optimization, but it's sensitive. This gives an improvement of 30-50 kpps.

Reviewed by: kp, markj, glebius, lutz_donnerhacke.de
Approved by: vmaffione (mentor)
Sponsored by: vstack.com
Differential Revision: https://reviews.freebsd.org/D27382

3 years agoAdd IRQ resource to SPIBUS
Emmanuel Vadot [Thu, 17 Dec 2020 17:11:14 +0000 (17:11 +0000)]
Add IRQ resource to SPIBUS

Add capability to SPIBUS to have child device with IRQ.
For example many ADC chip have a dedicated pin to signal "data ready"
and the host can just wait for a interrupt to go out and read the result.

It is the same code as in R282674 and R282702 for IICBUS by Michal Meloun

Submitted by: Oskar Holmund <oskar.holmlund@ohdata.se>
Differential Revision: https://reviews.freebsd.org/D27396

3 years agoarm: Remove samsung exnynos port
Emmanuel Vadot [Thu, 17 Dec 2020 17:09:43 +0000 (17:09 +0000)]
arm: Remove samsung exnynos port

Remove the exynos SoC support, this haven't been updated in a while,
isn't present in GENERIC and nobody is motivated to resurect it.

Differential Revision: https://reviews.freebsd.org/D24444

3 years agoChange POSIX compliance level for visibility of strerror_l(3).
Konstantin Belousov [Thu, 17 Dec 2020 17:08:25 +0000 (17:08 +0000)]
Change POSIX compliance level for visibility of strerror_l(3).

Third-party code tests for strerror_l(3) without specifying
_POSIX_SOURCE, and then expects that the function is prototyped with
_POSIX_SOURCE set to 200112.

Reported and tested by: antoine
Sponsored by: The FreeBSD Foundation
MFC after: 13 days

3 years agokyua: Only install examples if requested
Emmanuel Vadot [Thu, 17 Dec 2020 17:06:57 +0000 (17:06 +0000)]
kyua: Only install examples if requested

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D27638