Commit graph

269344 commits

Author SHA1 Message Date
George V. Neville-Neil
528d5d75e9 Address issue pointed out in CVE-2020-25705
Add jitter to the ICMP bandwidth limit to deny a side-channel port scan.

Reviewed by:	kp, philip, cy, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27354

(cherry picked from commit ca4cd20c4a)
2022-04-07 09:35:36 +02:00
Navdeep Parhar
73fc39b1bf Fix typo (interrups -> interrupts) in a sysctl description in tcp_lro.c.
(cherry picked from commit 08c7f1b6d4)
2022-04-06 18:49:50 -07:00
Tong Zhang
110b8112e5 stge: fix null pointer dereference
stge_attach() could fail at line 464, sc->sc_spec remains NULL when
calling stge_detach(), thus bus_release_resources() at line 704 will
trigger null pointer dereference. We need to check the nulliness before
calling bus_release_resources().

PR:		258420
Reviewed by:	markj

(cherry picked from commit 2108cc7290)
2022-04-06 20:30:45 -04:00
Mark Johnston
229eff21b7 uma: Use the correct type for a return value
zone_alloc_bucket() returns a pointer, not a bool.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 54361f9020)
2022-04-06 20:30:45 -04:00
Mark Johnston
fb89cf93a5 ctf: Avoid passing a caddr_t to roundup2()
For some reason I can't reproduce this locally, but Jenkins complains.

Reported by:	Jenkins
Fixes:		bdf290cd3e ("ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}")

(cherry picked from commit 3fe1f21fb3)
2022-04-06 20:30:45 -04:00
Mark Johnston
d80faf878a ctf: Fix a -Wunused-but-set-variable warning
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cb6f722562)
2022-04-06 20:30:45 -04:00
Mark Johnston
e5b54808f7 ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}
ctfdump handles v2 and v3.  ctfconvert now emits only CTFv3, whereas
ctfmerge can merge v2 and v3 containers into v3 containers.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit bdf290cd3e)
2022-04-06 20:30:45 -04:00
Mark Johnston
a49aa9da78 libctf: Handle CTFv3 containers
In general, the patch adds indirection to minimize the amount of code
that needs to know about differences between v2 and v3.  Specifically,
some new ctf_get_ctt_* functions are added, and new LCTF_* macros are
added to use the underlying container's version to do the right thing.

CTF containers can have parent/child relationships, wherein a type ID in
one container refers to a type in the parent.  It is permitted for the
parent and child to have different versions.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a6fb869173)
2022-04-06 20:30:45 -04:00
Mark Johnston
8409eb0251 linker: Permit CTFv3 containers
Reviewed by:	Domagoj Stolfa
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8dbae4ce32)
2022-04-06 20:30:44 -04:00
Mark Johnston
2ecf3b58eb fbt: Add support for CTFv3 containers
The general aim in this and subsequent patches is to minimize the
amount of code that directly references CTF types such as ctf_type_t,
ctf_array_t, etc.  To that end, introduce some routines similar to the
existing fbt_get_ctt_size() (which exists to deal with differences
between v1 and v2) and change ctf_lookup_by_id() to return a void
pointer.

Support for v2 containers is preserved.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d9175438c0)
2022-04-06 20:30:44 -04:00
Mark Johnston
9818e5ebf3 ctf: Add definitions for CTFv3
These are based on definitions added to binutils' libctf.  Specifically:
- Type IDs are now encoded in 32 bits rather than 16, changing the
  layout of ctf_type_t, ctf_array_t, ctf_member_t and ctf_lmember_t.
- Type info is encoded in 32 bits rather than 16.  The type "kind" is
  extended from 5 bits to 6, and the type "vlen" is extended from 10
  bits to 25.

The main upside is that we remove the current limit, imposed by CTFv2,
of 2^{15} distinct types in the main kernel executable.  Other limits,
such as that on the number of elements in an enum, imposed by the vlen
limit, are also raised.

This change adds v2 and v3 flavours of macros and type definitions which
differ between the two versions.  Compatibility is preserved for now by
having generic names refer to the v2 definitions, so, e.g., ctf_type_t
is still a v2 type.

No functional change intended.

Reviewed by:	Domagoj Stolfa
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 994297b01b)
2022-04-06 20:30:44 -04:00
Mark Johnston
24597a09b9 linker: Simplify CTF container handling
Use sys/ctf.h to provide various definitions required to parse the CTF
header.  No functional change intended.

Reviewed by:	Domagoj Stolfa, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cab9382a2c)
2022-04-06 20:30:44 -04:00
Mark Johnston
3681c4f065 ctf: Import ctf.h from OpenBSD
Use it instead of the existing ctf.h from OpenSolaris.  This makes it
easier to use CTF in the core kernel, and to extend the CTF format to
support wider type IDs.

The imported ctf.h is modified to depend only on _types.h, and also to
provide macros which use the "parent" bit of a type ID to refer to types
in a parent CTF container.

No functional change intended.

Reviewed by:	Domagoj Stolfa, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2d5d2a986c)
2022-04-06 20:30:44 -04:00
Chandrakanth Patil
09e161a29e mrsas: if controller reset is in progress, refrain from firing DCMDs to
firmware in shutdown

If controller reset is in progress, at same time if system shutdown is
issued then corresponding shutdown function in driver will be invoked
where driver is waiting 15 seconds to complete the controller reset.

If the reset is not complteted within that time frame driver will go
ahead and fire cache flush and shutdown DCMDs which will end up
accessing the the queues which are not initialized due to undergoing
reset leads to FMU error in firmware.

Fix:
In shutdown function, if controller reset is not finished within 15
seconds than driver will return to the OS without firing any DCMDs.

Reviewed by: imp
PR: 261375

(cherry picked from commit 79c4c4be96)
2022-04-06 10:27:25 -06:00
Chandrakanth Patil
2ebe518597 mrsas: remove additional MPT command allocation for R1 FP command
There is an additional MPT command allocation for R1 fp command which
will lead to MPT command unavailablity in case of rigorous R1 FP IOs.

Remove additional MPT command allocation for R1 FP.

Reviewed by: imp
PR: 261377

(cherry picked from commit 241bb95552)
2022-04-06 10:27:25 -06:00
Warner Losh
c43786cc37 fix integer overflow bugs in *stosbt
68f57679d6 Fixed another class of integer overflows, but introduced a
boundary condition for 2-4s in ns conversion, 2-~4000s in us conversions
and 2-~4,000,000s in ms conversions. This was because we bogusly used
SBT_1S for the notion of 1 second, instead of the appropriate power of
10. To fix, just use the appropriate power of 10, which avoids these
overflows.

This caused some sleeps in ZFS to be on the order of an hour.

MFC:			1 day
PR:			263073
Sponsored by:		Netflix
Reviewed by:		asomers
Differential Revision:	https://reviews.freebsd.org/D34790

(cherry picked from commit 4c30b9ecd4)
2022-04-06 09:58:30 -06:00
Martin Matuska
43a449f2f1 libarchive: merge vendor bugfixes
Bugfixes:
  IS #1685 and OSS-Fuzz #38764 (security):
    (ISO reader) fix possible heap buffer overflow in read_children()
  IS #1715 and OSS-Fuzz #46279 (security):
    (RARv4 reader) fix heap-use-after-free in run_filters()

(cherry picked from commit 9f690fcfdc)
2022-04-06 10:24:00 +02:00
Jose Luis Duran
39665ad353 sysrc.8: Mention it requires chroot(8)
Option -R uses chroot(8). Mention it in the corresponding section.

MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D34630

(cherry picked from commit 1a0bd2665a)
2022-04-06 08:48:03 +02:00
Kyle Evans
227e52a9c0 bectl: push space-in-name check down into libbe
This check was previously in `create` only, not applying to renames.  It
should really be applied at the libbe level, so that we can avoid
writing about this restriction over and over again.

While we're here: `bectl rename` always succeeds, even when it doesn't.
Start returning the error.

Reported By:	Christian McDonald <cmcdonald netgate com>

(cherry picked from commit dadb9c7093)
2022-04-05 22:37:07 -05:00
Kyle Evans
0e90da6549 bectl: add some discussion about boot environment layouts
Discuss the standard type of layout, as well as the "deep" BE layout,
and some of the properties of both.  Point the various -r flags at this
new section, to help users understand which they're working with and
what the -r flag is actually doing. Note that we may just deprecate the
-r flag in future versions, but the flag will be recognized as a NOP at
that point.

(cherry picked from commit c0f846ff23)
2022-04-05 22:37:07 -05:00
Kyle Evans
6ce8e35cea libbe: fix be_mounted_at() with props after bootonce
propinfo.bootonce was filled with garbage, leading to a segfault later
during prop building.  Initialize it to NULL.

(cherry picked from commit d155d8e138)
2022-04-05 22:37:03 -05:00
Kyle Evans
bed9c972ae libbe: pull props for the correct dataset in be_mounted_at()
The props feature to this API was added as a "just in case", with no
planned consumer.  It turns out that it was implemented incorrectly,
tapping out props for the BE root (BE's parent) rather than the BE
itself in all cases.

Fetch properties for the dataset that's actually mounted at the queried
path.

Reported by:	Christian McDonald <cmcdonald netgate com>

(cherry picked from commit 31190aa02e)
2022-04-05 22:36:10 -05:00
Alexander Motin
e3b3dfa779 gpart: Avoid geom_gettree() call in "bootcode -b".
geom_gettree() may be pretty expensive on large systems, and it is
not needed if only -b flag specified, that is processed by kernel.

MFC after:	1 month

(cherry picked from commit 5c20bfc787)
2022-04-05 22:07:40 -04:00
Alexander Motin
59c15b83be geom: Allow "load" command for already loaded modules.
I see more user-friendly to do nothing if the module is already
loaded, rather than returning quite confusing error message.

As side effect it allows to avoid std_list_available() call, using
quite expensive on large systems geom_gettree().

MFC after:	1 month

(cherry picked from commit 5678114cd8)
2022-04-05 22:07:40 -04:00
Alexander Motin
aacc157926 GEOM: Make G_F_CTLDUMP also dump result.
MFC after:	1 month

(cherry picked from commit dd7a5bc1e6)
2022-04-05 22:07:40 -04:00
Alexander Motin
4340533721 GEOM: Introduce gctl_add_param() API.
Make gctl_add_param() API public, allowing more precise control over
parameter flags.  Previously it was impossible to properly declare
write-only ASCII parameters, used for result reporting, they were
declared as read-write binary instead, that was not nice.

MFC after:	1 month

(cherry picked from commit 2117cdd4b4)
2022-04-05 22:07:40 -04:00
Alexander Motin
be6abdb259 GEOM: Skip copyin() for GCTL_PARAM_WR parameters.
Kernel does not read those parameters, so copyin is pointless.

While there, replace some KASSERT()s with CTASSERT()s.

MFC after:	1 month

(cherry picked from commit 01b9c48b5d)
2022-04-05 22:07:39 -04:00
Bjoern A. Zeeb
72617f9246 net80211: validate Mesh ID length in ieee80211_parse_beacon
Reported by:	m00nbsd working with Trend Micro Zero Day Initiative

(cherry picked from commit fb8c87b4f3)
2022-04-05 18:59:22 -04:00
Mark Johnston
53f7220947 bhyve: validate e82545 checksum offset field
Reported by:	Mehdi Talbi, Synacktiv

(cherry picked from commit b0aa20bec5)
2022-04-05 18:59:08 -04:00
Bjoern A. Zeeb
7b9d8e33bc LinuxKPI: 802.11: fix RSSI (and NF)
As in 4a22cd6c4e nf and rss should be
signed and not unsigned.  Change the types in the header and while
here change a magic number to a define as done elsewhere (value does
not change).

When calculating c_rssi we need to make it relative so subtract nf.
And while here improve the debug output.

This will hopefully fix ifconfig wlanN list scan S:N output which
tools use to chose a BSSID and help net80211 internal calculations.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 60970a328e)
2022-04-05 14:47:13 +00:00
Bjoern A. Zeeb
7311128e69 net80211: correct types for nf and rssi
NF and RSSI should be signed and not unsigned to avoid problems.
Change the type accordingly.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4a22cd6c4e)
2022-04-05 14:47:08 +00:00
Bjoern A. Zeeb
2a8e509ba3 LinuxKPI: 802.11: fix compat code for i386
Compiling another driver on i386 revealed two problems:
- ieee80211_tx_info.status.status_driver_data space needs to be
  calculated.  While a pointer is 32bit vm_paddr_t is 64 bit on i386
  so we didn't fit more than one of these in but needed more space.
- the arguments to ieee80211_txq_get_depth() are expected to
  unsigned long and not uint64_t.

No user noticable changes.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 86220d3cbd)
2022-04-05 14:46:58 +00:00
Warner Losh
4e94b3542d linuxkpi: move io_mapping_create_wc to .c
Move io_mapping_create_wc to .c because it encodes the size of struct
io_mapping so we move this from the client module to the linuxkpi
module.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34776

(cherry picked from commit 132b00f906)
2022-04-05 08:40:11 -06:00
Warner Losh
211621030e linuxkpi: Move lkpi_pcim_iomap_devres_find to .c file
lkpi_pcim_iomap_devres_find encodes the size of struct pcim_iomap_devres
in the code, so move from .h to .c to move from client driver to
linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34775

(cherry picked from commit 2bf3361d56)
2022-04-05 08:40:11 -06:00
Warner Losh
bc01b38394 linuxkpi: Move pci_alloc_irq_vectors to .c file
pci_alloc_irq_vectors encodes the size of struct msix_entry
into its code. Move from .h to .c to move this knowledge from
client modules to linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34774

(cherry picked from commit 36b5c44002)
2022-04-05 08:40:11 -06:00
Warner Losh
4859994c42 linuxkpi: Move pci_request_region and _lkpi_pci_iomap into .c
Both pci_request_region and _lkpi_pci_iomap encode the size of struct
pci_mmio_region into their code. Move from .h to .c files to move that
knowledge from the client drivers into the linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34773

(cherry picked from commit 1cdb25340f)
2022-04-05 08:40:11 -06:00
Warner Losh
2cd55de380 linuxkpi: Move lkpi_pci_devres_get_alloc into .c file
lkpi_pci_devres_get_alloc encodes the struct pci_devres into its
code. Move from .h file to .c file to move this knowledge into linuxkpi
module.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34772

(cherry picked from commit 3ea682e21e)
2022-04-05 08:40:10 -06:00
Warner Losh
d1f93d6721 linuxkpi: Move cdev_alloc into .c file
Move cdev_alloc into linux_compat.c since it encodes the size of struct
linux_cdev into the client modules otherwise.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34771

(cherry picked from commit aca0bcbca3)
2022-04-05 08:40:10 -06:00
Warner Losh
98d2b4a158 linuxkpi: Move class_create to .c file
class_create encodes the size of struct class into the generated
code. Move from .h file to .c file to move this knowledge from the
client modules that call this into the linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34769

(cherry picked from commit 1341ac9f9c)
2022-04-05 08:40:10 -06:00
Warner Losh
417f1c8149 linuxkpi: Move device_create_groups_vargs to linux_compat.c
device_create_groups_vargs encodes the size of struct device. Move
definition from .h to .c to move this size into the linuxkpi module
rather than encoding it in all client driver modules.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34768

(cherry picked from commit 702b687503)
2022-04-05 08:40:10 -06:00
Warner Losh
2f3d11894b linuxkpi: move kobject_create to .c file
kobject_create knows the size of struct kobject. Move it to
linux_compat.c so this knowledge is confined to the loadable module and
not the clients.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34767

(cherry picked from commit 36929b5584)
2022-04-05 08:40:10 -06:00
Mateusz Piotrowski
39289f6127 Cross-reference nextboot(8) and freebsd-update(8)
MFC after:	1 week

(cherry picked from commit 075999d3f1)
2022-04-05 16:08:43 +02:00
Mateusz Piotrowski
dee5ec942e freebsd-update.8: Fix use of mdoc(8) macros
- Use Ar for arguments.
- Use Cm for freebsd-update commands like "upgrade".
- Reference other manuals with Xr when possible.

MFC after:	1 week

(cherry picked from commit 15647a7106)
2022-04-05 16:08:43 +02:00
Mateusz Piotrowski
69c70456e8 ifconfig.8: Simplify -G & -g synopsis
MFC after:	1 week

(cherry picked from commit d1d14f0428)
2022-04-05 16:08:43 +02:00
Warner Losh
86d5c66106 linuxkpi: add padding to struct pci_driver
Add 32 or 64 bytes of padding to struct pci_driver at the end in the
_spare field like we should have done when we branched stable/13, but
neglected to do so since we didn't properly anticipate the need.

We cannot safely use these spare fields until after 13.0 EOL since
drivers compiled on 13.0 won't have that space reserved and we'll step
on something else using them. This isn't 100% KBI compatible through the
13.x release branch, but is compatible enough so that drm packages built
on the oldest supported release will work on the latest stable/13 and
any newer releases. It's not ideal, but makes the best of a bad
situation and is a pragmatic approach that belatedly builds in some
future proofing.

Direct commit to stable/13 because this is not relevant to main in this
exact form.

Sponsored by:		Netflix
Reviewed by:		bz
Differential Revision:	https://reviews.freebsd.org/D34754
2022-04-04 22:54:49 -06:00
Warner Losh
aa61c28b42 linuxkpi: Restore the KBI for struct pci_driver
The size of the 13.0 version of struct pci_driver was 92 or 184 bytes on
32- or 64-bit systems respectively. We recently added bsd_probe_return
at the end of this struct, breaking the KBI on the stable/13 branch.

Fix this by removing the isdrm member. We don't need it because we can
do a strcmp in the few places that need it as they aren't performance
critical. Move the newly added bsd_probe_return to that slot. It's the
same size in all our supported KBIs as bool and fits into that slot due
to padding rules.

Direct commit to stable/13 because this is not relevant to main.

Sponsored by:		Netflix
Reviewed by:		bz
Differential Revision:	https://reviews.freebsd.org/D34754
2022-04-04 22:48:27 -06:00
Piotr Kubaj
16c3f5d03e powerpc: implement __clear_cache
Merge LLVM commit 81f5c6270cdfcdf80e6296df216b696a7a37c8b5.

This fixes runtime of most notably pcre libraries (currently patched in ports),
and probably also other ports since currently __clear_cache() just calls
SIGABRT on powerpc.

Reviewed by:	dim
Differential Revision: https://reviews.freebsd.org/D34736

(cherry picked from commit 57b6ac48a9)
2022-04-05 02:33:22 +02:00
Konstantin Belousov
123b4031e9 sys/stdatomic.h: be nicer to c++
PR:	262683

(cherry picked from commit c1a24b9dbe)
2022-04-05 01:55:33 +03:00
Mike Karels
a999acabfc Add release note about change to lowest address in IPv4 (sub)net.
This change was made earlier, note it now.
This is a direct commit.
2022-04-04 17:05:57 -05:00
Xin LI
c4727a47f1 lib/libz: remove ZLIBprivate_1.0 namespace.
These symbols were hidden and no longer exposed, and were never exposed in headers.

MFC after:	3 days

(cherry picked from commit a7f127b653)
2022-04-04 15:30:18 -04:00