Commit Graph

269551 Commits

Author SHA1 Message Date
Warner Losh
80f21bb039 vt: fix git mismerge
I made a mistaking in merging the final commits for the devctl changes. This
adds the 'hushed' variable and has the correct dates for the manuals.

Pointy hat to: imp
2021-11-03 16:20:41 -06:00
Warner Losh
cc48eb70d1 vt: fix typo
Notifcation -> Notification
2021-11-03 16:12:55 -06:00
Warner Losh
ba48d52ca6 vt: Fix frequency calcuation for bell
386BSD provided a MD function sysbeep. This took two arguments (pitch
and period). Pitch was jammed into the PIT's divisor directly (which
means the argument was expected to sound a tone at '1193182 / pitch'
Hz). FreeBSD inherited this interface.

In commit e465985885 (svn 177642, Mar 26 2008), phk changed this
function to take a tone to sound in hz. He converted all in-tree
instances of 1193182 / hz to just hz (and kept the few misguided folks
that passed hz directly unchanged -- this was part of what motivated the
change). He converted the places where we pre-computed the 8254 divisor
from being pitch to 1193182 / pitch (since that converts the divisor to
the frequency and the interfaces that were exposed to userland exposed
it in these units in places, continuing the tradition inherited from SCO
System V/386 Unix in spots).

In 2009, Ed Shouten was contracted by the FreeBSD Foundation to write /
finish newcons. This work was done in perforce and was imported into
subversion in user/ed/newcons in revision 199072
(https://svnweb.freebsd.org/base?view=revision&revision=199072) which
was later imported into FreeBSD by ray@ (Aleksandr Rybalko).

From that earliest import into svn import to this date, we ring the bell
with:
      sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION);
where VT_BELLPITCH was defined to be 800. This results in a bell
frequency of 1491Hz, more or less today. This is similar to the
frequency that syscons and pcvt used (1493Hz and 1500Hz respectively).
This in turn was inherited from 386BSD, it seems, which used the hard
coded value 0x31b which is 795 -> 1500Hz.

This '800' was intended to be the bell tone (eg 800Hz) and this
interface was one that wasn't converted. The most common terminal prior
to the rise of PCs was the VT100, which had an approximately 800Hz
bell. Ed Shouten has confirmed that the original intent was 800Hz and
changing this was overlooked after the change to -current was made.
This restors that original intent and makes the bell less obnoxious in
the process.

Reviewed by:		des, adrian
Differential Revision:	https://reviews.freebsd.org/D32594
Sponsored by:		Netflix
2021-11-03 16:03:51 -06:00
Warner Losh
4ac3d08a96 vt: Add devctl message for bells
Generate VT events when the bell beeps. When coupled with disabling the
bell,this allows custom bells to be rung when we'd otherwise beep.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D32656
2021-11-03 16:03:51 -06:00
Warner Losh
2533eca1c2 vt(4): Connect to teken's TP_SETBELLPD
Add the glue needed to listen to TP_SETBELLPD which teken uses to
inform its client drivers about the results of parsing
\e[=<pitch>;<duration>B. It converts these to a Hz value for the
tone/pitch of the bell and a duration in ms. There's some loss of
precision because <pitch> in the escape seuquence is defined to be
(1193182 / pitch) Hz and <duration> is in 10ms units. Also note that
kbdcontrol also parses 'off' but then doesn't send the proper escape
sequence, leading me to wonder if that's another bug since teken
appears to parse that sequence properly and I've added code here to
treat that as the same as quiet or disabled.

In general, Hz from 100 to 2000 is good. Outside that range is possible,
but even at 100Hz the square wave is starting to sound bad and above
2000Hz the speaker may not respond.

Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D32620
2021-11-03 16:03:51 -06:00
Warner Losh
072d5b98c4 sysbeep: Adjust interface to take a duration as a sbt
Change the 'period' argument to 'duration' and change its type to
sbintime_t so we can more easily express different durations.

Reviewed by:	tsoome, glebius
Differential Revision:	https://reviews.freebsd.org/D32619
2021-11-03 16:03:51 -06:00
Rick Macklem
6b67753488 nfscl: Fix forced dismount from looping on commit
When a forced dismount is in progress, it is possible to
end up looping, retrying commits that fail.
This patch fixes the problem by pretending
that commits succeeded when a forced dismount is in prgress.

MFC after:	2 weeks
2021-11-03 14:25:44 -07:00
Kyle Evans
589aed00e3 sched: separate out schedinit_ap()
schedinit_ap() sets up an AP for a later call to sched_throw(NULL).

Currently, ULE sets up some pcpu bits and fixes the idlethread lock with
a call to sched_throw(NULL); this results in a window where curthread is
setup in platforms' init_secondary(), but it has the wrong td_lock.
Typical platform AP startup procedure looks something like:

- Setup curthread
- ... other stuff, including cpu_initclocks_ap()
- Signal smp_started
- sched_throw(NULL) to enter the scheduler

cpu_initclocks_ap() may have callouts to process (e.g., nvme) and
attempt to sched_add() for this AP, but this attempt fails because
of the noted violated assumption leading to locking heartburn in
sched_setpreempt().

Interrupts are still disabled until cpu_throw() so we're not really at
risk of being preempted -- just let the scheduler in on it a little
earlier as part of setting up curthread.

Reviewed by:	alfredo, kib, markj
Triage help from:	andrew, markj
Smoke-tested by:	alfredo (ppc), kevans (arm64, x86), mhorne (arm)
Differential Revision:	https://reviews.freebsd.org/D32797
2021-11-03 15:54:59 -05:00
Rick Macklem
ae49051c03 nfscl: Fix forced dismount when "nconnect" is specified
When a forced dismount is done and the "nconnect" mount
option was used, the additional connections must be closed.
This patch does that.

Found during a recent IETF NFSv4 working group testing event.

MFC after:	2 weeks
2021-11-03 13:26:38 -07:00
Gleb Smirnoff
3ea9a7cf7b blackhole(4): disable for locally originated TCP/UDP packets
In most cases blackholing for locally originated packets is undesired,
leads to different kind of lags and delays. Provide sysctls to enforce
it, e.g. for debugging purposes.

Reviewed by:		rrs
Differential revision:	https://reviews.freebsd.org/D32718
2021-11-03 13:02:44 -07:00
Warner Losh
c47a4a2375 arm: Remove unused items
Remote detritis copied, apparently, from sparc. utrap has never been
used on arm, so it's safe to just remove it.

Sponsored by:		Netflix
2021-11-03 13:54:36 -06:00
Mateusz Guzik
10ea195fa2 ipsec: add a lock encompassing SPI allocation
SPIs get allocated and inserted in separate steps. Prior to the change
there was nothing preventing 2 differnet threads from ending up with the
same one.

PR:		258849
Reported by:	Herbie.Robinson@stratus.com
Reviewed by:	ae
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32826
2021-11-03 19:51:40 +00:00
Mateusz Guzik
626bd0970a ipsec: fix edge case detection in key_do_getnewspi
The 'count' variable would end up being -1 post loop, while the
following condition would check for 0 instead.

PR:		258849
Reported by:	Herbie.Robinson@stratus.com
Reviewed by:	ae
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32826
2021-11-03 19:51:40 +00:00
Gordon Bergling
c28e39c3d6 Fix a common typo in syctl descriptions
- s/maxiumum/maximum/

MFC after:	3 days
2021-11-03 20:49:24 +01:00
Rick Macklem
4412225859 nfscl: Fix use after free for forced dismount
When a forced dismount is done and delegations are being
issued by the server (disabled by default for FreeBSD
servers), the delegation structure is free'd before the
loop calling vflush().  This could result in a use after
free of the delegation structure.

This patch changes the code so that the delegation
structures are not free'd until after the vflush()
loop for forced dismounts.

Found during a recent IETF NFSv4 working group testing event.

MFC after:	2 weeks
2021-11-03 12:15:40 -07:00
Mark Johnston
6afabf0092 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
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32803
2021-11-03 15:09:17 -04:00
Gleb Smirnoff
3358df2973 udp_input: remove a BSD stack relict
I should had removed it 9 years ago in 8ad458a471.  That commit
left save_ip as a write-only variable.

With save_ip removed we got one case when IP header can be modified:
the calculation of IP checksum with zeroed out header.  This place
already has had a header saver char b[9].  However, the b[9] saver
didn't cover the ip_sum field, which we explicitly overwrite aliased
as (struct ipovly *)->ih_len.  This was fine in cb34210012, since
checksum doesn't need to be restored if packet is consumed.  Now we
need to extend up to ip_sum field.

In collaboration with:	ae
Differential revision:	https://reviews.freebsd.org/D32719
2021-11-03 10:39:34 -07:00
Gleb Smirnoff
b788a226f6 Document net.inet.tcp.nolocaltimewait enabled. 2021-11-03 10:31:44 -07:00
Mark Johnston
2a519c3b14 kasan: Disable validation of function parameters passed by value
It appears that the emitted code in the caller does not update shadow
state for values passed on the stack to the callee, which it seemingly
ought to do after pushing values on the stack and prior to the call
itself.  This leaves open a window where an interrupt handler can cause
regions of the stack containing these values to be poisoned, resulting
in rare false positive reports.  This happens particularly in the amd64
TLB invalidation code, where we liberally pass cpuset_t's around by
value.

LLVM has a flag to disable validation of accesses of function parameters
passed by value.  Such validation is itself a relatively new feature.
Turn it off for now.

Reported by:	pho, syzkaller
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2021-11-03 12:36:02 -04:00
Mark Johnston
175d3380a3 amd64: Deduplicate routines for expanding KASAN/KMSAN shadow maps
When working on the ports these functions were slightly different, but
now there's no reason for them to be separate.

No functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-11-03 12:36:02 -04:00
Gordon Bergling
7b56cb0462 ocs_fs: Fix two typos in source code comments
- s/maxium/maximum/
- s/maxiumum/maximum/

MFC after:	3 days
2021-11-03 17:17:51 +01:00
Gordon Bergling
40a57b00f9 ng_pptpgre(4): Fix a typo in a source code comment
- s/mimimum/minimum/

MFC after:	3 days
2021-11-03 17:15:59 +01:00
Gordon Bergling
9d2e51884e gjournal(8): Fix a typo in a source code comment
- s/writting/writing/

MFC after:	3 days
2021-11-03 17:14:00 +01:00
Konstantin Belousov
be10c0a910 fexecve(2): allow O_PATH file descriptors opened without O_EXEC
This improves compatibility with Linux.

Noted by:	Drew DeVault <sir@cmpwn.com>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32821
2021-11-03 18:00:42 +02:00
Konstantin Belousov
02de91d740 proc_get_binpath(): return empty string instead of NULL
for strange case where queried process does not have text.

Reported by:	Michael Butler <imb@protected-networks.net>
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2021-11-03 17:30:10 +02:00
Mark Johnston
c75c1d2df9 vmci: Avoid relying on macro expansion to provide correct syntax
No functional change intended.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2021-11-03 11:22:40 -04:00
Gordon Bergling
bb91496a85 netinet: Fix a common typo in source code comments
- s/writting/writing/

MFC after:	3 days
2021-11-03 16:21:49 +01:00
Gordon Bergling
a506133ac9 mana: Fix a typo in a source code comment
- s/maxium/maximum/

MFC after:	1 week
2021-11-03 16:20:11 +01:00
Gordon Bergling
8da5034954 ixgbe(4): Fix a few typos in source code comments
- s/Manageblility/Managebility/
- s/alows/allows/

MFC after:	3 days
Obtained from:	NetBSD
2021-11-03 16:16:20 +01:00
Warner Losh
dbfe5dd3f9 cam_periph: style change
wrap a long line at 80 columns

Sponsored by:		Netflix
Reviewed by:		chs
Differential Revision:	https://reviews.freebsd.org/D32679
2021-11-03 08:03:07 -06:00
Alfredo Dal'Ava Junior
b042d10cdc ofwfb: fix vga/hdmi console with ASMEDIA during boot on powerpc64(le)
On recent OpenBMC firmware, the onboard ASMEDIA video card framebuffer
address was removed from device tree for security purposes (value is set
to zero to avoid leaking the address).

This patch works around the problem by taking framebuffer base address
from the "ranges" property of a parent node.

Reviewed by:	luporl, jhibbits (on IRC)
MFC after:	2 weeks
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D30626
2021-11-03 13:42:28 -03:00
Konstantin Belousov
e4ce23b238 fexecve(2): restore the attempts to calculate the executable path
vn_fullpath() call was not converted to pass newtextvp, instead it used
imgp->vp which is still NULL there.  As result vn_fullpath() always
returned EINVAL and execpath was recorded from the value of arg0.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2021-11-03 15:10:22 +02:00
Mateusz Piotrowski
c537bf9d59 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
2021-11-03 14:09:36 +01:00
Mateusz Piotrowski
a12b16f48f date: Clean up synopses
MFC after:	3 days
2021-11-03 14:09:36 +01:00
Mateusz Piotrowski
00133d5c5e 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
2021-11-03 14:09:18 +01:00
Zhenlei Huang
7acd322ebe devfs.rules: Correctly unhide pf in vnet jails
Revision 9e9be081d8 introduced a new devfs rule devfsrules_jail_vnet. It
includes rule devfsrules_jail which include other rules. Unfortunately
devfs could not recursively parse the action include and thus
devfsrules_jail_vnet will expose all nodes.

PR:		255660
Reviewed by:	kp
Obtained from:	Gijs Peskens <gijs@peskens.net>
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D32814
2021-11-03 12:50:13 +01:00
Andrey V. Elsukov
4a9e95286c ip_divert: calculate delayed checksum for IPv6 adress family
Before passing an IPv6 packet to application apply delayed checksum
calculation. Mbuf flags will be lost when divert listener will return a
packet back, so we will not be able to do delayed checksum calculation
later. Also an application will get a packet with correct checksum.

Reviewed by:	donner
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D32807
2021-11-03 15:20:51 +03:00
Kristof Provost
11703705c2 pf tests: route_to:icmp_nat_head requires scapy
Document the requirement so the test is skipped if scapy is not
installed.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-11-03 10:35:09 +01:00
Edward Tomasz Napierala
e03813c3e1 development(7): Use a more common architecture for examples 2021-11-03 08:59:26 +00:00
Edward Tomasz Napierala
c91d0e59be linux: Make linux_ptrace.c portable
Make sys/amd64/linux/linux_ptrace.c machine-independent,
in preparation for moving it into sys/compat/linux/.
No functional changes.

Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32756
2021-11-03 08:54:35 +00:00
Edward Tomasz Napierala
4dfd612286 linux: mv sys/i386/linux/linux_ptrace{,_machdep}.c
In preparation for machine-independent sys/compat/linux/linux_ptrace.c,
rename the i386-specific Linux ptrace(2) implementation.  No functional
changes.

Sponsored By:	EPSRC
Differential Revision: https://reviews.freebsd.org/D32757
2021-11-03 08:50:17 +00:00
Edward Tomasz Napierala
91be6286e2 linprocfs: Fix formatting of Uid and Gid lines
The separator here should be tabs, not spaces.  This fixes a warning
from chromium-browser on Bionic:

[1022/162248.137612:ERROR:process_info_linux.cc(107)] format error: unrecognized Uid format

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32612
2021-11-03 08:40:55 +00:00
Kyle Evans
7771f2a0c9 kern: physmem: improve region coalescing logic
The existing logic didn't take into account newly inserted mappings
wholly contained by an existing region (or vice versa), nor did it
account for weird overlap scenarios.  The latter is probably unlikely
to happen, but the former may happen in UEFI: BootServicesData allocated
within a large chunk of ConventionalMemory.  This situation blows up vm
initialization.

While we're here, remove the "exact match" logic as it's likely wrong;
if an exact match exists with conflicting flags, for instance, then we
should probably be doing something else.  The new logic takes into
account exact matches as part of the overlapping efforts.

Reviewed by:	kib, mhorne (both earlier version)
Differential Revision:	https://reviews.freebsd.org/D32701
2021-11-03 02:32:46 -05:00
Rick Macklem
331883a2f2 nfscl: Check for a forced dismount in nfscl_getref()
The nfscl_getref() function is called within nfscl_doiods() when
the NFSv4.1/4.2 pNFS client is doing I/O on a DS.  As such,
nfscl_getref() needs to check for a forced dismount.
This patch adds that check.

Found during a recent IETF NFSv4 working group testing event.

MFC after:	2 weeks
2021-11-02 17:28:13 -07:00
Warner Losh
edfbbfd541 gpart: Move MBR efimedia reporting to a separate routine
Move the efimedia reporting to g_part_mbr_efimedia and use that from
g_part_mbr_dumpconf to report it.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D32781
2021-11-02 17:09:17 -06:00
Warner Losh
e3ab141fda gpart: Move GPT efimedia reporting to a separate routine
Move the efimedia reporting to g_part_gpt_efimedia and use that from
g_part_gpt_dumpconf to report it.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D32780
2021-11-02 17:09:17 -06:00
Ruslan Bukin
4bb6991531 arm/pmu: add ACPI attachment.
This makes hwpmc(4) sampling work on ACPI-based AArch64 systems.
Tested on ARM Neoverse N1.

Submitted by: Greg V <greg@unrelenting.technology>
Reviewed by: jrtc27, mhorne
Differential Revision: https://reviews.freebsd.org/D24423
2021-11-02 19:35:29 +00:00
John Baldwin
4e057806cf crypto: Cleanup mtx_init() calls.
Don't pass the same name to multiple mutexes while using unique types
for WITNESS.  Just use the unique types as the mutex names.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D32740
2021-11-02 12:18:05 -07:00
John Baldwin
7178578192 crypto: Use a single "crypto" kproc for all of the OCF kthreads.
Reported by:	julian
Reviewed by:	markj
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D32739
2021-11-02 12:18:05 -07:00
Ed Maste
3513df4bcc fstyp: fix build WITHOUT_ICONV
Reported by:	Michael Dexter, Build Option Survey
Sponsored by:	The FreeBSD Foundation
2021-11-02 14:54:45 -04:00