Commit Graph

277880 Commits

Author SHA1 Message Date
firk
768f6373eb Fix compat10 semaphore interface race
Wrong has-waiters and missing unconditional _count==0 check may cause
infinite waiting with already non-zero count.
1) properly clear _has_waiters flag when waiting failed to start
2) always check _count before start waiting

PR:	265997
Reviewed by:	kib
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36272
2022-08-26 20:34:29 +03:00
Gleb Smirnoff
a358db5603 socket(2): bring documentation up tp date
o Undocument sockets that are no longer supported, or never were.
o Add AF_HYPERV. Note: PF_HYPERV isn't defined, no typo here.
o Point at ip(4) and ip6(4) instead of unwelcoming "not described here".

Reviewed by:		gbe, markj
Differential revision:	https://reviews.freebsd.org/D36284
2022-08-26 08:16:15 -07:00
Gleb Smirnoff
7c04ca1fad sockets: for stat(2) on a socket don't report hiwat as block size
The code appeared in d8392c6c39 with not good explanation.  It is
very unlikely any software in the world needs that.

Differential revision:	https://reviews.freebsd.org/D36283
2022-08-26 08:16:15 -07:00
Baptiste Daroussin
5876499023 tzsetup: remove left overs from libbsddialog conversion
PR:	265954
2022-08-26 11:54:17 +02:00
Kirk McKusick
27c6009e72 Correct diagnostic messages for bad cylinder groups.
Fix for 495b1ba.

Reported by:  Mike Karels
Sponsored by: The FreeBSD Foundation
2022-08-26 00:31:44 -07:00
Kirk McKusick
f0be378a66 Updates to UFS/FFS superblock integrity checks when reading a superblock.
Further updates based on ways Peter Holm found to corrupt UFS
superblocks in ways that could cause kernel hangs or crashes.

No legitimate superblocks should fail as a result of these changes.

Reported by:  Peter Holm
Tested by:    Peter Holm
Sponsored by: The FreeBSD Foundation
2022-08-26 00:09:01 -07:00
Kirk McKusick
495b1baac3 Provide better diagnostic messages for bad cylinder groups.
Like the detailed diagnostics produced when a bad superblock
is read, provide similar detailed diagnostics when bad
cylinder groups are read.

Reported by:  Peter Holm
Tested by:    Peter Holm
Sponsored by: The FreeBSD Foundation
2022-08-25 23:57:56 -07:00
Rick Macklem
8e59ec29e4 nfscl: Fix handling of nd_slotid while handling NFSERR_BADSESSION
When the NFSv4.1/4.2 client is handling a server error
of NFSERR_BADSESSION, it retries RPCs with a new session.
Without this patch, the nd_slotid was not being updated
for the new session.

This would result in a bogus console message like
"Wrong session srvslot=X slot=Y" and then it would
free the incorrect slot, often generating a
"freeing free slot!!" console message as well.

This patch fixes the problem.

Note that FreeBSD NFSv4.1/4.2 servers only
generate a NFSERR_BADSESSION error after a reboot
or after a client does a DestroySession operation.

PR:	260011
MFC after:	1 week
2022-08-25 20:48:04 -07:00
Rick Macklem
2b612c9d3b nfscl: Fix handling of a bad session slot (NFSv4.1/4.2)
When a session has been marked defunct by the server
sending a NFSERR_BADSESSION reply to the NFSv4.1/4.2
client, nfsv4_sequencelookup() returns NFSERR_BADSESSION
without actually assigning a session slot.
Without this patch, newnfs_request() would erroneously
free slot 0.

This could result in the slot being reused prematurely,
but most likely just generated a "freeing free slot!!"
console message.

This patch fixes the code to not do the erroneous
freeing of the slot for this case.

PR:	260011
MFC after:	1 week
2022-08-25 20:33:31 -07:00
Konstantin Belousov
c1a0ab5ec5 amd64: update comment for casueword/casueword32, mentioning return value 1
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-08-26 02:41:48 +03:00
Martin Matuska
08aba0aec7 zfs: merge openzfs/zfs@a582d5299
Notable upstream pull request merges:
  #13717 Fix zpool status in case of unloaded keys
  #13753 Prevent zevent list from consuming all of kernel memory
  #13767 arcstat: fix -p option
  #13785 Updates for snapshots_changed property

Obtained from:	OpenZFS
OpenZFS commit:	a582d52993
2022-08-26 00:58:56 +02:00
Dag-Erling Smørgrav
7ccdad905f renice: add unit tests.
Sponsored by:	Klara, Inc.
2022-08-25 20:06:20 +00:00
Dag-Erling Smørgrav
65ee0a8495 renice: fix argument order.
The target modifiers (-g, -p, -u) may occur in any position except
between -n and its argument; furthermore, we support both the old
absolute form (without -n) and the modern relative form (with -n).

Sponsored by: Klara, Inc.
2022-08-25 19:50:55 +00:00
Mateusz Guzik
e621cb0be2 amd64: dump standard registers when crashing
Sample output:

Fatal trap 12: page fault while in kernel mode
cpuid = 1; apic id = 01
fault virtual address   = 0x2
fault code              = supervisor write data, page not present
instruction pointer     = 0x20:0xffffffff80556853
stack pointer           = 0x28:0xffffffff8141bf50
frame pointer           = 0x28:0xffffffff8141bfa0
code segment            = base 0x0, limit 0xfffff, type 0x1b
		        = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 0 (swapper)
rdi: fffff80002c9c400 rsi: ffffffff80b89183 rdx:                0
rcx:                2  r8:               fe  r9:                1
rax: fffff80002c9c400 rbx:                1 rbp: ffffffff8141bfa0
r10:                0 r11: ffffffff80b97f8c r12:                0
r13:                0 r14:                0 r15:                0
trap number             = 12
panic: page fault
cpuid = 1
time = 1

Reviewed by:	kib
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36348
2022-08-25 17:33:07 +00:00
Mateusz Guzik
49afea1059 proc: read the pid prior to unlocking in report_alive_proc1
In principle another thread could have reaped the process by that time.
2022-08-25 17:26:49 +00:00
Andrew Turner
5d0aebf4fa Fix the arm generic timer on 32 bit
Hide a variable when we don't use it.

Sponsored by:	The FreeBSD Foundation
2022-08-25 13:17:11 +01:00
Andrew Turner
48a7e53db7 Merge the common parts of the SMCCC handlers
To simplify adding new handlers merge the common parts of the functions
used to call into the arm SMCCC firmware.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36297
2022-08-25 12:17:28 +01:00
Andrew Turner
7a060a8895 Add an IDC only arm64 icache sync function
When the IDC flag is set in the cache type register we don't need to
clean the data cache to the point of unification. Previously we
supported this flag being set only when the DIC flags was also set.
Add a new handler for when this is not the case.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation, Ampere (hardware)
Differential Revision: https://reviews.freebsd.org/D36296
2022-08-25 12:17:28 +01:00
Andrew Turner
278111b8a5 Allow the kernel to emulate the physical counter on arm64
When running under a VM we don't have access to the physical counter.
Add support to emulate this instruction by handling the trap in the
kernel. As it is slow only enable when the hw.emulate_phys_counter
tunable is set on boot.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35613
2022-08-25 12:17:23 +01:00
Peter Holm
2aba6e7aaf stress2: Added a regression test 2022-08-25 09:47:58 +02:00
Baptiste Daroussin
83e8c23178 bintrans: replace the quoted printable encoder/decoder
Replace the quoted printable code with one that respects RFC2045
Add tests about this parsers and encoders, using examples from the
wikipedia page.

Reviewed by:	pstef
Differential Revision: https://reviews.freebsd.org/D36314
2022-08-25 09:29:18 +02:00
Doug Moore
b6ce129d24 rb_tree: optimize rb_insert
In searching for where to insert a new node, RB_INSERT discards the
address of the pointer that will have to be modified, so that it must
find it again from the values of 'parent' and 'comp'. Stop discarding
that address, and so avoid having to recompute it.

Reviewed by:	alc
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D36317
2022-08-25 02:26:04 -05:00
Li-Wen Hsu
9ea2716b77
Reenable basic_signal:trap_signal_test on i386
This is fixed in dc4a2d1d0e

PR:		265889
Sponsored by:	The FreeBSD Foundation
MFC with:	dc4a2d1d0e
2022-08-25 12:09:00 +08:00
Li-Wen Hsu
504b998def
ObsoleteFiles: Follow awk test files move
Fixes:	517e52b6c2
Sponsored by:	The FreeBSD Foundation
2022-08-25 11:28:57 +08:00
Aymeric Wibo
05c9a0158f libc: Add strverscmp(3) and versionsort(3)
Add a strverscmp(3) function to libc, a GNU extension I implemented by
reading its glibc manual page. It orders strings following a much more
natural ordering (e.g. "ent1 < ent2 < ent10" as opposed to
"ent1 < ent10 < ent2" with strcmp(3)'s lexicographic ordering).

Also add versionsort(3) for use as scandir(3)'s compar argument.

Update manual page for scandir(3) and add one for strverscmp(3).

Reviewed by:	pstef, gbe, kib
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D35807
2022-08-25 03:29:03 +03:00
Mark Johnston
465988e9fa NOTES: Update the comment for MCLSHIFT
MFC after:	1 week
2022-08-24 19:59:32 -04:00
Mark Johnston
b0b0e4ee00 NOTES: Update the default MSIZE and MCLSHIFT values
After commit 840327e5dd ("mbuf: Don't support PAGE_SIZE < 4K"), these
defaults were causing LINT kernel builds to fail.

Reported by:	Jenkins
MFC after:	1 week
2022-08-24 19:57:33 -04:00
Umer Saleem
a582d52993
Updates for snapshots_changed property
Currently, snapshots_changed property is stored in dd_props_zapobj, due
to which the property is assumed to be local. This causes a difference
in behavior with respect to other readonly properties.

This commit stores the snapshots_changed property in dd_object. Source
is not set to local in this case, which makes it consistent with other
readonly properties.

This commit also updates the date string format to include seconds.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Umer Saleem <usaleem@ixsystems.com>
Closes #13785
2022-08-24 14:20:43 -07:00
Mark Johnston
c4d06691c0 git-arc: Respect GIT_EDITOR and GIT_PAGER 2022-08-24 16:54:41 -04:00
Mark Johnston
43d0c4d2a2 git-arc: Fix whitespace 2022-08-24 16:53:17 -04:00
Konstantin Belousov
a294e67973 Document scandirat(3)
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:01 +03:00
Konstantin Belousov
9fb8e8eede libc: add scandirat(3)
Reviewed by:	emaste, imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
cb6e97f4da libc: split scandir() into scandir_dirp() and proper scandir()
The new helper scandir_dirp() takes DIR *, i.e. a pre-opened directory,
instead of the directory name.

Reviewed by:	emaste, imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
ea448a0a43 Link scandir_b(3) to scandir(3)
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
aa5e19a9b3 scandir.3: Use .Fo instead of .Fn for long args
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
fce3b1c327 fork_exit(): style comment
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:53 +03:00
Konstantin Belousov
ff32a05554 x86: improve machdep.uprintf_signal
Print %eax/%rax.
Use better format strings, like %#x.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:45 +03:00
Konstantin Belousov
01a33b2af5 x86: print trap name in addition of trap number
for the "trap with interrupts disabled" warning.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:37 +03:00
Konstantin Belousov
0f906b30e6 i386: print all GPRs, PSL, and CR3 on double fault
Also compactify the printfs, and remove comment about 'two prints'.
Their arguments are on same page, so one fault implies another.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:30 +03:00
Konstantin Belousov
54e1546e09 i386: simplify flow control in irettraps
It is enough to have only one 'call calltrap' locally.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:22 +03:00
Konstantin Belousov
e8b2980e4a i386 doreti: stop saving/restoring %ecx around calls into C
There is no reason to do this.  Instead just calculate it later.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:05 +03:00
Konstantin Belousov
dc4a2d1d0e i386: do not allow userspace to set tf_trapno on sigreturn(2)
tf_trapno is checked on return from interrupt/exception to determine if
special handling is needed for switching address space.  This is due to
the possibility of NMI/MCHK/DBG to occur at arbitrary place in kernel,
where both address space and stack used could be transient.  Kernel
saves current %cr3 in tf_err for such events, to restore on return.

If user is able to set tf_trapno, it can trigger that special handling,
and since tf_err is also user-controlled by sigreturn(2), the result is
undefined.

PR:	265889
Reported by:	lwhsu
Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:11:57 +03:00
Konstantin Belousov
a03e4799e7 irettraps: i386 does not push %ss/%esp when exception does not switch rings
Which means that we must not copy top 8 bytes from the trampoline stack
for the exception frame to the regular thread kstack.  As consequence,
this stops corruption of the pcb.  The visible effect was often a broken
fork(2) on the CPU where corruption occured.

Account for the detail by substracting 8 from the copy byte count when
moving exception frames from trampoline to the regular stack.

[irettraps handles segmentation/stack/protection faults which could
occur on the doreti path, where we might already switched stack and
address space]

Reported and tested by:	pho
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:11:49 +03:00
Konstantin Belousov
95f773e594 i386 copyout_fast: improve detection of a fault on accessing userspace
Do not blindly account a page fault occuring on the trampoline area,
as the userspace access fault.  Check that it occured exactly in the
instruction that does that.

This avoids unneeded switches of address space on faults not needing the
switch, effectively converting machine resets due to tripple faults,
into regular panics.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:11:40 +03:00
Dag-Erling Smørgrav
0a9b374ecc chown: see also chmod.
Sponsored by:	Klara, Inc.
MFC after:	1 week
2022-08-24 20:21:39 +02:00
Eric van Gyzen
3b0f105ce3 shared_shadow_inval_test: fix copy-pasto in error message
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2022-08-24 13:03:11 -05:00
Brooks Davis
c46697b9cb freebsd32_sendmsg: fix control message ABI
When a freebsd32 caller uses all or most allowed space for control
messages (MCLBYTES == 2K) then the message may no longer fit when
the messages are padded for 64-bit alignment.  Historically we've just
shrugged and said there is no ABI guarantee.  We ran into this on
CheriBSD where a capsicumized 64-bit nm would fail when called with more
than 64 files.

Fix this by not gratutiously capping size of mbuf data we'll allocate
to MCLBYTES and let m_get2 allocate up to MJUMPAGESIZE (4K or larger).
Instead of hard-coding a length check, let m_get2 do it and check for a
NULL return.

Reviewed by:	markj, jhb, emaste
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36322
2022-08-24 18:34:39 +01:00
Brooks Davis
9c3ad5ba93 cxgbe: don't support MJUMPAGESIZE != MCLBYTES
This could only happen on systems with PAGE_SIZE < 4K and FreeBSD
doesn't support such systems.

Reviewed by:	np, imp, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36321
2022-08-24 18:34:25 +01:00
Brooks Davis
840327e5dd mbuf: Don't support PAGE_SIZE < 4K
The Vax supported such things, but FreeBSD does not.  This further
implies that MJUMPAGESIZE > MCLBYTES so assert this and remove code
handling them being equal.

Reviewed by:	kp, imp, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36320
2022-08-24 18:34:07 +01:00
Brooks Davis
e9ad2964f5 pkg: Add limited --debug/-d support
Add an internal debug level global:
 - Level 1 (-d) currently does nothing.

 - Level 2 (-d -d) enables libfetch debugging (quite verbose) so it's
   possible to see what pkg is attempting to download without having
   to sniff traffic.

Reviewed by:	debdrup, bapt
Differential Revision:	https://reviews.freebsd.org/D35756
2022-08-24 18:32:09 +01:00