Commit Graph

285102 Commits

Author SHA1 Message Date
Gleb Smirnoff
1d9722de6f tcp_wrappers: recognize IPv6 addresses/prefixes
Intentionally or not, but the libwrap was written in such manner that
if your /etc/hosts.allow doesn't have any domain names, neither smart
keywords like LOCAL or KNOWN, then it will not try to resolve the
client address during the hosts check.  This was achieved with the
NOT_INADDR() check that matched IPv4 addresses/prefixes.  Extend this
to also skip resolve if client list token looks like IPv6.

Reviewed by:		philip, emaste
PR:			269456
Differential revision:	https://reviews.freebsd.org/D40070
2023-07-20 14:56:20 -07:00
Gleb Smirnoff
9ff45b8ed8 sshd: do not resolve refused client hostname
This is a compromise between POLA and practical reasoning.  We don't
want to block the main server loop in an attempt to resolve.  But we
need to keep the format of the logged message as is, for sake of
sshguard and other scripts.  So let's print just the IP address twice,
this is what libwrap's refuse() would do if it failed to resolve.

Reviewed by:		philip
PR:			269456
Differential revision:	https://reviews.freebsd.org/D40069
2023-07-20 14:56:20 -07:00
Gleb Smirnoff
90f10db8a9 sshd: remove unneeded initialization of libwrap logging severities
This part of ca573c9a17 proved to be unnecessary.  As the removed
comment says, we set them merely for logging syntax errors, as we log
refusals ourselves.  However, inside the libwrap the parser logs any
syntax errors with tcpd_warn() which has hardcoded LOG_WARNING inside.

Reviewed by:		philip, emaste
Differential revision:	https://reviews.freebsd.org/D40068
2023-07-20 14:56:20 -07:00
Dmitry Morozovsky
615d167cb8 Revert "tftpd: fix double-colon typo in option string"
It was not a typo: -d takes an optional argument, which is indicated with
a double colon.

This reverts commit 3cbc8e752b.

Spotted by:	kevans
2023-07-21 00:38:30 +03:00
Dmitry Morozovsky
3cbc8e752b tftpd: fix double-colon typo in option string
MFC after:	1 month
X-MFC-With:	273a307d0b
X-MFC-With:	03c2616dc5
2023-07-21 00:24:28 +03:00
Eugene Grosbein
03c2616dc5 tftpd: unbreak getopt()
Unbreak getopt() broken by recent commit.

Fixes:		273a307d0b
MFC after:	1 month
2023-07-21 03:26:32 +07:00
Eugene Grosbein
273a307d0b tftpd: introduce new option -S
Historically, tftpd disallowed write requests to existing files
that are not publicly writable. Such requirement is questionable at least.
Let us make it possible to run tftpd in chrooted environment
keeping files non-world writable.

New option -S enables write requests to existing files
for chrooted run according to generic file permissions.
It is ignored unless tftpd runs chrooted.

MFC after:	1 month
Requested by:	marck
Differential:	https://reviews.freebsd.org/D41090 (based on)
2023-07-21 03:23:35 +07:00
Pierre Pronchery
1c42ed54bf libcrypto: add missing symbols to the FIPS provider
The fips.so provider module exposing FIPS-validated algorithms was still
missing a number of symbols.

PR:		272454
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41018
2023-07-20 15:05:12 -04:00
Konstantin Belousov
db6c7c7f8d vmspace_fork(): do not override offset for the guard entries
The offset field contains protection for the stack guards.

Reported by:	cy
Fixes:	21e45c30c3
MFC after:	1 week
2023-07-20 22:04:03 +03:00
Navdeep Parhar
a29916a6f8 ifconfig_netlink.c: whitespace cleanup.
No functional change.
2023-07-20 10:54:56 -07:00
Navdeep Parhar
88284368fa ifconfig: Shift unsigned value to avoid UB.
Reported by:	kib@
2023-07-20 10:54:56 -07:00
Ed Maste
e0a63d875e pciconf: add PCIe 5.0 and PCIe 6.0 link speeds
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40710
2023-07-20 13:39:17 -04:00
Minsoo Choo
0c3eaa06b3 Remove perforce tools and references
Perforce has been retired since 2019 (commit feea78990c), so there is
no need anymore to keep perforce tools.  Plus, there is no need to
mention perforce admin.

Reviewed by:	emaste, Olivier Certner
Differential Revision:	https://reviews.freebsd.org/D41106
2023-07-20 13:33:39 -04:00
Navdeep Parhar
47b1fef6fb ifconfig: Fix the display of capabilities in the netlink based code.
The capabilities in if_capabilities2/if_capenable2 are reported in the
second 32b and were not being displayed correctly.  v does not need to
be advanced because v[i / 32] is the correct 32b value already.

Sponsored by:	Chelsio Communications

Reviewed by:	kib@
Differential Revision:	https://reviews.freebsd.org/D41107
2023-07-20 10:26:18 -07:00
Konstantin Belousov
21e45c30c3 mmap(MAP_STACK): on stack grow, use original protection
If mprotect(2) changed protection in the bottom of the currently grown
stack region, currently the changed protection would be used for the
stack grow on next fault.  This is arguably unexpected.

Store the original protection for the entry at mmap(2) time in the
offset member of the gap vm_map_entry, and use it for protection of the
grown stack region.

PR:	272585
Reported by:	John F. Carr <jfc@mit.edu>
Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41089
2023-07-20 17:11:42 +03:00
Eric Joyner
a52f23f4c4
iflib: Unlock ctx lock around call to ether_ifattach()
Panic occurs during loading driver using kldload. It exists since netlink is
enabled.  There is problem with double locking ctx. This fix allows to call
ether_ifattach() without locked ctx.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

PR:		271768
Reviewed by:	erj@, jhb@
MFC after:	1 day
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D40557
2023-07-19 15:51:26 -07:00
John Baldwin
e5c4737955 amd64 crt1: Explicitly use a PLT entry for main in the PIC case.
This ensures GNU as generates a R_X86_64_PLT32 relocation instead of
R_X86_64_32.

Reviewed by:	kib
Fixes:		c969310c99 csu: Implement _start using as to satisfy unwinders on x86_64
Differential Revision:	https://reviews.freebsd.org/D41101
2023-07-19 11:53:33 -07:00
Dmitry Chagin
c84617e87a i386: Switch to PIC kernel modules
It seems since the last llvm project update, the lld linker has started
creating a PLT dependent kernel module object files.

Reviewed by:		kib, jhb, emaste
Differential Revision:	https://reviews.freebsd.org/D41088
2023-07-19 21:21:04 +03:00
Navdeep Parhar
c721694a1c ktls_alloc_rcv_tag: Fix capability checks for RXTLS4/6.
IFCAP2_* has the bit position and not the shifted value.

Reviewed by:	kib@
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41100
2023-07-19 11:12:14 -07:00
Dimitry Andric
8d0cab8800 Merge commit 9ca395b5ade1 from llvm-project (by Haojian Wu):
[clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.

  Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++
  code), we propagate the contains-errors bit for C-code path.

  Fixes https://github.com/llvm/llvm-project/issues/50236
  Fixes https://github.com/llvm/llvm-project/issues/50243
  Fixes https://github.com/llvm/llvm-project/issues/48636
  Fixes https://github.com/llvm/llvm-project/issues/50320

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

This fixes an assertion ('Assertion failed: ((LHSExpr->containsErrors()
|| RHSExpr->containsErrors()) && "Should only occur in error-recovery
path."), function BuildBinOp') when building parts of dtrace in certain
scenarios.

Reported by:	dstolfa
PR:		271047
MFC after:	1 month
2023-07-19 19:14:23 +02:00
Ed Maste
66fd12cf48 ssh: Update to OpenSSH 9.3p2
From the release notes:

Changes since OpenSSH 9.3
=========================

This release fixes a security bug.

Security
========

Fix CVE-2023-38408 - a condition where specific libaries loaded via
ssh-agent(1)'s PKCS#11 support could be abused to achieve remote
code execution via a forwarded agent socket if the following
conditions are met:

* Exploitation requires the presence of specific libraries on
  the victim system.
* Remote exploitation requires that the agent was forwarded
  to an attacker-controlled system.

Exploitation can also be prevented by starting ssh-agent(1) with an
empty PKCS#11/FIDO allowlist (ssh-agent -P '') or by configuring
an allowlist that contains only specific provider libraries.

This vulnerability was discovered and demonstrated to be exploitable
by the Qualys Security Advisory team.

In addition to removing the main precondition for exploitation,
this release removes the ability for remote ssh-agent(1) clients
to load PKCS#11 modules by default (see below).

Potentially-incompatible changes
--------------------------------

 * ssh-agent(8): the agent will now refuse requests to load PKCS#11
   modules issued by remote clients by default. A flag has been added
   to restore the previous behaviour "-Oallow-remote-pkcs11".

   Note that ssh-agent(8) depends on the SSH client to identify
   requests that are remote. The OpenSSH >=8.9 ssh(1) client does
   this, but forwarding access to an agent socket using other tools
   may circumvent this restriction.

CVE:		CVE-2023-38408
Sponsored by:	The FreeBSD Foundation
2023-07-19 13:02:33 -04:00
Marius Strobl
37eec7f68a ObsoleteFiles.inc: Remove leading slash from 20230714 entry
Fixes:	c3f58005d9 signal: Remove gsignal references from manuals
2023-07-19 19:00:14 +02:00
Marius Strobl
13d1f5cb62 enic(4): Remove unused dupe prototype 2023-07-19 18:58:51 +02:00
Christos Margiolis
02402ec888 kinst.h: make pointer to probe in kinst_cpu_state const
Fixes: 5b701ed19c ("kinst: start moving towards per-probe
trampolines")

Sponsored by: The FreeBSD Foundation
2023-07-19 19:57:44 +03:00
Ed Maste
e524ba4db4 Vendor import of OpenSSH 9.3p2 2023-07-19 11:49:33 -04:00
Christos Margiolis
e967a9a5d5 Revert "dtrace: cache current probe in kdtrace_thread_t"
This reverts commit 22508c8b6c.

The t_kinst_curprobe field is no longer needed by kinst.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41031
2023-07-19 17:58:49 +03:00
Christos Margiolis
07864a8a24 kinst: port to arm64
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40337
2023-07-19 17:58:18 +03:00
Christos Margiolis
2517b2085b kinst: use per-probe trampolines in riscv
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40963
2023-07-19 17:57:59 +03:00
Christos Margiolis
5b701ed19c kinst: start moving towards per-probe trampolines
Using per-CPU and per-thread trampolines is expensive and error-prone,
since we're rewriting the same memory blocks constantly. Per-probe
trampolines solve this problem by giving each probe its own block of
executable memory, which more or less remains the same after the initial
write.

What this patch does, is get rid of the initialization code which
allocates a trampoline for each thread, and instead let each port of
kinst allocate a trampoline for each new probe created. It also sets up
the infrastructure needed to support the new trampoline scheme.

This change is not currently supported on amd64, as the amd64 port needs
further changes to work, so this is a temporary/gradual patch to fix the
riscv and arm64 ports.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40962
2023-07-19 17:57:21 +03:00
Christos Margiolis
eb1413c9a6 kinst: exclude cpu_switch
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40985
2023-07-19 17:56:29 +03:00
Christos Margiolis
ea89133dbc kinst: check for 'push %rbp' anywhere in the function
Currently kinst checks if only the first instruction is 'push %rbp',
essentially excluding functions that do push RBP, but not in the first
instruction. This patch modifies kinst to check for 'push %rbp', as
well, as a following 'pop %rbp', anywhere in the function. This behavior
also matches that of FBT.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40283
2023-07-19 17:53:08 +03:00
Christos Margiolis
8ada3f78e6 kinst.h: reorder function declarations based on implementation file
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41032
2023-07-19 17:50:24 +03:00
Dag-Erling Smørgrav
a122c3c492 unifdef: Fix case where a multiline comment follows a directive.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41026
2023-07-19 14:47:23 +00:00
Doug Moore
6f251ef228 radix_trie: simplify ge, le lookups
Replace the implementations of lookup_le and lookup_ge with ones
that do not use a stack or climb back up the tree, and instead
exploit the popmap field to quickly identify the place to resume
searching if the straightforward indexed search fails.

The code size of the original functions shrinks by a combined 160
bytes on amd64, and the cumulative cycle count per invocation of
the two functions together is reduced 20% in a buildworld test.

Reviewed by:	alc, markj
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D40936
2023-07-19 09:43:31 -05:00
Dmitry Chagin
e38c634b77 vfs: Add a parenthese to vn_lock_pair() asserts to silence gcc
Reviewed by:		kib, markj
Differential Revision:	https://reviews.freebsd.org/D41070
2023-07-19 16:51:07 +03:00
Naman Sood
181692ab08
pw: Add regression tests for useradd bug fixes
PR:		238995
Reviewed by:	jrm
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41080
2023-07-19 10:43:12 -03:00
Naman Sood
1a8d37b8cf
pw: Use existing group entry, even if it already has members
Fix the following problem:

1. A nonexistent user, someuser, is added to /etc/group as
   someuser:*:12345:someuser.
2. someuser is then created with the default login group.

A second group entry for someuser will be created.

   someuser:*:12345:someuser
   someuser:*:12346:

With this fix, the existing group entry will be used.

PR:		238995
Reviewed by:	bapt, jrm
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41057
2023-07-19 10:40:53 -03:00
Naman Sood
17839f45d8
pw: Ensure group membership is not duplicated
Fix the following problem:

1. A nonexistent user, someuser, is added to somegroup in /etc/group.
2. someuser is then created with membership in somegroup.

The entry for somegroup in /etc/group will then contain

    somegroup:*:12345:someuser,someuser

With this fix, the entry will be

    somegroup:*:12345:someuser

PR:		238995
Reviewed by:	bapt, jrm
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41076
2023-07-19 10:36:09 -03:00
Michael Tuexen
e4a873bf10 tcp: improve layout of struct tcpcb
Put optional fields at the end to minimize run time problems in
case CC modules are build from within its directory.

Reviewed by:		cc, gallatin, glebius, imp
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D41059
2023-07-19 14:47:36 +02:00
John Baldwin
c5312bd79e cam: Move bus_dmamap_load_ccb into cam.c.
This routine is specific to CAM and no longer assumes any internal
bus_dma knowledge as it is simple wrapper around bus_dmamap_load_mem.

Fixes:		60381fd1ee memdesc: Retire MEMDESC_CCB.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41058
2023-07-18 18:19:27 -07:00
Dmitry Chagin
b834497c6d linux(4): Use M_LINUX for malloc type of proc emuldata
MFC after:		2 weeks
2023-07-19 00:44:17 +03:00
Dmitry Chagin
7729467781 linux(4): Use M_LINUX for malloc type in getdents
MFC after:		2 weeks
2023-07-19 00:44:16 +03:00
Dmitry Chagin
e27e3fa71c linux(4): Use M_LINUX for malloc type in getdents64
MFC after:		2 weeks
2023-07-19 00:44:16 +03:00
Dmitry Chagin
b27f3237c8 linux(4): Delete a useless variable in getdents64
MFC after:		2 weeks
2023-07-19 00:44:16 +03:00
Dmitry Chagin
13d049ab8d linux(4): Use M_LINUX for malloc type in readdir
MFC after:		2 weeks
2023-07-19 00:44:15 +03:00
Dmitry Chagin
fffb2e8de6 linux(4): Delete a useless variable in readdir
MFC after:		2 weeks
2023-07-19 00:44:15 +03:00
Dmitry Chagin
fc1c787aa0 linux(4): Properly allocate buffer for kern_getdirentries in readdir
Looks like prior to ino64 project the size of the struct linux_dirent
was greater (or equal) to the size of the native struct dirent so the
native dirent fit into the buffer. After ino64 project the size of the
native struct dirent has increased.

Spotted by gcc12.
MFC after:		2 weeks
2023-07-19 00:44:15 +03:00
Sven Ruediger
9efad6f9e1 add defaults for adduser.sh (OK? [yes] & additional user [no])
Event:		Kitchener-Waterloo Hackathon 202305
Differential Revision:	https://reviews.freebsd.org/D40157
2023-07-18 10:37:48 -07:00
Minsoo Choo
3bfbb521fe ls: Improve POSIX compatibility for -g and -n.
- Change -g (ignored for BSD 4.3 compatibility since BSD 4.4)
  to use POSIX semantics of implying -l but omitting the owner's
  name.

- Change -n to imply -l.

The -o option remains unchanged (POSIX defines -o as a complement to
-g that implies -l but omits group names whereas BSD defines -o to add
file flags to -l).  This compromise is the same used by both NetBSD
and OpenBSD.

PR:		70813
Reviewed by:	jhb, Pau Amma <pauamma@gundo.com>
Co-authored-by:	John Baldwin <jhb@FreeBSD.org>
Differential Revision:	https://reviews.freebsd.org/D34747
2023-07-18 10:03:09 -07:00
Ed Maste
d5e2d0f140 openssh: document a locally-applied workaround
We have a local hacky workaround for an issue caused by a hacky
upstream autoconf test.  Reported upstream on the OpenSSH mailing list:
https://lists.mindrot.org/pipermail/openssh-unix-dev/2022-May/040242.html

PR:		209441
Sponsored by:	The FreeBSD Foundation
2023-07-18 12:27:02 -04:00