]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoFix build of stand/usb .
Hans Petter Selasky [Mon, 12 Apr 2021 14:12:18 +0000 (16:12 +0200)]
Fix build of stand/usb .

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 7497dd58890131251441ab992016c9457295094b)

3 years agoif_smsc: Add the ability to disable "turbo_mode", also called RX frame batching,
Hans Petter Selasky [Sun, 11 Apr 2021 18:24:41 +0000 (20:24 +0200)]
if_smsc: Add the ability to disable "turbo_mode", also called RX frame batching,
similarly to the Linux driver, by a tunable read only sysctl.

Submitted by: Oleg Sidorkin <osidorkin@gmail.com>
PR: 254884
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 5a3426f453f970edda38367bea5ebf7385c3819d)

3 years agokern/intr: declare interrupt vectors unsigned
Elliott Mitchell [Mon, 3 May 2021 16:50:17 +0000 (12:50 -0400)]
kern/intr: declare interrupt vectors unsigned

These should never get values large enough for sign to matter, but one
of them becoming negative could cause problems.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D29327

(cherry picked from commit a3c7da3d08eec921f16a32c4c716b896385264e9)

3 years agodivert: Fix mbuf ownership confusion in div_output()
Mark Johnston [Fri, 7 May 2021 18:27:58 +0000 (14:27 -0400)]
divert: Fix mbuf ownership confusion in div_output()

div_output_outbound() and div_output_inbound() relied on the caller to
free the mbuf if an error occurred.  However, this is contrary to the
semantics of their callees, ip_output(), ip6_output() and
netisr_queue_src(), which always consume the mbuf.  So, if one of these
functions returned an error, that would get propagated up to
div_output(), resulting in a double free.

Fix the problem by making div_output_outbound() and div_output_inbound()
responsible for freeing the mbuf in all cases.

Reported by: Michael Schmiedgen <schmiedgen@gmx.net>
Tested by: Michael Schmiedgen
Reviewed by: donner
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30129

(cherry picked from commit a1fadf7de25b973a308b86d04c4ada4fa8be193f)

3 years agosmp: Initialize arg->cpus sooner in smp_rendezvous_cpus_retry()
Mark Johnston [Mon, 3 May 2021 16:43:00 +0000 (12:43 -0400)]
smp: Initialize arg->cpus sooner in smp_rendezvous_cpus_retry()

Otherwise, if !smp_started is true, then smp_rendezvous_cpus_done() will
harmlessly perform an atomic RMW on an uninitialized variable.

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit cdfcfc607acc10c8b1b2b6a427c9e1ed7e94ebb3)

3 years agobhyve: Set SO_REUSEADDR on the gdb stub socket
Mark Johnston [Mon, 3 May 2021 16:42:54 +0000 (12:42 -0400)]
bhyve: Set SO_REUSEADDR on the gdb stub socket

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30037

(cherry picked from commit 02e7a6514e63ceca680fade40797280aef1bf55f)

3 years agodevd.conf: Remove support for coldsync
Ceri Davies [Fri, 7 May 2021 18:19:34 +0000 (14:19 -0400)]
devd.conf: Remove support for coldsync

The coldsync port was removed in 2012.  The last stable release of
coldsync was issued in 2002.  Let's get rid of it.

PR: 255051
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D30100

(cherry picked from commit 1a212abd54c0e4323f11e3bc2fd94ca26f7e5329)

3 years agodevd.conf: Typo
Ceri Davies [Fri, 7 May 2021 18:31:02 +0000 (14:31 -0400)]
devd.conf: Typo

PR: 255051

(cherry picked from commit 6a8ed85f487c6fd109897235c60f710948bd5150)

3 years agogcore: add option to dump core using kernel facility
Konstantin Belousov [Sat, 24 Apr 2021 11:20:24 +0000 (14:20 +0300)]
gcore: add option to dump core using kernel facility

(cherry picked from commit 73e8f06ac523ee4b530e17d50cc580dc366f7ad8)

3 years agogcore: split code to open core file into helper
Konstantin Belousov [Sat, 24 Apr 2021 10:31:58 +0000 (13:31 +0300)]
gcore: split code to open core file into helper

(cherry picked from commit c192228b7398df72e472128605338555e5aa2db9)

3 years agoAdd ptrace(PT_COREDUMP)
Konstantin Belousov [Fri, 23 Apr 2021 13:26:01 +0000 (16:26 +0300)]
Add ptrace(PT_COREDUMP)

(cherry picked from commit 87a64872cd3166a09b58aac28cdb95380d6a38eb)

3 years agoptracestop: mark threads suspended there with the new TDB_SSWITCH flag
Konstantin Belousov [Sat, 24 Apr 2021 12:02:40 +0000 (15:02 +0300)]
ptracestop: mark threads suspended there with the new TDB_SSWITCH flag

(cherry picked from commit 68d311b66678d9daffc5cf1c78f3101f2eeec3ea)

3 years agoptrace: do not allow for parallel ptrace requests
Konstantin Belousov [Sat, 24 Apr 2021 11:57:40 +0000 (14:57 +0300)]
ptrace: do not allow for parallel ptrace requests

(cherry picked from commit 9ebf9100bad129a92961572ac862781d6c5681c7)

3 years agokern_ptrace(): extract code to determine ptrace eligibility into helper
Konstantin Belousov [Sat, 24 Apr 2021 11:52:11 +0000 (14:52 +0300)]
kern_ptrace(): extract code to determine ptrace eligibility into helper

(cherry picked from commit 54c8baa021957bc026406b3a424296e84b28baa5)

3 years agokern_ptrace: change type of proctree_locked to bool
Konstantin Belousov [Fri, 30 Apr 2021 21:14:26 +0000 (00:14 +0300)]
kern_ptrace: change type of proctree_locked to bool

(cherry picked from commit 2bd0506c8d94a2c581dd16407f3a1c159a38769b)

3 years agoAdd thread_run_flash() helper
Konstantin Belousov [Sat, 24 Apr 2021 11:47:53 +0000 (14:47 +0300)]
Add thread_run_flash() helper

(cherry picked from commit af928fded0705100e4f3926c99ed488f7ab6dcf1)

3 years agoAdd sleepq_remove_nested()
Konstantin Belousov [Sun, 25 Apr 2021 00:01:32 +0000 (03:01 +0300)]
Add sleepq_remove_nested()

(cherry picked from commit 15465a2c25cc2915e8c7c65178805b10e339dde3)

3 years agoELF coredump: define several useful flags for the coredump operations
Konstantin Belousov [Sat, 24 Apr 2021 11:45:01 +0000 (14:45 +0300)]
ELF coredump: define several useful flags for the coredump operations

(cherry picked from commit 86ffb3d1a0cbb09ba0123ff8d34149e691b461c4)

3 years agoimgact_elf: consistently pass flags from coredump down to helper functions
Konstantin Belousov [Sat, 24 Apr 2021 11:42:56 +0000 (14:42 +0300)]
imgact_elf: consistently pass flags from coredump down to helper functions

(cherry picked from commit 5bc3c61780d775810eea852936671ca4a232b2a8)

3 years agoAdd Apollo Lake SIO/LPSS UARTs PCI IDs
Jose Luis Duran [Sun, 2 May 2021 21:20:25 +0000 (21:20 +0000)]
Add Apollo Lake SIO/LPSS UARTs PCI IDs

PR: 255556

(cherry picked from commit 8f1562430fbb83f6cedff6450e1aa1b593e3d7e7)

3 years agouart_bus_pci.c: Style
Jose Luis Duran [Sun, 2 May 2021 21:20:25 +0000 (21:20 +0000)]
uart_bus_pci.c: Style

PR: 255556

(cherry picked from commit 5b8b6b26e40a81320f02a46df98b96bd8e93295a)

3 years agoifconfig: Minor documentation fix
Jose Luis Duran [Thu, 29 Apr 2021 11:03:48 +0000 (11:03 +0000)]
ifconfig: Minor documentation fix

PR: 255557

(cherry picked from commit 0ea8a7f36db31bfc550bbe5e39703fdedd12fa8c)

3 years agofilt_timerexpire: do not iterate over the interval
Konstantin Belousov [Wed, 28 Apr 2021 16:28:49 +0000 (19:28 +0300)]
filt_timerexpire: do not iterate over the interval

(cherry picked from commit 7cb40543e96451092d5bc6bb3d96ebee364327e0)

3 years agonetgraph/ng_base: Allow larger BINARY2ASCII conversions
Lutz Donnerhacke [Sun, 7 Feb 2021 21:07:34 +0000 (22:07 +0100)]
netgraph/ng_base: Allow larger BINARY2ASCII conversions

Allocate the necessary memory for the conversion dynamically starting
with a value which is sufficient for almost all normal cases.

PR: 187835
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D23840

(cherry picked from commit 45d75e3ac3fb5bf8230ca28dc09b48c6e5ed7a4f)

3 years agosbin/ipfw: Fix null pointer deference when printing counters
Lutz Donnerhacke [Fri, 30 Apr 2021 14:12:47 +0000 (16:12 +0200)]
sbin/ipfw: Fix null pointer deference when printing counters

ipfw -[tT] prints statistics of the last access. If the rule was never
used, the counter might be not exist.  This happens unconditionally on
inserting a new rule.  Avoid printing statistics in this case.

PR: 255491
Reported by: Haisheng Zhouz
Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D30046

(cherry picked from commit bf7cc0f9cb6603a6bdd6131c8d1939724ce6e62d)

3 years agonfscl: fix delegation recall when the file is not open
Rick Macklem [Sun, 25 Apr 2021 19:52:48 +0000 (12:52 -0700)]
nfscl: fix delegation recall when the file is not open

Without this patch, if a NFSv4 server recalled a
delegation when the file is not open, the renew
thread would block in the NFS VOP_INACTIVE()
trying to acquire the client state lock that it
already holds.

This patch fixes the problem by delaying the
vrele() call until after the client state
lock is released.

This bug has been in the NFSv4 client for
a long time, but since it only affects
delegation when recalled due to another
client opening the file, it got missed
during previous testing.

Until you have this patch in your client,
you should avoid the use of delegations.

(cherry picked from commit 02695ea8909d818ceaa726f90f889889dfd39fac)

3 years agoless: upgrade to v581.2.
Xin LI [Mon, 19 Apr 2021 02:46:19 +0000 (19:46 -0700)]
less: upgrade to v581.2.

(cherry picked from commit 50d31dbc6e2bc3aa6007edb8cdecbcb84e85d6c0)

less: upgrade to v581.

(cherry picked from commit 2235c7feac959bcc9ddfd6a2bc6be32102b1f84c)

3 years agoRevert "Add workaround for a QoS-related bug in VMWare Workstation."
Ed Maste [Sun, 25 Apr 2021 21:14:23 +0000 (17:14 -0400)]
Revert "Add workaround for a QoS-related bug in VMWare Workstation."

This reverts commit 77c2fe20df6a9a7c1a353e1a4ab2ba80fefab881.

The VMware Workstation issue was fixed in 2019[1], and we'd rather not
carry unnecessary local changes in OpenSSH.

[1] https://communities.vmware.com/t5/VMware-Workstation-Pro/Regression-ssh-results-in-broken-pipe-upon-connecting-in-Vmware/m-p/486105/highlight/true#M25470

PR: 234426
Discussed with: yuripv
Approved by: des
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d55bf492f8f587e4a99f4dcb39a96159b4431782)

3 years agopf tests: Test scrub fragment reassemble on interfaces with different MTU
Kristof Provost [Tue, 27 Apr 2021 16:46:03 +0000 (18:46 +0200)]
pf tests: Test scrub fragment reassemble on interfaces with different MTU

There's a problem with pf's reassembly code where it produces incorrect
checksums when reassembling across interfaces with different MTUs.
Test this.

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

(cherry picked from commit 388c0cde10293d9a3434e99146bf391aec6878a3)

3 years agopf: Fix IP checksum on reassembly
Kristof Provost [Wed, 28 Apr 2021 10:56:06 +0000 (12:56 +0200)]
pf: Fix IP checksum on reassembly

If we reassemble a packet we modify the IP header (to set the length and
remove the fragment offset information), but we failed to update the
checksum. On certain setups (mostly where we did not re-fragment again
afterwards) this could lead to us sending out packets with incorrect
checksums.

PR: 255432
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30026

(cherry picked from commit 055c55abefbe19fe46a56894595af9c9dad7678c)

3 years agopf: PFRULE_REFS should not be user-visible
Kristof Provost [Thu, 15 Apr 2021 11:38:56 +0000 (13:38 +0200)]
pf: PFRULE_REFS should not be user-visible

Split the PFRULE_REFS flag from the rule_flag field. PFRULE_REFS is a
kernel-internal flag and should not be exposed to or read from
userspace.

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

(cherry picked from commit 4f1f67e88853ac9e3c2d8897cf6dab6cfda8d16e)

3 years agolibpfct: Fix PIC flag
Kristof Provost [Fri, 16 Apr 2021 19:00:51 +0000 (21:00 +0200)]
libpfct: Fix PIC flag

Use ${PICFLAG} rather than hard-adding -fPIC, which removes the
requirement for libnv to be built PIC.

MFC after:      4 weeks
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 8403170b3d39326f836bc999534fe8c4d41cda11)

3 years agopf tests: Test clearing rules counters
Kristof Provost [Mon, 12 Apr 2021 15:29:19 +0000 (17:29 +0200)]
pf tests: Test clearing rules counters

This was briefly broken, so ensure that we can read and clear rules
counters.

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

(cherry picked from commit 112f007e12818ba3d54869b331139090e69dbc74)

3 years agopfctl: Fix clearing rules counters
Kristof Provost [Mon, 12 Apr 2021 15:23:33 +0000 (17:23 +0200)]
pfctl: Fix clearing rules counters

After the migration to libpfctl for rule retrieval we accidentally lost
support for clearing the rules counters.

Introduce a get_clear variant of pfctl_get_rule() which allows rules
counters to be cleared.

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

(cherry picked from commit 4eabfe468b6e80a0823523d83dc908c27ec823c7)

3 years agopfctl, libpfctl: introduce pfctl_pool
Kurosawa Takahiro [Mon, 12 Apr 2021 14:03:40 +0000 (16:03 +0200)]
pfctl, libpfctl: introduce pfctl_pool

Introduce pfctl_pool to be able to extend the pool part of the pf rule
without breaking the ABI.

Reviewed by: kp
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D29721

(cherry picked from commit 600bd6ce0639c84b763516477250df5964e8edf6)

3 years agopf: Ensure that we don't use kif passed to pfi_kkif_attach()
Kristof Provost [Mon, 12 Apr 2021 09:45:48 +0000 (11:45 +0200)]
pf: Ensure that we don't use kif passed to pfi_kkif_attach()

Once a kif is passed to pfi_kkif_attach() we must ensure we never re-use
it for anything else.
Set the kif to NULL afterwards to guarantee this.

Reported-by: syzbot+be5d4f4a7a4c295e659a@syzkaller.appspotmail.com
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5e98cae661f3a7e85df7f277660765b823454073)

3 years agolibnv: Use PICFLAG rather than -fPIC
Kristof Provost [Sat, 10 Apr 2021 09:23:57 +0000 (11:23 +0200)]
libnv: Use PICFLAG rather than -fPIC

Suggested by: andrew
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 15ca66220874c177602c13a114b2f3d17773b788)

3 years agolibpfctl: Fix u_* counters
Kristof Provost [Thu, 8 Apr 2021 08:36:18 +0000 (10:36 +0200)]
libpfctl: Fix u_* counters

struct pf_rule had a few counter_u64_t counters. Those couldn't be
usefully comminicated with userspace, so the fields were doubled up in
uint64_t u_* versions.

Now that we use struct pfctl_rule (i.e. a fully userspace version) we
can safely change the structure and remove this wart.

Reviewed by: glebius
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29645

(cherry picked from commit ab5707a5cf86ed66dbd11e03ad9676766da9a47b)

3 years agolibpfctl: Switch to pfctl_rule
Kristof Provost [Thu, 8 Apr 2021 08:31:46 +0000 (10:31 +0200)]
libpfctl: Switch to pfctl_rule

Stop using the kernel's struct pf_rule, switch to libpfctl's pfctl_rule.
Now that we use nvlists to communicate with the kernel these structures
can be fully decoupled.

Reviewed by: glebius
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29644

(cherry picked from commit e9eb09414a8de8f3329f51b48c90a5e5ac8f09cf)

3 years agopf: Move prototypes for userspace functions to userspace header
Kristof Provost [Wed, 7 Apr 2021 17:49:51 +0000 (19:49 +0200)]
pf: Move prototypes for userspace functions to userspace header

These functions no longer exist in the kernel, so there's no reason to
keep the prototypes in a kernel header. Move them to pfctl where they're
actually implemented.

Reviewed by: glebius
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29643

(cherry picked from commit a9b338b260be39cc74dddb599d6c95b8794ca98b)

3 years agobsnmp: Use libpfctl
Kristof Provost [Mon, 29 Mar 2021 15:43:25 +0000 (17:43 +0200)]
bsnmp: Use libpfctl

Reviewed by: glebius
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29642

(cherry picked from commit 956e7d232549ce4b17f5b1a079e5b51229479dda)

3 years ago(t)ftp-proxy: use libpfctl
Kristof Provost [Mon, 29 Mar 2021 12:03:39 +0000 (14:03 +0200)]
(t)ftp-proxy: use libpfctl

Reviewed by: glebius
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29641

(cherry picked from commit 95be9288f01f30a50440ea56d11468a2c6e18fed)

3 years agopfctl: Move ioctl abstraction functions into libpfctl
Kristof Provost [Fri, 26 Mar 2021 10:38:58 +0000 (11:38 +0100)]
pfctl: Move ioctl abstraction functions into libpfctl

Introduce a library to wrap the pf ioctl interface.

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

(cherry picked from commit 0d71f9f36e6c1849fdaf6c1edc1178be07357034)

3 years agolibnv: Build PIC
Kristof Provost [Fri, 2 Apr 2021 15:06:02 +0000 (17:06 +0200)]
libnv: Build PIC

Build libnv as position independent code so we can use it from shared
libraries.

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

(cherry picked from commit 0dd13c77432ade1ae94c9661cbad5537e3e6ab1d)

3 years agopfctl: Use the new DIOCGETRULENV ioctl
Kristof Provost [Fri, 26 Mar 2021 10:22:15 +0000 (11:22 +0100)]
pfctl: Use the new DIOCGETRULENV ioctl

Create wrapper functions to handle the parsing of the nvlist and move
that code into pfctl_ioctl.c.
At some point this should be moved into a libpfctl.

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

(cherry picked from commit 0d6c8174ef2f3d8d6fb02ec97753a0937796a5c6)

3 years agopf: Implement nvlist variant of DIOCGETRULE
Kristof Provost [Thu, 25 Mar 2021 09:39:14 +0000 (10:39 +0100)]
pf: Implement nvlist variant of DIOCGETRULE

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

(cherry picked from commit d710367d1159423ed4da6628b7ab042d3e44f900)

3 years agopfctl: Move to DIOCADDRULENV
Kristof Provost [Fri, 12 Mar 2021 17:03:14 +0000 (18:03 +0100)]
pfctl: Move to DIOCADDRULENV

Start using the new nvlist based ioctl to add rules.

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

(cherry picked from commit 5c11c5a3655842a176124ef2334fcdf830422c8a)

3 years agopf: Introduce nvlist variant of DIOCADDRULE
Kristof Provost [Thu, 11 Mar 2021 15:21:23 +0000 (16:21 +0100)]
pf: Introduce nvlist variant of DIOCADDRULE

This will make future extensions of the API much easier.
The intent is to remove support for DIOCADDRULE in FreeBSD 14.

Reviewed by: markj (previous version), glebius (previous version)
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29557

(cherry picked from commit 5c62eded5a11ebdb1d57134d923596e2b04e9466)

3 years agopf: Remove unused variable rt_listid from struct pf_krule
Kristof Provost [Thu, 8 Apr 2021 09:08:33 +0000 (11:08 +0200)]
pf: Remove unused variable rt_listid from struct pf_krule

Reviewed by: donner
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29639

(cherry picked from commit 4967f672ef3095300fe74a9d1ae873d0897cc0a5)

3 years agomprutil: add big endian support
Alfredo Dal'Ava Junior [Sat, 17 Apr 2021 01:01:38 +0000 (22:01 -0300)]
mprutil: add big endian support

This fix mprutil on big endian platforms, as follow up of D25785.

Flash operations are still not working, such as MPI2_FUNCTION_FW_UPLOAD
failing due to timeout.

Firmware version used during tests: 16.00.01.00

Submitted by: Andre Fernando da Silva <andre.silva@eldorado.org.br>
Reviewed by: luporl, Sreekanth Reddy <sreekanth.reddy@broadcom.com> (by e-mail)
Sponsored by: Eldorado Research Institute (eldorado.org.br)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D26040

(cherry picked from commit fc9780fd41e7b29db04e9cb843cb5034b88ae662)

3 years agoopal_console: fix serial console output corruption on powerpc64
Alfredo Dal'Ava Junior [Fri, 16 Apr 2021 22:51:15 +0000 (19:51 -0300)]
opal_console: fix serial console output corruption on powerpc64

Adds OPAL_CONSOLE_WRITE error handling and implements a call to
OPAL_CONSOLE_WRITE_BUFFER_SPACE to verify if there's enough space
before writing to console.

This fixes serial port output getting corrupted on fast writes, like
on "dmesg" output.

Tested on Raptor Blackbird running powerpc64 BE kernel

Reviewed by: luporl
Sponsored by: Eldorado Reserach Institute (eldorado.org.br)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29063

(cherry picked from commit b8bc6b7954e27edb449503004ef52b8b97585545)

3 years agopowerpc: implement bus_map_resource and bus_unmap_resource DEVMETHODs
Alfredo Dal'Ava Junior [Mon, 29 Mar 2021 23:28:32 +0000 (20:28 -0300)]
powerpc: implement bus_map_resource and bus_unmap_resource DEVMETHODs

Implements bus_map_resource and bus_unmap_resource DEVMETHODs to be
used by powerpc targets. This is identical to the amd64 code.

Required by virtio-modern.

Reviewed by: bryanv
Sponsored by: Eldorado Research Institute (eldorado.org.br)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28012

(cherry picked from commit befb0817bd5e47588eb0254744daec02488acd72)

3 years agoioccom: define ioctl cmd value that can never be valid
Konstantin Belousov [Thu, 22 Apr 2021 19:40:08 +0000 (22:40 +0300)]
ioccom: define ioctl cmd value that can never be valid

(cherry picked from commit 619fe095861274576a2cb45628076968051b1585)

3 years agoamd64: invalidate TLB between page table update and access
Konstantin Belousov [Fri, 16 Apr 2021 18:28:08 +0000 (21:28 +0300)]
amd64: invalidate TLB between page table update and access

(cherry picked from commit 21fc6a2a10cf6fbd294decbb0001473693ec1618)

3 years agofwip(4): fixing kernel panic when receiving unicast packet
Tai-hwa Liang [Thu, 15 Apr 2021 14:24:14 +0000 (14:24 +0000)]
fwip(4): fixing kernel panic when receiving unicast packet

Wrapping fwip_unicast_input() with NET_EPOCH_{ENTER,EXIT} to avoid a
NET_EPOCH_ASSERT() in netisr_dispatch().

Reviewed by: hselasky
MFC after: 2 weeks

(cherry picked from commit bdf316e892e9a7afa70e094135b5d05fbc26e867)

3 years agotraceroute6: Properly calculate UDP checksum
Zhenlei Huang [Mon, 3 May 2021 16:46:19 +0000 (12:46 -0400)]
traceroute6: Properly calculate UDP checksum

The revision D25604 capsicumize traceroute6. For UDP the send socket was
changed from SOCK_DGRAM to SOCK_RAW and thus the UDP checksum need be
calculated by application itself other than the kernel.

outpacket is filled with zeros by line 707, thus the first round the UDP
checksum is correct. But subsequent rounds outudp->uh_sum will be left
with garbage.

PR: 255507
Reviewed by: ae, markj, tuexen
Differential Revision: https://reviews.freebsd.org/D30042

(cherry picked from commit 1d712c05370dca8cbf81d1ecd9acd606fdcacaf4)

3 years agoIntroduce "soft" serseq variant.
Alexander Motin [Tue, 6 Apr 2021 21:27:16 +0000 (17:27 -0400)]
Introduce "soft" serseq variant.

With new ZFS prefetcher improvements it is no longer needed to fully
serialize reads to reach decent prediction hit rate.  Softer variant
only creates small time window to reduce races instead of completely
blocking following reads while previous is running.  It much less
hurts the performance in case of prediction miss.

MFC after: 1 month

(cherry picked from commit ac503c194cd8e9dbef5c120e87f9521e1a89003a)

3 years agocap_sysctl.3: Fix bugs in the example
Mark Johnston [Wed, 28 Apr 2021 14:38:52 +0000 (10:38 -0400)]
cap_sysctl.3: Fix bugs in the example

- Correct the type of the sysctl value.
- Initialize the oldsize parameter to cap_sysctlbyname()

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 44bbda649dc6c1cdc5a99641e14c77157967e140)

3 years agopipe: Avoid calling selrecord() on a closing pipe
Mark Johnston [Wed, 28 Apr 2021 14:42:59 +0000 (10:42 -0400)]
pipe: Avoid calling selrecord() on a closing pipe

pipe_poll() may add the calling thread to the selinfo lists of both ends
of a pipe.  It is ok to do this for the local end, since we know we hold
a reference on the file and so the local end is not closed.  It is not
ok to do this for the remote end, which may already be closed and have
called seldrain().  In this scenario, when the polling thread wakes up,
it may end up referencing a freed selinfo.

Guard the selrecord() call appropriately.

Reviewed by: kib
Reported by: syzkaller+KASAN
Differential Revision: https://reviews.freebsd.org/D30016

(cherry picked from commit d1e9441583fd85c7de5f48197d80c287f1a9494b)

3 years agogetdirentries.2: remove unnecessary space
Piotr Pawel Stefaniak [Sun, 11 Apr 2021 09:17:01 +0000 (11:17 +0200)]
getdirentries.2: remove unnecessary space

(cherry picked from commit 1fdd6934d596b0259096d0c310e97a9c4ebf6b6b)

3 years agoBalance parentheses in sysctl descriptions
Piotr Pawel Stefaniak [Sun, 11 Apr 2021 08:29:34 +0000 (10:29 +0200)]
Balance parentheses in sysctl descriptions

(cherry picked from commit a212f56d10d04508849cd817d2c595dd61107890)

3 years agosh: fix debug build
Piotr Pawel Stefaniak [Sun, 11 Apr 2021 07:09:28 +0000 (09:09 +0200)]
sh: fix debug build

(cherry picked from commit 1a4e959eb34ae03a96f6d0dea68b6a6a88ac4462)

3 years agosh: silence sanitizer
Piotr Pawel Stefaniak [Thu, 1 Apr 2021 05:31:03 +0000 (07:31 +0200)]
sh: silence sanitizer

(cherry picked from commit 5a18515b3143792135881ce64e2380115c4744c1)

3 years agosh(1): autocomplete commands
Piotr Pawel Stefaniak [Sun, 28 Mar 2021 09:58:20 +0000 (11:58 +0200)]
sh(1): autocomplete commands

(cherry picked from commit b315a7296d2a69883c483d79dfcb3860a0428f21)

3 years agoCorrect the link of external mirrors
Li-Wen Hsu [Wed, 28 Apr 2021 19:39:18 +0000 (03:39 +0800)]
Correct the link of external mirrors

Reported by: 0mp
Fixes: 8ef03ce6db33
MFC after: 1 day

(cherry picked from commit 164d49a5842dcd07823570eaa775e82ed10022d3)

3 years agoFix build post a0409676120c1e558d0ade943019934e0f15118d.
Cy Schubert [Mon, 22 Mar 2021 15:42:18 +0000 (08:42 -0700)]
Fix build post a0409676120c1e558d0ade943019934e0f15118d.

(cherry picked from commit 048488c0c4e47aa2aac9709b18d7da14b06f78cd)

3 years agodiff: eleminitate useless macros
Baptiste Daroussin [Wed, 27 Jan 2021 10:47:17 +0000 (11:47 +0100)]
diff: eleminitate useless macros

The diff_output was not bringing any values but was obfuscating
the code.

(cherry picked from commit 7a57c9cb5a4dffb0483beeae6da7cf266ea634be)

3 years agodiff: simplify the hash functions
Baptiste Daroussin [Tue, 26 Jan 2021 15:25:00 +0000 (16:25 +0100)]
diff: simplify the hash functions

Instead of 3 different complex case they have all been folded into a
simple on based on switch

(cherry picked from commit e43239f5140e1b80de122458a2ac037172866058)

3 years agodiff: fix typo in a comment
Baptiste Daroussin [Tue, 26 Jan 2021 14:20:44 +0000 (15:20 +0100)]
diff: fix typo in a comment

(cherry picked from commit e52546a3a75f6e4b327178f4d50a98dd99101c64)

3 years agodiff: remove stalled entries in headers
Baptiste Daroussin [Wed, 27 Jan 2021 11:13:47 +0000 (12:13 +0100)]
diff: remove stalled entries in headers

(cherry picked from commit 931ad51808a650fd28be27210f25ba05d8e71199)

3 years agodiff: eliminate space at end of line
Baptiste Daroussin [Wed, 27 Jan 2021 10:46:15 +0000 (11:46 +0100)]
diff: eliminate space at end of line

No functionnal changes

(cherry picked from commit 15abb23286541c17ff95bac056cd4979822c4288)

3 years agodiff: add a test case about the non regular file support
Baptiste Daroussin [Tue, 26 Jan 2021 10:38:36 +0000 (11:38 +0100)]
diff: add a test case about the non regular file support

(cherry picked from commit c440e7870a020546ad241848e2ff8e9cb27a3073)

3 years agocp: fix indentation
Baptiste Daroussin [Tue, 26 Jan 2021 09:52:22 +0000 (10:52 +0100)]
cp: fix indentation

No functional changes

(cherry picked from commit 45b252fc9182b96342b8a598f271e49c20cbfe40)

3 years agopci_vendors: update to 2021-05-04
Baptiste Daroussin [Tue, 4 May 2021 12:02:41 +0000 (14:02 +0200)]
pci_vendors: update to 2021-05-04

(cherry picked from commit 3657010266b235f6394aefbe755dc316bb2535b4)

3 years agopci_vendors: update to 2021.04.26
Baptiste Daroussin [Thu, 29 Apr 2021 04:46:26 +0000 (06:46 +0200)]
pci_vendors: update to 2021.04.26

(cherry picked from commit a4b5f7ba3e9bf8385b6e113c284d1559333048a0)

3 years agopci_vendors: update to 2021.02.20
Baptiste Daroussin [Sun, 21 Feb 2021 05:09:03 +0000 (06:09 +0100)]
pci_vendors: update to 2021.02.20

(cherry picked from commit e6bb49f12ca7a2dc103d69d4c70e1504195f70a6)

3 years agopci_vendors: update to 2021.01.11
Baptiste Daroussin [Thu, 28 Jan 2021 08:19:50 +0000 (09:19 +0100)]
pci_vendors: update to 2021.01.11

(cherry picked from commit f59810e34bae867059163cb9f651e074043fcec8)

3 years agopkg(7): replace usage of sbuf(9) with open_memstream(3)
Baptiste Daroussin [Tue, 27 Apr 2021 02:38:55 +0000 (04:38 +0200)]
pkg(7): replace usage of sbuf(9) with open_memstream(3)

open_memstream(3) is a standard way to obtain the same feature we do get
by using sbuf(9) (aka dynamic size buffer), switching to using it makes
pkg(7) more portable, and reduces its number of dependencies.

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D30005

(cherry picked from commit cc9a8a116d19daf224222506441e91a3d329160e)

3 years agopkg(7): indentation fixes
Baptiste Daroussin [Tue, 27 Apr 2021 02:07:05 +0000 (04:07 +0200)]
pkg(7): indentation fixes

Non functional changes

(cherry picked from commit f648d757b76d70d58bbda7c3ed3ff79261d24d0f)

3 years agopkg(7): when bootstrapping first search for pkg.pkg file then pkg.txz
Baptiste Daroussin [Fri, 12 Mar 2021 17:36:30 +0000 (18:36 +0100)]
pkg(7): when bootstrapping first search for pkg.pkg file then pkg.txz

The package extension is going to be changed to .pkg to be among other
things resilient to the change of compression format used and reduce
the impact of all third party tool of that change.

Ensure the bootstrap knows about it

Reviewed by: manu
Differential revision: https://reviews.freebsd.org/D29232

(cherry picked from commit a2aac2f5e5642740507a3cadb98046f3dd434ce4)
(cherry picked from commit c244b1d8a38731041d0f3ff4191192a85dd8608b)

3 years agopw(8): use open_memstream(3) instead of sbuf(9)
Baptiste Daroussin [Tue, 27 Apr 2021 03:05:13 +0000 (05:05 +0200)]
pw(8): use open_memstream(3) instead of sbuf(9)

open_memstream(3) is a standard function that brings here the same
functionnality what we were doing with sbuf(9).

(cherry picked from commit 0cd4b781a6fa1ed4ca04a7b642f41652e25bbc9b)

3 years agolibedit: vendor import libedit 2021-03-28
Baptiste Daroussin [Mon, 22 Mar 2021 14:34:14 +0000 (15:34 +0100)]
libedit: vendor import libedit 2021-03-28

(cherry picked from commit f9a159da2a292968cd5c37b56a6c43b6af8c5eed)
(cherry picked from commit 19318a62d7f8cfe2f0f5c24178fa33e8844ae5d1)

3 years agolibucl: vendor import snapshort 20210314
Baptiste Daroussin [Mon, 22 Mar 2021 14:13:02 +0000 (15:13 +0100)]
libucl: vendor import snapshort 20210314

(cherry picked from commit a0409676120c1e558d0ade943019934e0f15118d)

3 years agoMake pkg(7) use environment variables specified in pkg.conf
Moritz Schmitt [Tue, 27 Apr 2021 01:59:12 +0000 (03:59 +0200)]
Make pkg(7) use environment variables specified in pkg.conf

Modify /usr/sbin/pkg to use environment variables specified in pkg.conf.
This allows control over underlying libraries like fetch(3), which can
be configured by setting HTTP_PROXY.

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

(cherry picked from commit e869d3c60147bbb226b5ad97d2ef73391aeebafa)

3 years agosh: improve emacs mode
Baptiste Daroussin [Tue, 30 Mar 2021 09:37:29 +0000 (11:37 +0200)]
sh: improve emacs mode

In emacs mode, force ^R to backware search the history
This behaviour is the default in emacs mode for most of the other shells

Note: Note that this can still be overridden via $EDITRC, ~/.editrc or a
bind command after set -o emacs.

Approved by: jilles
Reviewed by: jilles, arichardson, pstef
Differential Revision: https://reviews.freebsd.org/D29494

(cherry picked from commit 660045fb5360d328da199ae78c89d5cc15b6d1ca)

3 years agoarcmsr(4): Fix SCSI command timeout on ARC-1886.
Xin LI [Wed, 21 Apr 2021 08:03:54 +0000 (01:03 -0700)]
arcmsr(4): Fix SCSI command timeout on ARC-1886.

Many thanks to Areca for continuing to support FreeBSD.

Submitted by: 黃清隆 <ching2048 areca com tw>

(cherry picked from commit 438b5532070f7c52e88f514380ee8662de1f600b)

3 years agoSet PCIe device's Max_Payload_Size to match PCIe root's.
Alexander Motin [Mon, 5 Apr 2021 14:34:40 +0000 (10:34 -0400)]
Set PCIe device's Max_Payload_Size to match PCIe root's.

Usually on boot the MPS is already configured by BIOS.  But we've
found that on hot-plug it is not true at least for our Supermicro
X11 boards.  As result, mismatch between root's configuration of
256 bytes and device's default of 128 bytes cause problems for some
devices, while others seem to work fine.

MFC after: 1 month
Sponsored by: iXsystems, Inc.

(cherry picked from commit 5a898b2b78ce04d608bbaaa0813424b11f921ae7)

3 years ago[fib algo] Update fib_gen counter under FIB_MOD_LOCK.
Alexander V. Chernikov [Wed, 28 Apr 2021 20:21:58 +0000 (20:21 +0000)]
[fib algo] Update fib_gen counter under FIB_MOD_LOCK.

MFC after: 3 days

(cherry picked from commit 41ce0e34ea42a4f7113d1ba15d25b9b64d5921b8)

3 years agoFix drace CTF for the rib_head.
Alexander V. Chernikov [Tue, 27 Apr 2021 07:47:53 +0000 (07:47 +0000)]
Fix drace CTF for the rib_head.

33cb3cb2e321 introduced an `rib_head` structure field under the
FIB_ALGO define. This may be problematic for the CTF, as some
 of the files including `route_var.h` do not have `fib_algo`
 defined.

Make dtrace happy by making the field unconditional.

Suggested by: markj

(cherry picked from commit bc5ef45aec3fa8acf2dd3408cebd207317543a8b)

3 years agoAdd rib_walk_from() wrapper for selective rib tree traversal.
Alexander V. Chernikov [Sun, 25 Apr 2021 11:59:40 +0000 (11:59 +0000)]
Add rib_walk_from() wrapper for selective rib tree traversal.

Provide wrapper for the rnh_walktree_from() rib callback.
As currently `struct rib_head` is considered internal to the
 routing subsystem, this wrapper is necessary to maintain isolation
 from the external code.

Differential Revision: https://reviews.freebsd.org/D29971
MFC after: 1 week

(cherry picked from commit f9668e42b44f22c9ab213eb9a4792d5acfcf6903)

3 years ago[fib algo] Delay algo init at fib growth to to allow to reliably use rib KPI.
Alexander V. Chernikov [Sun, 25 Apr 2021 10:22:45 +0000 (10:22 +0000)]
[fib algo] Delay algo init at fib growth to to allow to reliably use rib KPI.

Currently, most of the rib(9) KPI does not use rnh pointers, using
 fibnum and family parameters to determine the rib pointer instead.
This works well except for the case when we initialize new rib pointers
 during fib growth.
In that case, there is no mapping between fib/family and the new rib,
 as an entirely new rib pointer array is populated.

Address this by delaying fib algo initialization till after switching
 to the new pointer array and updating the number of fibs.
Set datapath pointer to the dummy function, so the potential callers
 won't crash the kernel in the brief moment when the rib exists, but
 no fib algo is attached.

This change allows to avoid creating duplicates of existing rib functions,
 with altered signature.

Differential Revision: https://reviews.freebsd.org/D29969
MFC after: 1 week

(cherry picked from commit 8a0d57baecf70aa7f49b0b1468f6264c75d8e6df)

3 years ago[rtsock] Enforce netmask/RTF_HOST consistency.
Alexander V. Chernikov [Fri, 23 Apr 2021 21:53:47 +0000 (21:53 +0000)]
[rtsock] Enforce netmask/RTF_HOST consistency.

Traditionally we had 2 sources of information whether the
 added/delete route request targets network or a host route:
netmask (RTA_NETMASK) and RTF_HOST flag.

The former one is tricky: netmask can be empty or can explicitly
 specify the host netmask. Parsing netmask sockaddr requires per-family
 parsing and that's what rtsock code traditionally avoided. As a result,
 consistency was not enforced and it was possible to specify network with
 the RTF_HOST flag and vice versa.

Continue normalization efforts from D29826 and D29826 and ensure that
 RTF_HOST flag always reflects host/network data from netmask field.

Differential Revision: https://reviews.freebsd.org/D29958
MFC after: 2 days

(cherry picked from commit 5d1403a79a3e56403fb63c062252a23fce81e5f1)

3 years agopf tests: Test using '<ifgroup>:network' in tables
Kristof Provost [Sun, 25 Apr 2021 10:18:48 +0000 (12:18 +0200)]
pf tests: Test using '<ifgroup>:network' in tables

MFC after: 1 week

(cherry picked from commit daa5350d0e0c5fbe42c5a057dd37b9d22df91bb7)

3 years agopfctl: Revert "pfctl: Another set skip <group> fix"
Kristof Provost [Mon, 26 Apr 2021 08:07:07 +0000 (10:07 +0200)]
pfctl: Revert "pfctl: Another set skip <group> fix"

This reverts commit 0c156a3c32cd0d9168570da5686ddc96abcbbc5a.
This fix broke using '<ifgroup>:network' in tables.

MFC after: 1 week

(cherry picked from commit d5b08e13dd6beb3436e181ff1f3e034cc8186584)

3 years agonfscommon: fix function name in comment
Rick Macklem [Tue, 20 Apr 2021 03:09:46 +0000 (20:09 -0700)]
nfscommon: fix function name in comment

(cherry picked from commit 78ffcb86d98fc9c27ac7a723c65621667036c42d)

3 years agonfsd: fix stripe size reply for the File Layout pNFS server
Rick Macklem [Tue, 20 Apr 2021 00:51:07 +0000 (17:51 -0700)]
nfsd: fix stripe size reply for the File Layout pNFS server

At a recent testing event I found out that I had misinterpreted
RFC5661 where it describes the stripe size in the File Layout's
nfl_util field. This patch fixes the pNFS File Layout server
so that it returns the correct value to the NFSv4.1/4.2 pNFS
enabled client.

This affects almost no one, since pNFS server configurations
are rare and the extant pNFS aware NFS clients seemed to
function correctly despite the erroneous stripe size.
It *might* be needed for correct behaviour if a recent
Linux client mounts a FreeBSD pNFS server configuration
that is using File Layout (non-mirrored configuration).

(cherry picked from commit 5a89498d19863d0c4cb074f9b93862a70040bf1b)

3 years agogpioc_detach: fix freeing of wrong pointers
Andriy Gapon [Tue, 23 Mar 2021 10:45:18 +0000 (12:45 +0200)]
gpioc_detach: fix freeing of wrong pointers

MFC after: 1 week

(cherry picked from commit 3c6b59567f61277ed487320aa9ad130c6894ad7a)

3 years agoimgact_elf: Ensure that the return value in parse_notes is initialized
Mark Johnston [Mon, 26 Apr 2021 18:53:16 +0000 (14:53 -0400)]
imgact_elf: Ensure that the return value in parse_notes is initialized

parse_notes relies on the caller-supplied callback to initialize "res".
Two callbacks are used in practice, brandnote_cb and note_fctl_cb, and
the latter fails to initialize res.  Fix it.

In the worst case, the bug would cause the inner loop of check_note to
examine more program headers than necessary, and the note header usually
comes last anyway.

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

(cherry picked from commit 409ab7e109c692014e3484a74af248dd7a4746e8)

3 years agogeom_uzip(4): fix a typo
Ceri Davies [Wed, 28 Apr 2021 04:55:32 +0000 (00:55 -0400)]
geom_uzip(4): fix a typo

While I was there, also fixed a whitespace issue reported by mandoc
-Tlint.

PR: 254338

(cherry picked from commit f33f2365eeefa38730e365bf6813cd0b90c9e9bc)

3 years agoarp(8): fixing the deletion failure of IEEE1394 associated addresses
Tai-hwa Liang [Mon, 12 Apr 2021 06:27:03 +0000 (06:27 +0000)]
arp(8): fixing the deletion failure of IEEE1394 associated addresses

Without this, 'arp -d ${IEEE1394_ADDRESS}' gives the following error:

arp: delete: cannot locate 10.0.0.71

Reviewed by: glebius
MFC after: 2 weeks

(cherry picked from commit a0d6d0d0b9aba6d4c025b2f2807e7c4b4c4b2415)