]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agopowerd(8): Add rc.conf(5) to see also
Felix Johnson [Sun, 7 Nov 2021 02:39:23 +0000 (22:39 -0400)]
powerd(8): Add rc.conf(5) to see also

powerd_flags is mentioned in rc.conf(5) and can be set there and pass to
powerd.

PR: 258320
Reported by: Michael <michael.hmich@gmail.com>

(cherry picked from commit ec071430a7822997619fe6d99853d8f49ea10b20)

2 years agoscsi_cd: Improve TOC access validation
Mark Johnston [Wed, 3 Nov 2021 19:09:17 +0000 (15:09 -0400)]
scsi_cd: Improve TOC access validation

1. During CD probing, we read the TOC header to find the number of
   entries, then read the TOC itself.  The header determines the number
   of entries, which determines the amount of data to read from the
   device into the softc in the CD_STATE_MEDIA_TOC_FULL state.  We
   hard-code a limit of 99 tracks (plus one for the lead-out) in the
   softc, but were not validating that the size reported by the media
   would fit in this hard-coded limit.  Kernel memory corruption could
   occur if not.[1]  Add validation to check this, and refuse to cache
   the TOC if it would not fit.

2. The CDIOCPLAYTRACKS ioctl uses caller provided track numbers to index
   into the TOC, but we only validate the starting index.  Add
   validation of the ending index.

Also, raise the hard-coded limit from 100 tracks to 170, per a
suggestion from Ken.

Reported by: C Turt <ecturt@gmail.com> [1]
Reviewed by: ken, avg
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6afabf00920fb8d41b8f013090f282c17c117efc)

2 years agonfscl: Add a missing delegation lock release
Rick Macklem [Tue, 26 Oct 2021 02:09:14 +0000 (19:09 -0700)]
nfscl: Add a missing delegation lock release

There was a case in nfscl_doiods() where the function would return
without releasing the delegation shared lock, if it was aquired by
the call to nfscl_getstateid().  This patch adds that release.

I have never observed a failure due to this missing release, so I
do not know if it ever happens in practice.  However, since the pNFS
client is not yet heavily used, it might be the case.

Found by code inspection during a recent NFSv4 IETF working group
testing event.

(cherry picked from commit 23024f004a4c5659bfcb0b08fac2211ae925ee58)

2 years agoarm: fix a typo in nvidia/drm2/tegra_bo.c
Mateusz Guzik [Mon, 25 Oct 2021 18:42:10 +0000 (18:42 +0000)]
arm: fix a typo in nvidia/drm2/tegra_bo.c

Unbreaks building TEGRA124

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

(cherry picked from commit e2493f4912cabd1d04be88fd17139a64bf2a2622)

2 years agortld: fix dangerous_ld_env calculation for ld_dynamic_weak
Konstantin Belousov [Sat, 6 Nov 2021 03:00:52 +0000 (05:00 +0200)]
rtld: fix dangerous_ld_env calculation for ld_dynamic_weak

(cherry picked from commit 8363963a8f3fc8226b1e3aa627e2fdd09688704e)

2 years agossh: move common Makefile boilerplate to a new ssh.mk
Ed Maste [Tue, 2 Nov 2021 18:48:33 +0000 (14:48 -0400)]
ssh: move common Makefile boilerplate to a new ssh.mk

This moves SSHDIR and ssh_namespace.h handling to a common location,
and will simplify future work such as adding U2F support (D32509).

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

(cherry picked from commit 9d63429fa16352f58037ac2aa6ddc734b25e8331)

2 years agoopenssh: remove unnecessary $FreeBSD$ tags
Ed Maste [Wed, 8 Sep 2021 01:48:15 +0000 (21:48 -0400)]
openssh: remove unnecessary $FreeBSD$ tags

Diff reduction against upstream: remove $FreeBSD$ tags from files where
the tag itself is the only difference from upstream.

(cherry picked from commit 0e642632e64a8b8ca740ce3307abe116c990e0b6)

2 years agoopenssh: restore local change to gssapi include logic
Ed Maste [Thu, 2 Sep 2021 20:43:59 +0000 (16:43 -0400)]
openssh: restore local change to gssapi include logic

/usr/include/gssapi.h claims that it is deprecated, and gssapi/gssapi.h
should be used instead.  So, test HAVE_GSSAPI_GSSAPI_H first falling
back to HAVE_GSSAPI_H.

This will be submitted upstream.

Fixes: 6eac665c8126 ("openssh: diff reduction against...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31810

(cherry picked from commit 258f5f79bb36e3e6955e7fb149cd2f50265a9ea5)

2 years agoopenssh: diff reduction against upstream 7.9p1
Ed Maste [Thu, 2 Sep 2021 17:38:30 +0000 (13:38 -0400)]
openssh: diff reduction against upstream 7.9p1

Clean up whitespace and nonfunctional differences, and unused functions.

(cherry picked from commit 6eac665c8126af387a457ee8a08303c6607a6769)

2 years agoPartially revert ac76bc1145dd because it is no longer necessary
Dimitry Andric [Fri, 5 Nov 2021 21:26:16 +0000 (22:26 +0100)]
Partially revert ac76bc1145dd because it is no longer necessary

In ac76bc1145dd, I added a few volatiles to work around ctrig_test
failures with {inf,inf}. This is not necessary anymore now, since in
3b00222f156d we added -fp-exception-behavior=maytrap for clang >= 10 in
libm's Makefile. (The flag tells clang to use stricter floating point
semantics, which libm depends on.)

PR: 244732, 254911
Fixes: ac76bc1145dd

(cherry picked from commit e2157cd0000f6dbb6465d7a885f2dcfd4d3596cb)

2 years agostrip/objcopy: handle empty file as unknown
Ed Maste [Mon, 25 Oct 2021 21:25:26 +0000 (17:25 -0400)]
strip/objcopy: handle empty file as unknown

Previously strip reported a somewhat cryptic error for empty files:

    strip: elf_begin() failed: Invalid argument

Add a special case to treat empty files as with an unknown file format.
This is consistent with llvm-strip.  GNU strip produces no output which
does not seem like useful behaviour (but it does exit with status 1).

Reported by: andrew
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32648

(cherry picked from commit 179219ea046f46927d6478d43431e8b541703539)

2 years agoelftoolchain: stop leaving tempfiles on error
Chris Rees [Mon, 15 Feb 2021 11:37:06 +0000 (11:37 +0000)]
elftoolchain: stop leaving tempfiles on error

Temporary files were not cleaned up, resulting in $TMPDIR or even
the current directory becoming littered with ecp.* files.

This happened with error and even sometimes on success!

Approved by: dim
MFC after: 4 weeks
Accepted upstream: https://sourceforge.net/p/elftoolchain/code/3918/
Differential Revision: https://reviews.freebsd.org/D28651

(cherry picked from commit 5ac70383c8b32eeec80426e837960977971c7c2b)

2 years agofuser: restore functionality by fixing fsid type
Andriy Gapon [Mon, 1 Nov 2021 06:40:17 +0000 (08:40 +0200)]
fuser: restore functionality by fixing fsid type

Use types from sys/stat.h for the filesystem and inode numbers for extra
safety.

PR: 259504
Reported by: Markus Wild <freebsd-bugs@virtualtec.ch>
MFC after: 1 week

(cherry picked from commit e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a)

2 years agocosl(): fix polynomial approximation coefficients for ld128 version
Steve Kargl [Tue, 2 Nov 2021 08:54:10 +0000 (10:54 +0200)]
cosl(): fix polynomial approximation coefficients for ld128 version

PR: 218514

(cherry picked from commit 6d04e1422e70ca0a77552782c01c291f90716773)

2 years agovmci: Avoid relying on macro expansion to provide correct syntax
Mark Johnston [Wed, 3 Nov 2021 15:19:53 +0000 (11:19 -0400)]
vmci: Avoid relying on macro expansion to provide correct syntax

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c75c1d2df9b3839319f6b5e2fad0b757eebd9c55)

2 years agodate: Capitalize seconds string in synopses
Mateusz Piotrowski [Wed, 3 Nov 2021 11:59:49 +0000 (12:59 +0100)]
date: Capitalize seconds string in synopses

This makes it consistent with other date(1) implementations. Also, it
feels more consistent since hours and minutes are already represented as
HH and MM respectively.

MFC after: 3 days

(cherry picked from commit c537bf9d5903d0689321f83691341c93b5919172)

2 years agodate.1: Fix some style issues and examples
Mateusz Piotrowski [Wed, 3 Nov 2021 10:26:46 +0000 (11:26 +0100)]
date.1: Fix some style issues and examples

- Use Cm instead of Ar or Sq for command modifiers of the -v flag.
- Remove unnecessary "Ar ..." from the synopsis. It's not clear what it
  was referring to.
- Add missing arguments to the -f and -v flags.
- Stylize the dot before "ss" with Cm in the default format in the -f
  flag description.
- Set LC_ALL=C in the last example so that the output format of
  date(1) always matches the specified format of the -f flag not matter
  the locale.
- List the -f flag as optional in all usage lines in the synopsis.

MFC after: 3 days

(cherry picked from commit 00133d5c5e6aae01663eca40993abd5e6137425b)

2 years agodate: Clean up synopses
Mateusz Piotrowski [Wed, 3 Nov 2021 11:58:09 +0000 (12:58 +0100)]
date: Clean up synopses

MFC after: 3 days

(cherry picked from commit a12b16f48f747339ccae6dd80cc0c0c4ad5b7846)

2 years agodpv: Fix synopsis formatting & sort options
Mateusz Piotrowski [Tue, 2 Nov 2021 07:05:48 +0000 (08:05 +0100)]
dpv: Fix synopsis formatting & sort options

MFC after: 3 days

(cherry picked from commit a85aa7f9d3bfd26f5dc07f70cb7ba281bfc69f20)

2 years agodpv.1: Do not use mdoc macros for Bl width
Mateusz Piotrowski [Tue, 2 Nov 2021 07:17:19 +0000 (08:17 +0100)]
dpv.1: Do not use mdoc macros for Bl width

Macros do not expand there.

MFC after: 3 days

(cherry picked from commit 3693250e8a746053291849d8442f912336f0bf1b)

2 years agodpv.1: Fix an example
Mateusz Piotrowski [Tue, 2 Nov 2021 07:11:50 +0000 (08:11 +0100)]
dpv.1: Fix an example

dpv(1) requires a label to be specified.

MFC after: 3 days

(cherry picked from commit f7c7a6ac00f13e2d47d50844dd92071933c33a56)

2 years agortld: Do not install libmap.conf when installing the COMPAT32 version
Emmanuel Vadot [Wed, 13 Oct 2021 12:40:26 +0000 (14:40 +0200)]
rtld: Do not install libmap.conf when installing the COMPAT32 version

This has the effect of installing the same file twice at the same location
and confuse pkgbase as we add this file twice in the package config part.

MFC after:  1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit d0f0e0bd741af867582ceede8ac1b0aec90eae2d)

2 years agoFix a common typo in syctl descriptions
Gordon Bergling [Wed, 3 Nov 2021 19:49:24 +0000 (20:49 +0100)]
Fix a common typo in syctl descriptions

- s/maxiumum/maximum/

(cherry picked from commit c28e39c3d6d10a72800b7f49c23453fcc1bca8cc)

2 years agonetinet: Fix a common typo in source code comments
Gordon Bergling [Wed, 3 Nov 2021 15:21:49 +0000 (16:21 +0100)]
netinet: Fix a common typo in source code comments

- s/writting/writing/

(cherry picked from commit bb91496a85176cfc005cf141fe1262c9ad5507d4)

2 years agoocs_fs: Fix two typos in source code comments
Gordon Bergling [Wed, 3 Nov 2021 16:17:51 +0000 (17:17 +0100)]
ocs_fs: Fix two typos in source code comments

- s/maxium/maximum/
- s/maxiumum/maximum/

(cherry picked from commit 7b56cb0462c39cb190fc23e0e1190bdc89c163c8)

2 years agogjournal(8): Fix a typo in a source code comment
Gordon Bergling [Wed, 3 Nov 2021 16:14:00 +0000 (17:14 +0100)]
gjournal(8): Fix a typo in a source code comment

- s/writting/writing/

(cherry picked from commit 9d2e51884ef286bab94d48d062cf71f6a74a3f99)

2 years agong_pptpgre(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 3 Nov 2021 16:15:59 +0000 (17:15 +0100)]
ng_pptpgre(4): Fix a typo in a source code comment

- s/mimimum/minimum/

(cherry picked from commit 40a57b00f9a76f32a271d258acec4075966eec32)

2 years agoixgbe(4): Fix a few typos in source code comments
Gordon Bergling [Wed, 3 Nov 2021 15:16:20 +0000 (16:16 +0100)]
ixgbe(4): Fix a few typos in source code comments

- s/Manageblility/Managebility/
- s/alows/allows/

Obtained from: NetBSD

(cherry picked from commit 8da5034954911ecad0ce1e55acd3b50797bc338a)

2 years agofexecve(2): allow O_PATH file descriptors opened without O_EXEC
Konstantin Belousov [Wed, 3 Nov 2021 12:51:06 +0000 (14:51 +0200)]
fexecve(2): allow O_PATH file descriptors opened without O_EXEC

(cherry picked from commit be10c0a910155709dc4e521db3349d50e0440018)

2 years agoprocfs_doprocfile(): simplify
Konstantin Belousov [Thu, 4 Nov 2021 03:58:06 +0000 (05:58 +0200)]
procfs_doprocfile(): simplify

(cherry picked from commit 15bd9fa3bea794054b4a5bd2f4bb71b0ba3aa3ba)

2 years agoproc_get_binpath(): provide syntaxically correct value for unused NDINIT arg
Konstantin Belousov [Thu, 4 Nov 2021 00:53:21 +0000 (02:53 +0200)]
proc_get_binpath(): provide syntaxically correct value for unused NDINIT arg

(cherry picked from commit 7ac82c96fe79a6a9dcf595ef4860ed75d3511414)

2 years agoproc_get_binpath(): return empty string instead of NULL
Konstantin Belousov [Wed, 3 Nov 2021 15:11:33 +0000 (17:11 +0200)]
proc_get_binpath(): return empty string instead of NULL

(cherry picked from commit 02de91d740235f186321d7d3e11d09737daba43e)

2 years agofexecve(2): restore the attempts to calculate the executable path
Konstantin Belousov [Wed, 3 Nov 2021 12:58:03 +0000 (14:58 +0200)]
fexecve(2): restore the attempts to calculate the executable path

(cherry picked from commit e4ce23b238a162f5d36afe8ef49dcd66901138a1)

2 years agoprocfs: return right hardlink from /proc/curproc/file
Konstantin Belousov [Fri, 29 Oct 2021 01:43:32 +0000 (04:43 +0300)]
procfs: return right hardlink from /proc/curproc/file

PR: 248184

(cherry picked from commit e5248548f95ff1c89667847e0d945dea38adeca7)

2 years agoExtract proc_get_binpath() from sysctl_kern_proc_pathname()
Konstantin Belousov [Fri, 29 Oct 2021 01:42:59 +0000 (04:42 +0300)]
Extract proc_get_binpath() from sysctl_kern_proc_pathname()

(cherry picked from commit f34fc6ba06a10e0f2a505ec0dd2f2fab2a79e53d)

2 years agosys/proc.h: put proc_add_orphan() into proper place
Konstantin Belousov [Fri, 29 Oct 2021 22:02:32 +0000 (01:02 +0300)]
sys/proc.h: put proc_add_orphan() into proper place

(cherry picked from commit b4c7d45c849071b31936fec6ec43f3d4df3ef3d8)

2 years agosysctl kern.proc.procname: report right hardlink name
Konstantin Belousov [Sat, 23 Oct 2021 19:01:37 +0000 (22:01 +0300)]
sysctl kern.proc.procname: report right hardlink name

PR: 248184

(cherry picked from commit ee92c8a842d61ffda8d111e1b0e398085c5bfb3a)

2 years agoexec: store parent directory and hardlink name of the binary in struct proc
Konstantin Belousov [Sat, 23 Oct 2021 18:44:22 +0000 (21:44 +0300)]
exec: store parent directory and hardlink name of the binary in struct proc

(cherry picked from commit 351d5f7fc5161ededeaa226ee3f21a438ee4a632)

2 years agoexec: provide right hardlink name in AT_EXECPATH
Konstantin Belousov [Sat, 23 Oct 2021 00:24:08 +0000 (03:24 +0300)]
exec: provide right hardlink name in AT_EXECPATH

PR: 248184

(cherry picked from commit 0c10648fbb758bb76fd29330b7fe1bc519252325)

2 years agoMake vn_fullpath_hardlink() externally callable
Konstantin Belousov [Sat, 23 Oct 2021 00:23:17 +0000 (03:23 +0300)]
Make vn_fullpath_hardlink() externally callable

(cherry picked from commit 9a0bee9f6a77a85e4dfb27c9a33d4e210d05b469)

2 years agostruct image_params: use bool type for boolean members
Konstantin Belousov [Sat, 23 Oct 2021 15:05:56 +0000 (18:05 +0300)]
struct image_params: use bool type for boolean members

(cherry picked from commit 15bf81f354a428723d7e9ea61ea215d4195aa050)

2 years agodo_execve(): switch boolean locals to use bool type
Konstantin Belousov [Sat, 23 Oct 2021 14:47:28 +0000 (17:47 +0300)]
do_execve(): switch boolean locals to use bool type

(cherry picked from commit 9d58243fbc4a1931aba618f8f5f6872779656c42)

2 years agokern_exec.c: style
Konstantin Belousov [Fri, 22 Oct 2021 23:49:30 +0000 (02:49 +0300)]
kern_exec.c: style

(cherry picked from commit 143dba3a914294c2f4de80a46ffd04cd8b25246f)

2 years agollvm BPF target: add missed source files
Dimitry Andric [Tue, 2 Nov 2021 16:49:34 +0000 (17:49 +0100)]
llvm BPF target: add missed source files

Otherwise, linking llvm binaries with this target enabled (which is not
the default) will fail with a number of undefined symbol errors:

  ld: error: undefined symbol: llvm::initializeBPFAdjustOptPass(llvm::PassRegistry&)
  ld: error: undefined symbol: llvm::initializeBPFCheckAndAdjustIRPass(llvm::PassRegistry&)
  ld: error: undefined symbol: llvm::createBPFCheckAndAdjustIR()
  ld: error: undefined symbol: llvm::createBPFAdjustOpt()
  ld: error: undefined symbol: llvm::BPFAdjustOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)

Reported by: Michael Dexter <editor@callfortesting.org>

(cherry picked from commit d30dc78f798adebda488d2b8e21290268d2fb501)

2 years agopowerpc64le: stand fixes
Leandro Lupori [Wed, 20 Oct 2021 18:48:33 +0000 (15:48 -0300)]
powerpc64le: stand fixes

Fix boot1 and loader on PowerPC64 little-endian (LE).

Due to endian issues, boot1 couldn't find the UFS boot partition
and loader wasn't able to load the kernel. Most of the issues
happened because boot1 and loader were BE binaries trying to access
LE UFS partitions and because loader expects the kernel ELF image
to use the same endian as itself.

To fix these issues, boot1 and loader are now built as LE binaries
on PPC64LE. To support this, the functions that call OpenFirmware
were enhanced to correctly perform endian conversion on its input
and output arguments and to change the CPU into BE mode before
making the calls, as OpenFirmware always runs in BE. Besides that,
some other small fixes were needed.

Submitted by: bdragon (initial version)
Reviewed by: alfredo, jhibbits
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D32160

(cherry picked from commit f83288645cd9726c24ca67292fbc3abb4eb65a36)

2 years agopowerpc64: fix OFWFB with Radix MMU
Leandro Lupori [Thu, 14 Oct 2021 13:39:52 +0000 (10:39 -0300)]
powerpc64: fix OFWFB with Radix MMU

Current implementation of Radix MMU doesn't support mapping
arbitrary virtual addresses, such as the ones generated by
"direct mapping" I/O addresses. This caused the system to hang, when
early I/O addresses, such as those used by OpenFirmware Frame Buffer,
were remapped after the MMU was up.

To avoid having to modify mmu_radix_kenter_attr just to support this
use case, this change makes early I/O map use virtual addresses from
KVA area instead (similar to what mmu_radix_mapdev_attr does), as
these can be safely remapped later.

Reviewed by: alfredo (earlier version), jhibbits (in irc)
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D31232

(cherry picked from commit 76384bd10fdbb97be2803d969905f15a84255d6a)

2 years agoefirt(9): Correct efi_var_set definition in the manpage
Lakshman [Tue, 2 Nov 2021 07:17:38 +0000 (03:17 -0400)]
efirt(9): Correct efi_var_set definition in the manpage

PR: 257531

(cherry picked from commit 2fe85640b2a3bf5c377dd180e40cd3d6e1a4f1f4)

2 years agodevinfo(8): Remove cross-reference to pnpinfo(8)
Felix Johnson [Mon, 1 Nov 2021 16:29:12 +0000 (12:29 -0400)]
devinfo(8): Remove cross-reference to pnpinfo(8)

devinfo(8) manpage contains reference to pnpinfo(8) which existed at the
time. Remove it.

PR: 232587
Reported by: Graham Perrin <grahamperrin@gmail.com>

(cherry picked from commit dde6071adcf203b185c185289f687c2bd51532fb)

2 years agowpa: Fix WITHOUT_CRYPT build
Cy Schubert [Thu, 28 Oct 2021 23:55:48 +0000 (16:55 -0700)]
wpa: Fix WITHOUT_CRYPT build

PASN requires CRYPT and when built WITHOUT_CRYPT buildworld
fails. Only enable PASN when MK_CRYPT is enabled (default).

PR: 259517
Reported by: emaste
Fixes: c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5

(cherry picked from commit a30e8044aa4753858c189f3384dae2b2f25a150b)

2 years agowpa: Address CTRL-EVENT-SCAN-FAILED
Cy Schubert [Thu, 9 Sep 2021 00:20:52 +0000 (17:20 -0700)]
wpa: Address CTRL-EVENT-SCAN-FAILED

5fcdc19a8111 didn't fully resolve the issue. There remains a report
that an ifconfig wlan0 up by itself is insufficient. Ifconfig down
must precede it.

Reported by: Filipe da Silva Santos <contact _ shiori_com_br>
Fixes: 5fcdc19a8111

(cherry picked from commit d06d7eb09131edea666bf049d6c0c55672726f76)

2 years agowpa: Address CTRL-EVENT-SCAN-FAILED
Cy Schubert [Tue, 7 Sep 2021 01:48:39 +0000 (18:48 -0700)]
wpa: Address CTRL-EVENT-SCAN-FAILED

Some installations may experience CTRL-EVENT-SCAN-FAILED when
associating to an AP. Installations that specify
ifconfig_wlan0="WPA ... up" in rc.conf do not experience
the problem whereas those which specify ifconfig_wlan0="WPA" without
the "up" will experience CTRL-EVENT-SCAN_FAILED.

However those that specify "up" in ifconfig_wlan0 will be able to
reproduce this problem by service netif stop wlan0;
service netif start wlan0. Interestingly The service netif stop/start
problem is reproducible on the older wpa 2.9 as well.

Reported by: dhw
Reported by: "Oleg V. Nauman" <oleg _ theweb_org_ua>
Reported by: Filipe da Silva Santos <contact _ shiori_com_br>
Reported by: Jakob Alvermark <jakob _ alvermark_net>

(cherry picked from commit 5fcdc19a81115d975e238270754e28557a2fcfc5)

2 years agowpa: Enable RSN Preauthentication
Cy Schubert [Fri, 3 Sep 2021 13:14:59 +0000 (06:14 -0700)]
wpa: Enable RSN Preauthentication

RSN Preauthentication allows a station autnetnicate to an AP that
it is not associated with yet while associated with a different AP.
This allows athentication to multiple APs simulteneously.

Tested by: philip

(cherry picked from commit bd452dcbede69b1862c769f244948f94b86448b5)

2 years agowpa: Enable MBO
Cy Schubert [Fri, 3 Sep 2021 13:14:01 +0000 (06:14 -0700)]
wpa: Enable MBO

Enable WiFi 6 MBO (Multi Band Operation). MBO is a prereq to 802.11ax.

MBO allows the efficient use of multiple frequency bands (channels).

To facilitate MBO, WNM (Wireless Network Monitoring) is a prerequisite.
It is required to build.

Tested by: philip

(cherry picked from commit 3968b47cd974e503df303265f3be9ba5865499ab)

2 years agowpa: Import wpa_supplicant/hostapd commits up to b4f7506ff
Cy Schubert [Fri, 3 Sep 2021 13:07:19 +0000 (06:07 -0700)]
wpa: Import wpa_supplicant/hostapd commits up to b4f7506ff

Merge vendor commits 40c7ff83e74eabba5a7e2caefeea12372b2d3f9a,
efec8223892b3e677acb46eae84ec3534989971f, and
2f6c3ea9600b494d24cac5a38c1cea0ac192245e.

Tested by: philip

(cherry picked from commit c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5)

2 years agoUnmap shared page manually before doing vm_map_remove() on exit or exec
Konstantin Belousov [Wed, 20 Oct 2021 20:32:59 +0000 (23:32 +0300)]
Unmap shared page manually before doing vm_map_remove() on exit or exec

(cherry picked from commit 1c69690319c5bb7deae6ce1add6ea25bb40b3b91)

2 years agoamd64 pmap: adjust the empty pmap optimization in pmap_remove()
Konstantin Belousov [Wed, 20 Oct 2021 20:30:34 +0000 (23:30 +0300)]
amd64 pmap: adjust the empty pmap optimization in pmap_remove()

(cherry picked from commit 0b3bc7288984c17da00d9f8c29f116d56bf44d35)

2 years agoamd64 pmap: account for the top-level pages
Konstantin Belousov [Wed, 20 Oct 2021 01:03:43 +0000 (04:03 +0300)]
amd64 pmap: account for the top-level pages

(cherry picked from commit e93b5adb6bb83d487eaa4211ac26e116db748c63)

2 years agokern_tc.c: Scaling/large delta recalculation
Sebastian Huber [Thu, 28 Oct 2021 08:22:58 +0000 (10:22 +0200)]
kern_tc.c: Scaling/large delta recalculation

(cherry picked from commit ae750fbac72387c05c8e13623c2465b20497b4be)

2 years agoForce WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL
Ed Maste [Thu, 28 Oct 2021 21:07:34 +0000 (17:07 -0400)]
Force WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL

Discussed with: jhb
MFC after: 1 week
Reported by: Michael Dexter, Build Option Survey
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6940d0e4703e72b8ea445541567d0ef64c2bb94b)

2 years agoiscsid: set max_recv_data_segment_length to what we advertise
Ed Maste [Thu, 21 Oct 2021 15:09:58 +0000 (11:09 -0400)]
iscsid: set max_recv_data_segment_length to what we advertise

Previously we updated the conection's conn_max_recv_data_segment_length
only when we received a response containing MaxRecvDataSegmentLength
from the target.  If the target did not send MaxRecvDataSegmentLength
then we left conn_max_recv_data_segment_length at the default (i.e.,
8192).  A target could then send more data than that defult (up to our
advertised maximum), and we would drop the connection.

RFC 7143 specifies that MaxRecvDataSegmentLength is Declarative, not
negotiated.  Just set conn_max_recv_data_segment_length to our
advertised value in login_negotiate().

PR: 259355
Reviewed by: mav
MFC after: 1 week
Fixes: a15fbc904a4d ("Alike to r312190 decouple iSCSI...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32605

(cherry picked from commit fc79cf4fea7221fa62d480648f05e30f7df73f92)

2 years agovm_page: Break reservations to handle noobj allocations
Mark Johnston [Thu, 21 Oct 2021 15:46:25 +0000 (11:46 -0400)]
vm_page: Break reservations to handle noobj allocations

vm_reserv_reclaim_*() will release pages to the default freepool, not
the direct freepool from which noobj allocations are drawn.  But if both
pools are empty, the noobj allocator variants must break reservations to
make progress.

Reported by: cy
Reviewed by: kib (previous version)
Fixes: b498f71bc56a ("vm_page: Add a new page allocator interface for unnamed pages")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d7acbe481d17ccb81c2b879b9731c83b018f3094)

2 years agoUse the vm_radix_init() helper when initializing pmaps
Mark Johnston [Wed, 20 Oct 2021 00:29:05 +0000 (20:29 -0400)]
Use the vm_radix_init() helper when initializing pmaps

No functional change intended.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ff93447d8ed61081adfe00a23a1e4c7bee479e53)

2 years agoamd64: Add comments to pmap_pinit_type()
Mark Johnston [Wed, 20 Oct 2021 00:29:18 +0000 (20:29 -0400)]
amd64: Add comments to pmap_pinit_type()

... explaining why we don't pass the pmap pointer to
pmap_alloc_pt_page().

Reported by: alc
Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 34fac29e98313fb0bfba0503e2e19e352b452516)

2 years agoConvert consumers to vm_page_alloc_noobj_contig()
Mark Johnston [Wed, 20 Oct 2021 00:25:04 +0000 (20:25 -0400)]
Convert consumers to vm_page_alloc_noobj_contig()

Remove now-unneeded page zeroing.  No functional change intended.

Reviewed by: alc, hselasky, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 84c3922243a7b7fd510dcfb100aec59c878c57d0)

2 years agoIntroduce vm_page_alloc_noobj_contig()
Mark Johnston [Wed, 20 Oct 2021 00:24:21 +0000 (20:24 -0400)]
Introduce vm_page_alloc_noobj_contig()

This is the same as vm_page_alloc_noobj(), but allocates physically
contiguous runs of memory.  For now it is implemented in terms of
vm_page_alloc_contig(), with the difference that
vm_page_alloc_noobj_contig() implements VM_ALLOC_ZERO by zeroing the
page.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 92db9f3bb7623883231214e74ec38788c3dffc6a)

2 years agoConvert vm_page_alloc() callers to use vm_page_alloc_noobj().
Mark Johnston [Wed, 20 Oct 2021 00:23:39 +0000 (20:23 -0400)]
Convert vm_page_alloc() callers to use vm_page_alloc_noobj().

Remove page zeroing code from consumers and stop specifying
VM_ALLOC_NOOBJ.  In a few places, also convert an allocation loop to
simply use VM_ALLOC_WAITOK.

Similarly, convert vm_page_alloc_domain() callers.

Note that callers are now responsible for assigning the pindex.

Reviewed by: alc, hselasky, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit a4667e09e6520dc2c4b0b988051f060fed695a91)

2 years agovm_page: Add a new page allocator interface for unnamed pages
Mark Johnston [Wed, 20 Oct 2021 00:22:12 +0000 (20:22 -0400)]
vm_page: Add a new page allocator interface for unnamed pages

The diff adds vm_page_alloc_noobj() and vm_page_alloc_noobj_domain().
These mostly correspond to vm_page_alloc() and vm_page_alloc_domain()
when no VM object is specified, with the exception that they handle
VM_ALLOC_ZERO by zeroing the page, rather than by preserving PG_ZERO.

This simplifies callers and will permit simplification of the
vm_page_alloc_domain() definition.

Since the new allocator variant is similar to vm_page_alloc_freelist(),
implement both of them using a common backend allocator function.  No
functional change intended.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b498f71bc56af0069d9a4685b8385ee613a00727)

2 years agoAdd a VM flag to prevent reclaim on a failed contig allocation
Ryan Stone [Fri, 29 Jan 2021 21:13:57 +0000 (16:13 -0500)]
Add a VM flag to prevent reclaim on a failed contig allocation

If a M_WAITOK contig alloc fails, the VM subsystem will try to
reclaim contiguous memory twice before actually failing the
request.  On a system with 64GB of RAM I've observed this take
400-500ms before it finally gives up, and I believe that this
will only be worse on systems with even more memory.

In certain contexts this delay is extremely harmful, so add a flag
that will skip reclaim for allocation requests to allow those
paths to opt-out of doing an expensive reclaim.

Sponsored by: Dell Inc
Differential Revision: https://reviews.freebsd.org/D28422
Reviewed by: markj, kib

(cherry picked from commit 660344ca44c63bfe4a16c3e57d0f6dbcbb5e083e)

2 years agovlapic: Schedule callouts on the local CPU
Mark Johnston [Wed, 20 Oct 2021 00:50:06 +0000 (20:50 -0400)]
vlapic: Schedule callouts on the local CPU

The virtual LAPIC driver uses callouts to implement the LAPIC timer.
Callouts are armed using callout_reset_sbt(), which currently puts
everything on CPU 0.  On systems running many bhyve VMs this results in
a large amount of contention for CPU 0's callout lock.

Modify vlapic to schedule callouts on the local CPU instead.  This
allows timer interrupts to be scheduled more evenly among CPUs where
bhyve is running.

Reviewed by: grehan, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4c812fe61b7ce2f297a381950ff7bd87fd51f698)

2 years agormslock: Update td_locks during lock and unlock operations
Mark Johnston [Wed, 27 Oct 2021 15:18:13 +0000 (11:18 -0400)]
rmslock: Update td_locks during lock and unlock operations

Reviewed by: mjg
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 71f31d784e1816a155cafbccf4b28291200097aa)

2 years agoamd64: Define KVA regions for KMSAN shadow maps
Mark Johnston [Tue, 10 Aug 2021 20:25:39 +0000 (16:25 -0400)]
amd64: Define KVA regions for KMSAN shadow maps

KMSAN requires two shadow maps, each one-to-one with the kernel map.
Allocate regions of the kernels PML4 page for them.  Add functions to
create mappings in the shadow map regions, these will be used by the
KMSAN runtime.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f95f780ea4e163ce9a0295a699f41f0a7e1591d4)

2 years agoconf: Add a KMSAN kernel option
Mark Johnston [Tue, 10 Aug 2021 19:51:03 +0000 (15:51 -0400)]
conf: Add a KMSAN kernel option

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 30d00832d7733e60f5e030d335c129bfa77dd77a)

2 years agokasan: Use vm_offset_t for the first parameter to kasan_shadow_map()
Mark Johnston [Thu, 29 Apr 2021 15:39:02 +0000 (11:39 -0400)]
kasan: Use vm_offset_t for the first parameter to kasan_shadow_map()

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 20e3b9d8bd778445bb80b2be28d2fdedf7bae37e)

2 years agoamd64 pmap: Pre-set PG_M on 2MB KASAN shadow map entries
Mark Johnston [Tue, 10 Aug 2021 20:23:42 +0000 (16:23 -0400)]
amd64 pmap: Pre-set PG_M on 2MB KASAN shadow map entries

Also remove a redundant assertion in pmap_kasan_enter().

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4fd450a87df015fe85cadfac0e22c73e3c878d24)

2 years agousb(4): Fix for use after free in combination with EVDEV_SUPPORT.
Hans Petter Selasky [Sun, 24 Oct 2021 11:38:04 +0000 (13:38 +0200)]
usb(4): Fix for use after free in combination with EVDEV_SUPPORT.

When EVDEV_SUPPORT was introduced, the USB transfers may be running
after the main FIFO is closed. In connection to this a race may appear
which can lead to use-after-free scenarios. Fix this for all FIFO
consumers by initializing and resetting the FIFO queues under the
lock used by the client. Then the client driver will see an empty
queue in all cases a race may appear.

Found by: pho@
Sponsored by: NVIDIA Networking

(cherry picked from commit aad0c65d6b37364d8ba92ecb8c85e004398a5194)

2 years agosinpi[fl] etc: Fix the ld128 implementations
Steve Kargl [Sun, 31 Oct 2021 22:26:20 +0000 (00:26 +0200)]
sinpi[fl] etc: Fix the ld128 implementations

PR: 218514

(cherry picked from commit 4f889260c33c163ab28e0e082b4d7e7562d9c647)

2 years agosinpi,cospi,tanpi: float.h needed for week reference
Steve Kargl [Thu, 28 Oct 2021 22:53:13 +0000 (01:53 +0300)]
sinpi,cospi,tanpi: float.h needed for week reference

PR: 218514

(cherry picked from commit 3bfc837685b8128067b946b31dfe2120dae0d003)

2 years agolib/msun: Move the files to appropriate locations in the Makefile
Steve Kargl [Tue, 26 Oct 2021 20:53:51 +0000 (23:53 +0300)]
lib/msun: Move the files to appropriate locations in the Makefile

(cherry picked from commit ca3d8cb087cd5b40369478b1693f3e4038b5fa23)

2 years agolib/msun/ld128/s_tanpil.c: make it compile.
Konstantin Belousov [Tue, 26 Oct 2021 21:14:35 +0000 (00:14 +0300)]
lib/msun/ld128/s_tanpil.c: make it compile.

(cherry picked from commit 6312d144613f97bf59703c442ee4871be1450c46)

2 years ago[LIBM] implementations of sinpi[fl], cospi[fl], and tanpi[fl]
Steve Kargl [Mon, 25 Oct 2021 13:13:52 +0000 (16:13 +0300)]
[LIBM] implementations of sinpi[fl], cospi[fl], and tanpi[fl]

PR: 218514

(cherry picked from commit dce5f3abed7181cc533ca5ed3de44517775e78dd)

2 years agosleepqueue(9): Remove sbinuptime() from sleepq_timeout().
Alexander Motin [Sun, 3 Oct 2021 00:57:55 +0000 (20:57 -0400)]
sleepqueue(9): Remove sbinuptime() from sleepq_timeout().

Callout c_time is always bigger or equal than the scheduled time.  It
is also smaller than sbinuptime() and can't change while the callback
is running.  So we reliably can use it instead of sbinuptime() here.
In case there was a race and the callout was rescheduled to the later
time, the callback will be called again.

According to profiles it saves ~5% of the timer interrupt time even
with fast TSC timecounter.

MFC after: 1 month

(cherry picked from commit 6df1359e5542f69179c142be1ea099d447e273d1)

2 years agoGeneralize sanitizer interceptors for memory and string routines
Mark Johnston [Wed, 24 Mar 2021 23:43:05 +0000 (19:43 -0400)]
Generalize sanitizer interceptors for memory and string routines

Similar to commit 3ead60236f ("Generalize bus_space(9) and atomic(9)
sanitizer interceptors"), use a more generic scheme for interposing
sanitizer implementations of routines like memcpy().

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ec8f1ea8d536e91ad37e03e45a688c4e255b9cb0)

2 years agoGeneralize bus_space(9) and atomic(9) sanitizer interceptors
Mark Johnston [Tue, 23 Mar 2021 01:44:55 +0000 (21:44 -0400)]
Generalize bus_space(9) and atomic(9) sanitizer interceptors

Make it easy to define interceptors for new sanitizer runtimes, rather
than assuming KCSAN.  Lay a bit of groundwork for KASAN and KMSAN.

When a sanitizer is compiled in, atomic(9) and bus_space(9) definitions
in atomic_san.h are used by default instead of the inline
implementations in the platform's atomic.h.  These definitions are
implemented in the sanitizer runtime, which includes
machine/{atomic,bus}.h with SAN_RUNTIME defined to pull in the actual
implementations.

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 3ead60236fd25ce64fece7ae4a453318ca18c119)

2 years agoKASAN: Disable checking before triggering a panic
Mark Johnston [Fri, 23 Jul 2021 14:41:00 +0000 (10:41 -0400)]
KASAN: Disable checking before triggering a panic

KASAN hooks will not generate reports if panicstr != NULL, but then
there is a window after the initial panic() call where another report
may be raised.  This can happen if a false positive occurs; to simplify
debugging of such problems, avoid recursing.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ea3fbe0707f9a02a29875966668b6f15284f335a)

2 years agoredzone: Raise a compile error if KASAN is configured
Mark Johnston [Fri, 23 Jul 2021 14:30:29 +0000 (10:30 -0400)]
redzone: Raise a compile error if KASAN is configured

redzone(9) does some munging of the allocation to insert redzones before
and after a valid memory buffer, but KASAN does not know about this and
will raise false positives if both are configured.  Until this is fixed,
do not allow both to be configured.  Note that KASAN provides similar
checking on its own but currently does not force the creation of
redzones for all UMA allocations; this should be addressed as well.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4e8e26a00471f1a5e7a2af322265c45b1529c5b8)

2 years agoKASAN: Implement __asan_unregister_globals()
Mark Johnston [Sat, 10 Jul 2021 00:38:28 +0000 (20:38 -0400)]
KASAN: Implement __asan_unregister_globals()

It will be called during KLD unload to unpoison the redzones following
global variables.  Otherwise, virtual address ranges previously used for
a KLD may be left tainted, triggering false positives when they are
recycled.

Reported by: pho
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 588c7a06dffbc74b281dacbdd854437b0815e501)

2 years agouma: Fix a few problems with KASAN integration
Mark Johnston [Sat, 10 Jul 2021 00:38:21 +0000 (20:38 -0400)]
uma: Fix a few problems with KASAN integration

- Ensure that all items returned by UMA are aligned to
  KASAN_SHADOW_SCALE (8).  This was true in practice since smaller
  alignments are not used by any consumers, but we should enforce it
  anyway.
- Use a non-zero code for marking redzones that appear naturally in
  items that are not a multiple of the scale factor in size.  Currently
  we do not modify keg layouts to force the creation of redzones.
- Use a non-zero code for marking freed per-CPU items, otherwise
  accesses of freed per-CPU items are not detected by the runtime.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b0dfc48684780024a3d736c5a5449284dad97f4e)

2 years agox86: Mark the trapframe as initialized in ipi_bitmap_handler()
Mark Johnston [Sat, 10 Jul 2021 00:38:18 +0000 (20:38 -0400)]
x86: Mark the trapframe as initialized in ipi_bitmap_handler()

Otherwise KASAN may generate false positives if the trapframe was
written into a poisoned region of the stack.

Reported by: pho
Reported by: syzbot+ee60455cd58e6eed20c9@syzkaller.appspotmail.com
Reported by: syzbot+be5f9df26426ace3a00c@syzkaller.appspotmail.com
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 36226163fa48ee2c5f73bd2e870ce2e5a057f42e)

2 years agohwpmc: Disable KASAN in pmc_save_kernel_callchain()
Mark Johnston [Sat, 10 Jul 2021 00:38:11 +0000 (20:38 -0400)]
hwpmc: Disable KASAN in pmc_save_kernel_callchain()

As in commit 831850d8b087, this routine can trigger false positives, so
exclude it from instrumentation.

Reported by: pho
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5d243d41b1206044cb5eddd5d48c1c711b731478)

2 years agoamd64: Mark the trapframe as initialized in trap()
Mark Johnston [Sat, 10 Jul 2021 00:38:03 +0000 (20:38 -0400)]
amd64: Mark the trapframe as initialized in trap()

Otherwise KASAN may generate false positives if the trapframe was
written into a poisoned region of the stack.

Reported by: pho
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f08f0ae5247ab31de58bda0817e74ccc1a3a5e95)

2 years agostack(9): Disable KASAN in stack_capture()
Mark Johnston [Fri, 7 May 2021 18:20:53 +0000 (14:20 -0400)]
stack(9): Disable KASAN in stack_capture()

When unwinding the stack, we may encounter a stack frame in a poisoned
region of the stack, triggering a false positive.

Reviewed by: andrew, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 831850d8b0870c75c21d2e01527af1e55fe2fec8)

2 years agocdefs: Make __nosanitizeaddress work for KASAN as well
Mark Johnston [Fri, 7 May 2021 18:26:28 +0000 (14:26 -0400)]
cdefs: Make __nosanitizeaddress work for KASAN as well

Add __nosanitizememory while I'm here.

Reviewed by: andrew, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit cfad8bd24f038e4779e937f48b05511f2dd4a5a8)

2 years agolinker_set: Disable ASAN only in userspace
Mark Johnston [Fri, 7 May 2021 18:24:37 +0000 (14:24 -0400)]
linker_set: Disable ASAN only in userspace

KASAN does not insert redzones around global variables and so is not
susceptible to the problem that led to us disabling ASAN for linker set
elements in the first place (see commit fe3d8086fb6f).

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

(cherry picked from commit 2d499d505262c9c965fc5f4fd36afdd2bb7cad3d)

2 years agorealloc: Fix KASAN(9) shadow map updates
Mark Johnston [Wed, 5 May 2021 21:05:46 +0000 (17:05 -0400)]
realloc: Fix KASAN(9) shadow map updates

When copying from the old buffer to the new buffer, we don't know the
requested size of the old allocation, but only the size of the
allocation provided by UMA.  This value is "alloc".  Because the copy
may access bytes in the old allocation's red zone, we must mark the full
allocation valid in the shadow map.  Do so using the correct size.

Reported by: kp
Tested by: kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9a7c2de36460cdb916734a6969aac666707a639b)

2 years agomalloc: Add state transitions for KASAN
Mark Johnston [Tue, 13 Apr 2021 21:40:27 +0000 (17:40 -0400)]
malloc: Add state transitions for KASAN

- Reuse some REDZONE bits to keep track of the requested and allocated
  sizes, and use that to provide red zones.
- As in UMA, disable memory trashing to avoid unnecessary CPU overhead.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 06a53ecf24005b3a74b85ecc4b504a401ac26cd0)

2 years agoexecve: Mark exec argument buffers
Mark Johnston [Tue, 13 Apr 2021 21:40:19 +0000 (17:40 -0400)]
execve: Mark exec argument buffers

We cache mapped execve argument buffers to avoid the overhead of TLB
shootdowns.  Mark them invalid when they are freed to the cache.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f1c3adefd95d35115bd4597293e0b904ae401245)

2 years agovfs: Add KASAN state transitions for vnodes
Mark Johnston [Tue, 13 Apr 2021 21:40:11 +0000 (17:40 -0400)]
vfs: Add KASAN state transitions for vnodes

vnodes are a bit special in that they may exist on per-CPU lists even
while free.  Add a KASAN-only destructor that poisons regions of each
vnode that are not expected to be accessed after a free.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b261bb4057f4abbc1366e4af8e9e4081d039be4a)

2 years agokmem: Add KASAN state transitions
Mark Johnston [Tue, 13 Apr 2021 21:40:01 +0000 (17:40 -0400)]
kmem: Add KASAN state transitions

Memory allocated with kmem_* is unmapped upon free, so KASAN doesn't
provide a lot of benefit, but since allocations are always a multiple of
the page size we can create a redzone when the allocation request size
is not a multiple of the page size.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2b914b85ddf4c25d112b2639bbbb7618641872b4)

2 years agokstack: Add KASAN state transitions
Mark Johnston [Tue, 13 Apr 2021 21:39:55 +0000 (17:39 -0400)]
kstack: Add KASAN state transitions

We allocate kernel stacks using a UMA cache zone.  Cache zones have
KASAN disabled by default, but in this case it makes sense to enable it.

Reviewed by: andrew

(cherry picked from commit 244f3ec642ed99a371c97b946b93b877d8be1756)

2 years agouma: Add KASAN state transitions
Mark Johnston [Tue, 13 Apr 2021 21:39:50 +0000 (17:39 -0400)]
uma: Add KASAN state transitions

- Add a UMA_ZONE_NOKASAN flag to indicate that items from a particular
  zone should not be sanitized.  This is applied implicitly for NOFREE
  and cache zones.
- Add KASAN call backs which get invoked:
  1) when a slab is imported into a keg
  2) when an item is allocated from a zone
  3) when an item is freed to a zone
  4) when a slab is freed back to the VM

  In state transitions 1 and 3, memory is poisoned so that accesses will
  trigger a panic.  In state transitions 2 and 4, memory is marked
  valid.
- Disable trashing if KASAN is enabled.  It just adds extra CPU overhead
  to catch problems that are detected by KASAN.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 09c8cb717d214d03e51b3e4f8e9997b9f4e1624d)