8 Commits
Author SHA1 Message Date
Osvaldo Janeri Filho 06abe08de4 pam_exec: fix the stderr close test and avoid a double close
The cleanup tested cherr[0] when closing cherr[1].  The parent also closed
chin[0]/chout[1]/cherr[1] after pdfork() without clearing them, so the out:
cleanup path closed them again.  Clear each fd after closing and test the right
one.

Reviewed by:	des, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D60924
2026-10-20 22:05:31 +00:00
Osvaldo Janeri Filho 9ab2bf0f42 inetd: use snprintf() in inetd_setproctitle()
inetd_setproctitle() formats se_service (the service name taken verbatim
from inetd.conf) and the peer address into an 80-byte buffer with
sprintf(). A long service name can overflow it. Bound both calls with
snprintf().

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D60879
2026-10-20 22:04:31 +00:00
Osvaldo Janeri Filho 2d6f961164 ssh: use defaultkey sentinel for ML-DSA-44 default host key
servconf_add_hostkey() compares its file argument to defaultkey by
pointer to skip an unreadable default key; the ML-DSA-44 entry passed
the "[default]" literal, so the skip (and the "No host key files found"
fallback) never applied to it.

MFC after:	1 week
Reviewed by:	emaste
Fixes: bb5c77e9d2 ("OpenSSH: Update to 10.4p1")
Differential Revision:	https://reviews.freebsd.org/D60922
2026-10-20 16:53:25 -04:00
Osvaldo Janeri Filho 5ce0ab7355 bhyve: fix integer overflow in qXfer packet parser
doff + dlen overflows unsigned int when both values are close to UINT_MAX,
causing the wrong branch to execute and passing an unbounded length to
append_binary_data().  Rewrite the comparison to avoid the addition.

Reviewed by:	markj
Fixes:		f81cdf24ba ("bhyve: Add support for XML register definitions")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D60847
2026-10-19 18:53:53 +00:00
Osvaldo Janeri Filho 911fcebfc7 hwpmc: return errors from PMC_OP_PMCGETMSR
pcd_get_msr() returns a positive errno, but only a negative value was
treated as a failure, so errors were reported as success.

Signed-off-by:	Osvaldo Janeri Filho <[email protected]>
Reviewed by:	mhorne
MFC after:	3 days
Sponsored by:	AMD
Pull Request:	https://github.com/freebsd/freebsd-src/pull/2461
2026-10-08 11:57:40 -03:00
Osvaldo Janeri Filho ca9c571801 libpmc: fix the family check for the AMD DF event encoding
The check compares cpu_family with decimal 19 instead of 0x19, so
Families 17h and 19h get the Family 1Ah DF encoding.

Signed-off-by:	Osvaldo Janeri Filho <[email protected]>
Reviewed by:	mhorne
Fixes:		00c0a1f0bf ("hwpmc: Fix PMC flags for AMD Zen cores")
MFC after:	3 days
Sponsored by:	AMD
Pull Request:	https://github.com/freebsd/freebsd-src/pull/2461
2026-10-08 11:57:35 -03:00
Osvaldo Janeri Filho 10409ee40b pcib: Only apply ARI translation to a bridge's own secondary bus
ARI changes RID interpretation only for the device on a downstream
port's secondary bus.  pcib_xlate_ari() applied that translation to
every config access through an ARI-enabled bridge, including cycles
forwarded to a subordinate bus.

A non-zero slot on a subordinate bus then panics an INVARIANTS kernel
and is misrouted otherwise.  Translate only when the access targets
this bridge's secondary bus.

Reviewed by:	kib, jhb
Fixes:		55d3ea1731 ("Add support for PCIe ARI")
Sponsored by:	AMD
Differential Revision:	https://reviews.freebsd.org/D60033
2026-09-30 11:04:08 -04:00
Osvaldo Janeri Filho 8a0cab240f hwpmc/amd: replace static pmcdesc[] and pc_amdpmcs[] with dynamic allocation
AMD_NPMCS_MAX = 342 (16 core + 6 L3 + 64 DF + 256 UMC). On a Zen 4
EPYC 9654 with 6 core, 6 L3, 16 DF, and 4 UMC counters, only 32
descriptors are needed; the static arrays over-allocate by ~10x.

Replace both amd_pmcdesc[AMD_NPMCS_MAX] and per-CPU pc_amdpmcs[AMD_NPMCS_MAX]
with mallocarray() sized to the actual registered PMC count:
  - amd_pmcdesc: allocated in pmc_amd_initialize()
  - pc_amdpmcs:  allocated per-CPU in amd_pcpu_init(), freed in fini()

Normalize amd_l3_npmcs and amd_df_npmcs against the AMDID2_PTSCEL2I
and AMDID2_PNXC feature bits before computing npmcs_total, so that
allocation, registration, and amd_get_msr() row offsets are all derived
from the same values.  Previously the ternary in npmcs_total excluded
L3/DF from the allocation while the globals retained their defaults,
causing amd_get_msr() to miscompute DF row offsets when L3 is absent.

amd_umc_npmcs comes from CPUID Fn8000_0022h EBX[23:16] (NumUMCCounters)
and is zero when the leaf is absent, so no additional feature flag is
needed.  See AMD64 APM Vol.3 Appendix E.

Fix three error-path memory leaks: amd_hwcheck() failure, goto error,
and finalize.  Reset amd_npmcs = 0 on the error path.

Tested on AMD EPYC 9654 (Zen 4, Family 19h Model 11h, 192 threads).
Full PMC test suite (IBS/UMCDF/PMC/L3/DF/TSC): 0 failures.

Signed-off-by: Osvaldo Janeri Filho <[email protected]>
Reviewed by:	mhorne
MFC after:	1 week
Sponsored by:	AMD
Pull Request:	https://github.com/freebsd/freebsd-src/pull/2415
2026-09-21 19:49:42 -03:00