Commit Graph

284828 Commits

Author SHA1 Message Date
Mateusz Guzik
e01f9fe10c ipf: low-effort fix to make it compilable without inet6 2023-07-05 10:02:32 +00:00
Mateusz Guzik
cea9f49f82 ping: low-effort fix to make it compilable without inet 2023-07-05 10:02:32 +00:00
Mateusz Guzik
55e0aefae6 ping: low-effort fix to make it compilable without inet6 2023-07-05 10:02:32 +00:00
Andrew Turner
df0d0fc990 Add helpers to allocate an arm64 VFP state struct
This will be used by bhyve and will allow the size to change, e.g. for SVE.

Reviewed by:	markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D40131
2023-07-05 10:42:14 +01:00
Andrew Turner
6b1f532951 arm64: Fix a use of update_lower_register
In get_kernel_reg_masked we use update_lower_register to get the lower
value of two registers for a given field. It will return the entire
register value with just the single field updated.

Because of this get_kernel_reg_masked needs to use the returned value
directly rather than ORing each field together. Fix this by updating
the mask and returning that from get_kernel_reg_masked.

Reviewed by:	markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D40846
2023-07-05 10:42:14 +01:00
Baptiste Daroussin
3743f3d020 pci_vendors: update to 2023-06-19 2023-07-05 08:31:37 +02:00
Konstantin Belousov
658e762067 kern_lockf.c: fix typo
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-07-05 02:11:37 +03:00
Mark Johnston
8e7046ff29 libcrypto: Revert recent changes to fix legacy and fips providers
They break the !amd64 builds due to an underspecified include path and
will be re-applied once that's fixed.

Reported by:	Ronald Klop <ronald-lists@klop.ws>
2023-07-04 16:38:26 -04:00
Li-Wen Hsu
fea4a44c19
release/DVD_PACKAGES: Update the names of drm-kmod ports
Reviewed by:	x11 (manu), re (gjb)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40770
2023-07-05 04:24:52 +08:00
Joerg Pulz
53a03e312c ure(4): add support for Thinkpad Hybrid USB-C with USB-A dock
Add support for LAN port found on Thinkpad Hybrid USB-C with USB-A dock.
While here fix a small typo
  - s/UBS/USB/

Sponsored by:	Technical University of Munich
Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/791
2023-07-04 15:42:55 -04:00
Mohamed Akram
b35ea9bac9 man(1): use gzcat for .gz files
POSIX zcat appends the .Z suffix to file arguments causing the command to fail
with .gz files.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>

Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/789
2023-07-04 15:42:55 -04:00
Olivier Cochard
150d8ca9f3 socket afinet tests: using dynamic ports instead of the same static port
Allows these tests to be run in parallel.

Approved by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D40859
2023-07-04 21:17:56 +02:00
Pierre Pronchery
c4b7fe91fc libcrypto: group definitions for libcrypto and fips
OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. This
change makes sure the FIPS module matches build instructions used for
libcrypto.

Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/787
2023-07-04 15:05:01 -04:00
Pierre Pronchery
0b27be500a libcrypto: expand the common Makefile for providers
OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. This
change adds mandatory source files to every provider.

Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/787
2023-07-04 15:04:56 -04:00
Pierre Pronchery
0102ee0d59 libcrypto: add missing symbols to the fips provider
OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. One
such provider, "fips", ships with OpenSSL 3 directly, and groups
algorithms that can be FIPS 140-2 validated.

The import of OpenSSL 3.0.9 was building this provider incorrectly,
missing symbols required for proper operation.

In addition, without the change in OpenSSL's crypto/bn/bn_const.c, the
FIPS module fails loading: `Undefined symbol "ossl_bignum_modp_1536_p"`.
This change is consistent with crypto/bn/bn_dh.c though.

Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/787
2023-07-04 15:04:49 -04:00
Pierre Pronchery
0457eebbe8 libcrypto: add missing symbols to the legacy provider
OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. One
such provider, "legacy", ships with OpenSSL 3 directly, and groups
obsoleted algorithms that can still optionally be used anyway.

The import of OpenSSL 3.0.9 was building this provider incorrectly,
missing symbols required for proper operation.

Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/787
2023-07-04 15:04:04 -04:00
Konstantin Belousov
d7614c010c vn_path_to_global_path_hardlink(): initialize len
before calling vn_fullpath_hardlink().  Otherwise we get random failures
when the len is automatically clipped.

Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-07-04 19:00:24 +03:00
Christos Margiolis
911f026039 dtrace: move kinst tests to common
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40414
2023-07-04 18:46:59 +03:00
Christos Margiolis
1c77612451 riscv: improve register dumping
Search for and print kernel symbols in case a register's value is a
kernel address. Also improve column alignment.

Reviewed by:	mhorne, jhb
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40829
2023-07-04 18:38:37 +03:00
Christos Margiolis
9310bf5404 kinst: update LICENSE headers
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40875
2023-07-04 18:38:25 +03:00
Christos Margiolis
2d7bb03adb kinst: port to riscv
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39884
2023-07-04 18:38:01 +03:00
Christos Margiolis
22508c8b6c dtrace: cache current probe in kdtrace_thread_t
Needed by the forthcoming RISC-V and ARM64 ports.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40872
2023-07-04 18:37:55 +03:00
Christos Margiolis
2e28f8cc39 kinst: accommodate other architectures in Makefile
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40871
2023-07-04 18:37:44 +03:00
Arthur Kiyanovski
ac40021c93 ena: Update driver version to v2.6.3
Bug Fixes:
* Initialize statistics before the interface is available
* Fix driver unload crash

Minor Changes:
* Mechanically convert ena(4) to DrvAPI
* Remove usage of IFF_KNOWSEPOCH

MFC after: 2 weeks
Sponsored by: Amazon, Inc.
2023-07-04 15:58:47 +02:00
Arthur Kiyanovski
c59a5fbd8a ena: Fix driver unload crash
When ena_detach is called, we first call ether_ifdetach(),
which destroys internal addresses of ifp. One such address
is ifp->if_addr->ifa_addr. Then during ena_destroy_device(),
if_link_state_change() is called, eventually trying to access
ifp->if_addr->ifa_addr->sa_family. This causes an access
to garbage memory and crashes the kernel.

Ticket [1] was opened to the FreeBSD community to add null
check in the code of if_link_state_change().
A fix was submitted in commit [2], however it was noted
that it is our driver's responsibilty to not call
if_link_state_change() after calling ether_ifdetach().

This commit makes sure if_link_state_change() is not called
after ether_ifdetach().

[1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270813
[2]: https://reviews.freebsd.org/D39614

Fixes: 32f63fa7f9 ("Split ENA reset routine into restore and destroy stages")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
2023-07-04 15:57:15 +02:00
Osama Abboud
b9e80b5280 ena: Initialize statistics before the interface is available
In [1], the FBSD community exposed a bug in the fbsd/ena driver.

Bug description:
----------------
Current function call order is as follows:

1. ena_attach()
1.1. ena_setup_ifnet()
1.1.1. Registration of ena_get_counter()
1.1.2. ether_ifattach(ifp, adapter->mac_addr);
1.2. Statistics allocation and initialization.

At point 1.1.2, when ether_ifattach() returns, the interface is available,
and stats can be read before they are allocated, leading to kernel panic.

Also fixed a potential memory leak by freeing the stats since they were
not freed in case the following calls failed.

Fix:
----
This commit moves the statistics allocation and initialization to happen
before ena_setup_ifnet()

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268934

Fixes: 9b8d05b8ac ("Add support for Amazon Elastic Network Adapter (ENA) NIC")
Fixes: 30217e2dff ("Rework counting of hardware statistics in ENA driver")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
2023-07-04 15:51:16 +02:00
Pedro F. Giffuni
4ef3964b5f bin/date: Upgrade calculations (take 2)
Use uint64_t instead of long, as this type is not correct for platforms like i386 or armv7.

Pointed out by:	imp
2023-07-03 23:39:00 -05:00
Konstantin Belousov
81a37995c7 killpg(): close a race with fork(), part 2
When we are sending terminating signal to the group, killpg() needs to
guarantee that all group members are to be terminated (it does not need
to ensure that they are terminated on return from killpg()).  The
pg_killsx change eliminates the largest window there, but still, if a
multithreaded process is signalled, the following could happen:
- thread 1 is selected for the signal delivery and gets descheduled
- thread 2 waits for pg_killsx lock, obtains it and forks
- thread 1 continue executing and terminates the process
This scenario allows the child to escape still.

To fix it, count the number of signals sent to the process with
killpg(2), in p_killpg_cnt variable, which is incremented in killpg()
and decremented after signal handler frame is created or in exit1()
after single-threading.  This way we avoid forking if the termination is
due.

Noted and reviewed by:	markj (previous version)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D40493
2023-07-04 06:43:16 +03:00
Konstantin Belousov
3360b48525 killpg(2): close a race with fork(2), part1
If the process group member performs fork(), the child could escape
signalling from killpg(). Prevent it by introducing an sx process group
lock pg_killsx which is taken interruptibly shared around fork. If there
is a pending signal, do the trip through userspace with ERESTART to
handle signal ASTs. The lock is taken exclusively during killpg().

The lock is also locked exclusive when the process changes group
membership, to avoid escaping a signal by this means, by ensuring that
the process group is stable during fork.

Note that the new lock is before proctree lock, so in some situations we
could only do trylocking to obtain it.

This relatively simple approach cannot work for REAP_KILL, because
process potentially belongs to more than one reaper tree by having
sub-reapers.

Reported by:	dchagin
Tested by:	dchagin, pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D40493
2023-07-04 06:21:53 +03:00
Konstantin Belousov
4b59d1724b killpg1(): update the herald comment
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40493
2023-07-04 06:21:53 +03:00
Konstantin Belousov
d6b900c915 vn_path_to_global_path_hardlink(): avoid freeing non-initialized pointer
Reported by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-07-04 06:19:47 +03:00
Pedro F. Giffuni
4456846a1a bin/date: Upgrade calculations
Use long instead of int for numerous calculations, fixing a number of
date calculation overflow issues.

Obtained from:	DragonflyBSD
Git log:	4238ce6f0c6df33ce677ae298b245c62cd60fb43 (only partial)
2023-07-03 22:08:01 -05:00
Robert Clausecker
ee8b0c436d lib/libc/string: replace ffs/fls implementations with clang builtins
Most architectures we support (except for riscv64) have instructions
to compute these functions very quickly.  Replace old code with the
ffs and clz builtin functions, allowing clang to generate good code
for all architectures.

As a consequence, toss out arm and i386 ffs() implementations.

Sponsored by:	FreeBSD Foundation
Approved by:	mhorne
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D40730
2023-07-03 22:18:27 +02:00
Robert Clausecker
49390697b9 lib/libc/tests/string: add unit tests for ffs, ffsl, ffsll, fls, flsl, and flsll
Also supply CFLAGS+=-fno-builtin to ensure our unit tests
actually test libc functions and not clang's builtins.

Sponsored by:	FreeBSD Foundation
Approved by:	kevans
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D40729
2023-07-03 22:18:27 +02:00
Kristof Provost
e842342373 pf tests: test double-pass codel
Build a setup where a given packet will be passed through the codel code
twice. This used to trigger issues with double-free on mtags.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-07-03 21:32:33 +02:00
Kristof Provost
d0b0424fa0 altq codel: do not insert the same mtag twice
If we're called on an mbuf that's passed through codel before it may
already contain the MTAG_CODEL tag. The code accounts for this and does
not allocate a new mtag. However, it inserts the mtag unconditionally.
That is, it inserts the existing mtag a second time.

When the mbuf later gets freed we iterate over the list of mtags to fee
them one by one, and we'll end up freeing an mtag that's already been
freed.

Only insert the mtag if we've allocated a new one. If we found one
there's no need to insert it again.

See also:	https://redmine.pfsense.org/issues/14497
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-07-03 21:32:33 +02:00
Glen Barber
3f21d3e0ba release: update GCE configuration for python3
Reported by:	asomers
PR:		272354
MFC after:	3 days
Sponsored by:	GoFundMe https://www.gofundme.com/f/gjbbsd
2023-07-03 15:28:33 -04:00
Dimitry Andric
3a9dd38705 Stop removing OpenSSL man pages that were revived in 3.0.9
PR:		271615
Fixes:		b077aed33b ("Merge OpenSSL 3.0.9")
2023-07-03 18:58:24 +02:00
Eugene Grosbein
5aee3e14d4 syslog.3: document ident[N] format
When libc switched to generation of logs as per RFC 5424,
that change broke application ability to insert specific process id
using ident[N] format, the feature existed for decades.
Some processes rely on it (including logger and syslogd).

Later the regression was fixed but the feature remained undocumented.
This change documents it.

MFC after:	1 week
2023-07-03 19:46:40 +07:00
Michael Tuexen
2176c9ab71 dtrace: improve siftr probe
Improve consistency of the field names with tcpsinfo_t:
* Use mss instead of max_seg_size.
* Use lport and rport instead of tcp_localport and tcp_foreignport.

Use t_flags instead of flags to improve consistency with t_flags2.

Add laddr and raddr, since the addresses were missing when compared
to the output of siftr.

Reviewed by:		cc
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D40834
2023-07-02 03:08:51 +02:00
Eugene Grosbein
ccc806a049 dumpdev: respect kenv for stable branches
We have somewhat twisted logic to determine actions for dumpdev
considering three sources of information:

* kenv "dumpdev" tunnable supposed to point to specific device;
* /etc/defaults/rc.conf "dumpdev" variable;
* /etc/rc.conf that may be unset or set to "NO", "AUTO" or device name.

For CURRENT without any setting in kenv or /etc/rc.conf
the default is "AUTO". For STABLE branches the default is "NO".

Current implementation breaks for STABLE branches if kenv points
to specific device but /etc/rc.conf does not set "dumpdev" at all.

Let us fix it commenting out "dumpdev" in /etc/defaults/rc.conf
for STABLE branches and making the code to consult kenv
if "dumpdev" is not set elsewhere.

MFC-after:	1 month
2023-07-02 14:54:57 +07:00
Ka Ho Ng
005aa1743b modules: bzero the modspecific_t
Per https://reviews.llvm.org/D68115, only the first field is
zero-initialized, meanwhile other fields are undef.

The pattern can be observed on clang as well, that when
-ftrivial-auto-var-init=pattern is specified 0xaa is filled for
non-active fields, otherwise they are zero-initialized.
Technically both are acceptable when using clang. However it
would be good to simply bzero the modspecific_t in such case to
be strict to the standard.

MFC with:	2cab2d43b8
MFC after:	1 day
Sponsored by:	Juniper Networks, Inc.
Reviewed by:	delphij
Differential Revision:	https://reviews.freebsd.org/D40830
2023-07-01 18:58:46 -04:00
John Baldwin
84deca4d8c libkern: Trim OBE comment from divmoddi routines.
-1/2 is defined to be 0 in modern C.

Reviewed by:	jrtc27
Differential Revision:	https://reviews.freebsd.org/D40833
2023-07-01 14:43:53 -07:00
John Baldwin
df11fb9bf0 divmoddi4: Handle negative remainders.
The sign of the remainder matches the sign of the numerator in C.

Reported by:	jrtc27
Reviewed by:	jrtc27
Differential Revision:	https://reviews.freebsd.org/D40832
2023-07-01 14:43:41 -07:00
Dimitry Andric
5de9420ad5 Create correct engines debug directory after OpenSSL 3.0.9 merge
PR:		271656
Fixes:		b077aed33b ("Merge OpenSSL 3.0.9")
2023-07-01 22:59:23 +02:00
John Baldwin
da3096a92d rdrand_rng: Build with -fPIC on i386 when using GCC.
ld.bfd requires an R_386_PLT32 relocation for calls to ifuncs
rather than R_386_PC32.  (lld permits R_386_PC32.)

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D40811
2023-07-01 12:23:00 -07:00
John Baldwin
cc4f247fb9 sys: Add [u]divmoddi4 intrinsics on i386.
GCC 12 uses these in several places when building the i386 kernel.
They are very similar to [u]divdiv3 except that they return both
the quotient and the remainder.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D40817
2023-07-01 12:22:44 -07:00
John Baldwin
ec41a96daa sys: Switch the kernel's C standard from C99 to GNU99.
This matches the default used in userland, and the kernel already
depends on various GNU extensions to standard C that are supported by
both clang and GCC.

This should be a no-op for clang, but for GCC it enables some GNU
extensions that aren't otherwise enabled.  It also enables GCC for
i386 to avoid the need for a floatundidf intrinsic in libkern.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D40646
2023-07-01 12:21:13 -07:00
Ka Ho Ng
2cab2d43b8 syscalls: fix modspecific_t stack content leak
Zero-initialize the whole modspecific_t so that there would
not be kernel stack content leak in the unused part.

Sponsored by:	Juniper Networks, Inc.
MFC after:	1 days
Differential Revision:	https://reviews.freebsd.org/D40815
2023-07-01 14:38:11 -04:00
Stéphane Rochoy
f03a7e5276 nctgpio: Populate the cache earlier
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:54 -06:00