Commit graph

285156 commits

Author SHA1 Message Date
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
Stéphane Rochoy 350b7c3570 superio+ncthwm: Add hardware monitoring support
Add support for the following chips:
- Nuvoton NCT6779D
- Nuvoton NCT6796D-E

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:53 -06:00
Stéphane Rochoy 8e6ea10c31 superio+nctgpio: Add support for new (weird) chips
Add support for the following chips:
- Nuvoton NCT5585D
- Nuvoton NCT6796D-E
- Nuvoton NCT6779
- Nuvoton NCT6116D
- and Winbond 83627DHG

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:52 -06:00
Stéphane Rochoy 7f8d2ed03b superio+nctgpio: Prepare to support some new (weird) chips
- Increase verbosity to direct i/o code path (iores != 0)
- Fix pin inversion configuration
- Allow forcing the use of indirect access channel via hint.gpio.0.flags=2
- Document the PREFER_INDIRECT_CHANNEL tunable in nctgpio(4)

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:51 -06:00
Stéphane Rochoy a0bcfa7831 superio: Handle conflicting devid via prefer/extid
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:51 -06:00
Stéphane Rochoy c94b4d460e sysctl: Document formats for uint8_t and uint16_t in sysctl(9)
Was missing from c3220d0b6d.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:50 -06:00
Stéphane Rochoy 26a0a4035e superio: Add superio_ldn_read and superio_ldn_write
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:49 -06:00
Stéphane Rochoy 93f899bed5 nctgpio(4): Document supported Nuvoton chips
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:48 -06:00
Stéphane Rochoy 32c3d315ed superio(4): Document supported Nuvoton and Winbond chips
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719
2023-07-01 11:19:48 -06:00
VexedUXR 3bf9e84f08 Stand: Silence undefined symbols check command
No need to print this...

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/786
2023-07-01 11:16:58 -06:00
santhoshkumar-mani d3eb9d3db3 bios: Don't keep sending BIO_FLUSH after first ENOTSUPP.
When a storage device reports that it does not support cache flush, the
GEOM disk layer by default returns ENOTSUPP in response to a BIO_FLUSH
command.

On AWS, local volumes do not advertise themselves as having write-cache
enabled.  When they are selected for L3 on all HDD nodes, the L3
subsystem may inadvertently kick these L3 devices if a BIO_FLUSH command
fails with an ENOTSUPP return code.  The fix is to make GEOM disk return
success (0) when this condition occurs and add a sysctl to make this
error handling config-driven

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/710
2023-07-01 11:14:49 -06:00
Mark O'Donovan 6f9388d505 qlnxe: remove unused variable from ecore_ll2.c
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779
2023-07-01 11:07:00 -06:00
Mark O'Donovan b0d3d44dfe qlnxe: add driver to amd64 NOTES
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779
2023-07-01 11:06:59 -06:00
Mark O'Donovan e4017d9b69 qlnxe: Fix building as in-kernel component
Add some extra files for building the driver as part of the kernel.
Change some #defines to match those used when building as a module.

PR: 268354

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779
2023-07-01 11:06:59 -06:00
Mark O'Donovan dc58675cfb qlnxe: Fix unused but set variable warning
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779
2023-07-01 11:06:58 -06:00
Mark O'Donovan b75c387a66 qlnxe: Remove #ifdef ECORE_PACKAGE
I do not know why this is here but it blocks compilation.
Removing it makes the builtin option the same as the module build

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779
2023-07-01 11:06:57 -06:00
Mark O'Donovan c1be7151d5 qlnxe: Fix too many args in call to internal_ram_wr()
internal_ram_wr() only takes 3 args when ECORE_CONFIG_DIRECT_HWFN
is defined

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779
2023-07-01 11:06:56 -06:00
Mark O'Donovan 99e5ffe1ba qlnxe: Move sriov includes to qlnx_os.c
SRIOV is being enabled in ecore.h but by then
the qlnx_os.h header has been processed and not
included the relevant headers

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779
2023-07-01 11:06:56 -06:00
Mark O'Donovan 134b093699 qlnxe: Remove -Wno-case-qual from module build
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779
2023-07-01 11:06:55 -06:00
Martin Matuska 0a97523d46 zfs: merge openzfs/zfs@009d3288d
Notable upstream pull request merges:
  #14654 Pack our DDT ZAPs a bit denser
  #14979 Again fix race between zil_commit() and zil_suspend()
  #14985 Some ZIO micro-optimizations
  #15000 Fix remount when setting multiple properties
  #15004 ddt_addref: remove unnecessary phys fill when refcount is 0
  #15007 Do not report bytes skipped by scan as issued
  #15023 Enable tuning of ZVOL open timeout value

Obtained from:	OpenZFS
OpenZFS commit:	009d3288de
OpenZFS tag:	zfs-2.2.0-rc1
2023-07-01 15:24:26 +02:00
Michael Tuexen cd9da8d072 siftr: unbreak dtrace support
This patch adds back some fields needed by the siftr probe, which were
removed in
https://cgit.freebsd.org/src/commit/?id=aa61cff4249c92689d7a1f15db49d65d082184cb

With this fix, you can run dtrace scripts again when the siftr
module is loaded. And the siftr probe works again.

Reviewed by:		rscheff
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D40826
2023-07-01 09:50:54 +02:00
Dmitry Chagin f049c92ad6 csu: Add the prologue and epilogue to the _init and _fini on x86_64
Normally, modern unwinders uses Dwarf information to unwind stack,
however in case when the code is not annotated by Dwarf instructions,
unwinders fallbacks to a frame-pointer based algorithm.

That is allows libunwind to unwind stack from global constructors and
destructors. Also it makes gdb happy as it printed nonexistent frame
before.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D40795
2023-07-01 10:52:10 +03:00
Dmitry Chagin 3bdf68086d rtld: Add a stop indicator to rtld_start to satisfy unwinders on x86_64
The right unwinding stop indicator should be CFI-undefined PC.
https://dwarfstd.org/doc/Dwarf3.pdf - page 118:
If a Return Address register is defined in the virtual unwind table,
and its rule is undefined (for example, by DW_CFA_undefined), then
there is no return address and no call address, and the virtual
unwind of stack activations is complete.

That is allows gdb and libunwind successfully stop when unwinding stack
from global constructors and destructors.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D40794
2023-07-01 10:51:35 +03:00
Michael Tuexen f85b82daf1 dtrace: third update to the siftr probe
This adds the changes corresponding to
https://cgit.freebsd.org/src/commit/?id=60167184abd54ca12c6bf7ab60f2a08b41342f84
to the siftr probe.
This concludes the series up updates.

Reviewed by:		rscheff
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D40825
2023-07-01 09:30:34 +02:00