Commit graph

268181 commits

Author SHA1 Message Date
Cy Schubert
95daf09d07 ipfilter: Move userland bits to sbin
Through fixes and improvements our ipfilter sources have diverged
enough to warrant move from contrib into sbin/ipf. Now that I'm
planning on implementing MSS clamping as in iptables it makes more
sense to move ipfilter to sbin.

This is the second of three commits of the ipfilter move.

Suggested by glebius on two occaions.

Suggested by and discussed with:	glebius
Reviewed by:				glebius, kp (for #network)
Differential Revision:		https://reviews.freebsd.org/D33510

(cherry picked from commit 41edb306f0)
2022-02-07 05:51:14 -08:00
Cy Schubert
5729ebba33 ipfilter: Move kernel bits to netpfil
Through fixes and improvements our ipfilter sources have diverged
enough to warrant move from contrib into sys/netpil. Now that I'm
planning on implementing MSS clamping as in iptables it makes more
sense to move ipfilter to netpfil.

This is the first of three commits the ipfilter move.

Suggested by glebius on two occaions.

Suggested by and discussed with:	glebius
Reviewed by:				glebius, kp (for #network)
Differential Revision:		https://reviews.freebsd.org/D33510

(cherry picked from commit 3b9b51fe46)
2022-02-07 05:51:14 -08:00
Konstantin Belousov
de8aecebf9 ufs, msdosfs: do not record witness order when creating vnode
(cherry picked from commit 303d3ae7e8)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
7a3e533acb ffs_read(): lock buffers after snaplk with LK_NOWITNESS
(cherry picked from commit 0af463e661)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
83d203e3d7 ffs: lock buffers after snaplk with LK_NOWITNESS
(cherry picked from commit 99aa3b731c)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
15def34bd8 Add GB_NOWITNESS flag
(cherry picked from commit c02780b78c)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
06d7509099 ffs_alloc.c: order includes alphabetically
(cherry picked from commit e11b2b69c5)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
7c2d965ca8 ufs: be more persistent with finishing some operations
(cherry picked from commit 8d8589b385)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
773d9d7e40 ffs_snapblkfree(): add a comment explaining lockmgr invocation
(cherry picked from commit 4559700a0a)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
8fcc0d7b39 ufs: Use IS_SNAPSHOT()
(cherry picked from commit 0cdc603308)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
7782d71671 syncer VOP_FSYNC(): unlock syncer vnode around call to VFS_SYNC()
(cherry picked from commit 3d68c4e175)
2022-02-07 11:38:50 +02:00
Konstantin Belousov
4116ae3ece buf_alloc(): lock the buffer with LK_NOWAIT
(cherry picked from commit 5875b94c74)
2022-02-07 11:38:49 +02:00
Konstantin Belousov
78d27f25c7 Use dedicated lock name for pbufs
(cherry picked from commit 531f8cfea0)
2022-02-07 11:38:49 +02:00
Konstantin Belousov
6939af9c12 ext2fs: remove remnants of the UFS snapshot code
(cherry picked from commit 9cd59de2e1)
2022-02-07 11:38:49 +02:00
Cy Schubert
0d7d7c3ec7 unbound: Vendor import 1.14.0
Vendor import GA release of unbound 1.14.0.

Merge commit '9b87431a326169e72d5ca55670cb3c95205aa350' into unbound/main

(cherry picked from commit 273016e836)
2022-02-06 21:51:39 -08:00
Cy Schubert
915840ba7f sqlite3: Vendor import of sqlite3 3.37.2
Changes at https://www.sqlite.org/releaselog/3_37_2.html.

(cherry picked from commit 8778e54cab)
2022-02-06 20:58:39 -08:00
Cy Schubert
ae7ca647e4 sqlite3: Vendor import of sqlite3 3.37.1
Changes at https://www.sqlite.org/releaselog/3_37_1.html.

(cherry picked from commit 0197ba465f)
2022-02-06 20:58:39 -08:00
Marko Zec
d055313f8c fib_algo: shift / mask by constants in dxr_lookup()
Since trie configuration remains invariant during each DXR instance
lifetime, instead of shifting and masking lookup keys by values
computed at runtime, compile upfront several dxr_lookup()
configurations with hardcoded shift / mask constants, and choose the
apropriate lookup function version after each DXR instance rebuild.

In synthetic tests this yields small but measurable (5-10%) lookup
throughput improvement, depending on FIB size and  prefix patterns.

MFC after:	3 days

(cherry picked from commit e7abe200c2)
2022-02-06 08:33:17 +01:00
Ed Maste
62a323ecbc dma: limit lines to 998 characters
Per RFC2822 the maximum transmitted line length is "998 characters...
excluding the CRLF."  In a file the maximum is 999 with the \n included.

Previously mail containing a line with exactly 999 characters would
bounce.

PR:		208261
Reported by:	Helge Oldach
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 1a0dde338d)
2022-02-05 11:26:39 -05:00
Ed Maste
eb32eb2b45 dma: exit if invoked with invalid (zero) argc
This was prompted by the recent pkexec vulnerability (CVE-2021-4034).
This change is being made on general principle for setuid/setgid
binaries and is not in response to an actual issue.

Reviewed by:	kevans, markj (both earlier)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34087

(cherry picked from commit 1c91aedf25)
2022-02-05 11:26:09 -05:00
Michał Górny
93627e0a18 gdb(4): Do not use run length encoding for 3-symbol repetitions
Disable the gdb packet run length encoding for 3-symbol repetitions.
While it is technically possible to encode them, they have no advantage
over sending the characters verbatim (the resulting length is the same)
and they result in sending non-printable \x1f character.  The protocol
has been designed with the intent of avoiding non-printable characters
and therefore the run length encoding is biased to emit \x20 (a space)
with the minimal intended run length of 4.

While at it, simplify the logic by merging the different 'if' blocks
into a single while loop, and moving 'runlen == 0' check lower.

Reviewed by:	cem, emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33686

(cherry picked from commit 028a372fe2)
2022-02-04 20:58:34 -05:00
Kirk McKusick
57b0fc3067 Avoid unnecessary setting of UFS flag requesting fsck(8) be run.
(cherry picked from commit 7ef56fb049)
2022-02-04 14:45:49 -08:00
Kirk McKusick
c16f699d79 Whitespace and capitalization cleanups.
(cherry picked from commit c82df0a0bf)
2022-02-04 11:59:30 -08:00
Mark Johnston
1a233fd317 sort: Fix message catalogue usage
- Check that catopen() succeeded before calling catclose().  musl will
  crash in the latter if the catalogue descriptor is -1.
- Keep the message catalogue open for most of sort(1)'s actual
  operation.
- Don't use catgets(3) to print error messages if catopen(3) had failed.

Reviewed by:	arichardson, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8d8b9b560a)
2022-02-04 09:58:13 -05:00
Kristof Provost
5f11f3cb1f pf tests: Provoke failure in pf_ioctl_addrule
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 4ca4193760)
2022-02-04 11:38:15 +01:00
Kristof Provost
ba4b345345 pf: ensure we don't destroy an uninitialised lock
The new lock introduced in 5f5e32f1b3 needs to be initialised early so
that it can be safely destroyed if we error out.

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

(cherry picked from commit e5ca5e801d)
2022-02-04 11:38:09 +01:00
Kristof Provost
650607380c pf: protect the rpool from races
The roundrobin pool stores its state in the rule, which could
potentially lead to invalid addresses being returned.

For example, thread A just executed PF_AINC(&rpool->counter) and
immediately afterwards thread B executes PF_ACPY(naddr, &rpool->counter)
(i.e. after the pf_match_addr() check of rpool->counter).

Lock the rpool with its own mutex to prevent these races. The
performance impact of this is expected to be low, as each rule has its
own lock, and the lock is also only relevant when state is being created
(so only for the initial packets of a connection, not for all traffic).

See also:	https://redmine.pfsense.org/issues/12660
Reviewed by:	glebius
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33874

(cherry picked from commit 5f5e32f1b3)
2022-02-04 11:37:14 +01:00
Konstantin Belousov
d0128bd98a msdosfs_denode.c: some style
(cherry picked from commit d51b0786a2)
2022-02-04 12:19:36 +02:00
Gordon Bergling
fb65d88033 sctp(4): Fix a typo in an INVARIANTS panic message
- s/failes/fails/

(cherry picked from commit 4bd030b369)
2022-02-04 11:00:46 +01:00
Alexander Motin
35f0bf2d37 atkbd: Reduce polling rate from 10Hz to ~1Hz.
In my understanding this is only needed to workaround lost interrupts.
I was thinking to remove it completely, but the comment about edge-
triggered interrupt may be true and needs deeper investigation.  ~1Hz
should be often enough to handle the supposedly rare loss cases, but
rare enough to not appear in top.  Add sysctl hw.atkbd.hz to tune it.

MFC after:	1 month

(cherry picked from commit 9e007a88d6)
2022-02-03 19:55:44 -05:00
Mark Johnston
f6e755d1b2 geom: Handle partial I/O in g_{read,write,delete}_data()
These routines are used internally by GEOM to dispatch I/O requests to a
provider, typically for tasting or for updating GEOM class metadata
blocks.

These routines assumed that partial I/O did not occur without setting
BIO_ERROR, but this is possible in at least two cases:
- Some or all of the I/O range is beyond the provider's mediasize.
  In this scenario g_io_check() truncates the bounds of the request
  before it is handed to the target provider.
- A read from vnode-backed md(4) device returns EOF (the backing vnode
  is allowed to be smaller than the device itself) or partial vnode I/O
  occurs.
In these scenarios g_read_data() could return a partially uninitialized
buffer.  Many consumers are not affected by the first case, since the
offsets used for provider metadata or tasting are relative to the
provider's mediasize, but in some cases metadata is read at fixed
offsets, such as when searching for a UFS superblock using the offsets
defined by SBLOCKSEARCH.

Thus, modify the routines to explicitly check for a non-zero residual
and return EIO in that case.  Remove a related check from the
DIOCGDELETE ioctl handler, it is handled within g_delete_data() now.

Reviewed by:	mav, imp, kib
Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d91d2b513e)
2022-02-03 09:34:27 -05:00
Dimitry Andric
40b816bd4f Apply clang fix for assertion failure compiling science/chrono
Merge commit 6b0f35931a44 from llvm git (by Jennifer Yu):

  Fix signal during the call to checkOpenMPLoop.

  The root problem is a null pointer is accessed during the call to
  checkOpenMPLoop, because loop up bound expr is an error expression
  due to error diagnostic was emit early.

  To fix this, in setLCDeclAndLB, setUB and setStep instead return false,
  return true when LB, UB or Step contains Error, so that the checking is
  stopped in checkOpenMPLoop.

  Differential Revision: https://reviews.llvm.org/D107385

Note this only fixes the assertion reported in bug 261567; some other
tweaks for port dependencies are probably still required to make it
build to completion.

PR:		261567
MFC after:	3 days

(cherry picked from commit fdf2784101)
2022-02-02 21:51:40 +01:00
Toomas Soome
bde54d2dc0 contrib/terminus: update to terminus-font-4.49.1
(cherry picked from commit 658a47d1ef)
2022-02-02 17:56:00 +02:00
Gordon Bergling
e61be158fb bsnmp: Fix two typos in error messages
- s/responce/response/

(cherry picked from commit 4731124cac)
2022-02-02 09:49:53 +01:00
Gordon Bergling
e5f0a16e19 extra_tcp_stacks: Fix a few common typos
TCP_BBR:
- Fix a typo introducted in 1b90dfa5d2, which was reported by tuexen@

TCP_RACK:
- Correct two sysctl descriptions: s/corret/correct/

tcp_bbr(4): Also fix s/measurment/measurement/ in the man page

(cherry picked from commit b3df222eae)
2022-02-02 09:49:31 +01:00
Gordon Bergling
b42a942f7e cpucontrol(8): Fix a typo in an error message
- s/incorret/incorrect/

(cherry picked from commit ee6d379be7)
2022-02-02 09:49:08 +01:00
Andriy Gapon
8934d3e7b9 sdhci: fix dumping support in MMCCAM configuration
This change fixes interaction with recently added sddadump.

(cherry picked from commit 94ff1d9cc8)
2022-02-02 08:51:13 +02:00
Mark Johnston
2faefc48c7 tools/build: Fix the error message used when a host tool is not present
(cherry picked from commit ddf312e8d7)
2022-02-01 20:28:12 -05:00
Ed Maste
fd1501dcf0 sanitizers: Improve FreeBSD ASLR detection
The kern.elf64.aslr.pie_enable and kern.elf32.aslr.pie_enable sysctls
control the default setting for PIE binary address randomization, but
it is possible to enable or disable ASLR on a per-process basis.  Use
procctl(2) to query whether ASLR is enabled.

(Note that with ASLR enabled but sysctl kern.elf64.aslr.pie_enable=0
a PIE binary will in effect have randomization disabled, and be
functional with msan.  This is not intended as as a user-facing control
though.  The user can use proccontrol(1) to disable aslr for the
process.)

Approved by:	dim
Obtained from:	LLVM 64de0064f315f57044294879d9ff4eacb454d45b
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33933

(cherry picked from commit 7cafe89f9c)
2022-02-01 20:13:30 -05:00
Alexander Motin
c27237d62f Reduce bufdaemon/bufspacedaemon shutdown time.
Before this change bufdaemon and bufspacedaemon threads used
kthread_shutdown() to stop activity on system shutdown.  The problem is
that kthread_shutdown() has no idea about the wait channel and lock used
by specific thread to wake them up reliably.  As result, up to 9 threads
could consume up to 9 seconds to shutdown for no good reason.

This change introduces specific shutdown functions, knowing how to
properly wake up specific threads, reducing wait for those threads on
shutdown/reboot from average 4 seconds to effectively zero.

MFC after:	2 weeks
Reviewed by:	kib, markj
Differential Revision:  https://reviews.freebsd.org/D33936

(cherry picked from commit b7ff445ffa)
2022-02-01 19:53:10 -05:00
Dimitry Andric
b39b662917 Apply llvm fix for assertion failure compiling recent libc++
Merge commit c7c84b90879f from llvm git (by Adrian Prantl):

  [DwarfDebug] Refuse to emit DW_OP_LLVM_arg values wider than 64 bits

  DwarfExpression::addUnsignedConstant(const APInt &Value) only supports
  wider-than-64-bit values when it is used to emit a top-level DWARF
  expression representing the location of a variable. Before this change,
  it was possible to call addUnsignedConstant on >64 bit values within a
  subexpression when substituting DW_OP_LLVM_arg values.

  This can trigger an assertion failure (e.g. PR52584, PR52333) when it
  happens in a fragment (DW_OP_LLVM_fragment) expression, as
  addUnsignedConstant on >64 bit values splits the constant into separate
  DW_OP_pieces, which modifies DwarfExpression::OffsetInBits.

  This change papers over the assertion errors by bailing on overly wide
  DW_OP_LLVM_arg values. A more comprehensive fix might be to be to split
  wide values into pointer-sized fragments.

  [0] https://github.com/llvm/llvm-project/blob/e71fa03/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L799-L805

  Patch by Ricky Zhou!

  Differential Revision: https://reviews.llvm.org/D115343

MFC after:	3 days

(cherry picked from commit 9738bc28ab)
2022-02-01 19:25:08 +01:00
Andriy Gapon
eacdf85d44 dtrace: add a knob to control maximum size of principal buffers
We had a hardcoded limit of 1/128-th of physical memory that was further
subdivided between all CPUs as principal buffers are allocated on the
per-CPU basis.  Actually, the buffers could use up 1/64-th of the
memmory because with the default switch policy there are two buffers per
CPU.

This commit allows to change that limit.

Note that the discussed limit is per dtrace command invocation.
The idea is to limit the size of a single malloc(9) call, not the total
memory size used by DTrace buffers.

(cherry picked from commit 7fdf0e8835)
2022-02-01 10:12:03 +02:00
Andriy Gapon
08bc6b60c3 dwwdt: make it actually useful
Flip dwwdt_prevent_restart to false.  What's the use of a watchdog if it
does not restart a hung system?

Add a knob for panic-ing on the first timeout, resetting on the second
one.  This can be useful if interrupts can still work, otherwise a reset
recovers a system without any aid for debugging the hang.

The change also doubles the timeout that's programmed into the hardware.
The previous version of the code always had the interrupt on the first
timeout enabled, but it took no action on it.  Only the second timeout
could be configured to reset the system.  So, the hardware timeout was
set to a half of the user requested timeout.  But now,we can take a
corrective action on the first timeout, so we use the user requested
timeout.

While here, define boolean sysctl-s as such.

(cherry picked from commit ee900888c4)
2022-02-01 10:11:26 +02:00
Konstantin Belousov
ec2db06d0d stdio: add test for 86a16ada1e: fflush() handling of errors
PR:	76398

(cherry picked from commit 72d5dedfa6)
2022-02-01 05:29:16 +02:00
Konstantin Belousov
afa9a1f5ec __sflush(): on write error, if nothing was written, reset FILE state back
PR:	76398

(cherry picked from commit 86a16ada1e)
2022-02-01 05:29:15 +02:00
Mark Johnston
40d6b2a362 exec: Remove the stack gap implementation
ASLR stack randomization will reappear in a forthcoming commit.  Rather
than inserting a random gap into the stack mapping, the entire stack
mapping itself will be randomized in the same way that other mappings
are when ASLR is enabled.

No functional change intended, as the stack gap implementation is
currently disabled by default.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 758d98debe)
2022-01-31 09:48:57 -05:00
Mark Johnston
947e849150 sysent: Add a sv_psstringssz field to struct sysentvec
The size of the ps_strings structure varies between ABIs, so this is
useful for computing the address of the ps_strings structure relative to
the top of the stack when stack address randomization is enabled.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 3fc21fdd5f)
2022-01-31 09:48:11 -05:00
Mark Johnston
d247611467 exec: Introduce the PROC_PS_STRINGS() macro
Rather than fetching the ps_strings address directly from a process'
sysentvec, use this macro.  With stack address randomization the
ps_strings address is no longer fixed.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 706f4a81a8)
2022-01-31 09:46:57 -05:00
Andrew Turner
3b8c26507f Use ${MACHINE} for the kernel modeule ldscript
For consistancy with the kernel linker script also use ${MACHINE} for
finding the kernel module linker script. As we currently only use this
for amd64 and i386 this is a no-op, but I'm planning on using this with
arm64 where ${MACHINE} != ${MACHINE_ARCH}.

Reviewed by:	markj, kib, imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33841

(cherry picked from commit 2754373f9a)
2022-01-31 10:05:54 +00:00
Andrew Turner
b28c2ffcc2 Fix a typo in an arm64 comment
This was pointed out by markj in the review, but I missed it and forgot
to fix before pushing.

Reported by:	markj
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 78c347d9f3)
2022-01-31 10:05:47 +00:00