Print the file and line number of the caller where the assert fired.
Use _thread_exitf() directly for this.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
In-tree Clang is unaware of the N2680 fixed-width modifier `w` and emits
a warning when used.
PR: 299631
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D60939
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
libpfctl sends a table definition in chunks of 256 addresses, each as
its own PFNL_CMD_INA_DEFINE. The kernel treated every chunk as a new
definition and replaced the shadow table, so only the last chunk
survived.
Mark the chunks after the first with PF_ID_APPEND and have the kernel
add them to the shadow table in progress. A request without the
attribute still replaces the shadow; one with it and no definition in
progress fails with EINVAL. Old kernels ignore the attribute, so both
halves are needed; the ioctl sends all addresses at once and is not
affected. Mask the flags userland passes to PFR_FLAG_ALLMASK, as
PFR_FLAG_APPEND is kernel-internal.
Add a test that defines a table of 1,000 addresses, also in an anchor.
Reviewed by: kp
Fixes: 219ce30638 ("pf: convert DIOCRINADEFINE to netlink")
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60876
Manual pages have an optional architecture specifier after the section
number in the document title macro. I highly recommend using it when
expedient, the extra information is available programmatically and it
uses no extra lines in the rendered page.
MFC after: No, pmc.perf.3 is not MFCing
Reviewed by: Anderson Nascimento <[email protected]>
Differential Revision: https://reviews.freebsd.org/D60714
thr_try_gc unlock and lock again to make sure the lock order. However,
there is no reason for such roundtrip if the caller holds the correct
oder. As a result, we create a new helper function to add the thread
to gc list without unlock + lock and wire the join_common to this new helper.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60717
- Update the copyright dates and add "Joao Bonifacio" to the top of
`sbuf_core_test.c`.
- Use `SPDX-Identifier` instead of longform copyright tort.
- Remove `sbuf_test_common.h`: the header was originally added to help
with the 10.x/11.x split, but is no longer needed given that those
releases have been EOLed for multiple years now.
MFC after: 1 week
This change adds additional explicit test coverage for the following
sbuf(3) APIs:
- sbuf_clear_flags
- sbuf_get_flags
- sbuf_set_flags
While here, add a missing `sbuf_delete` to `sbuf_drain_ret0_test`: while
it isn't strictly required (the library's state is cleaned up shortly
after the test process ends), tools such as Coverity and LSAN flag
issues with leaked memory. Adding the sbuf_delete(3) call to the test
quells that issue.
MFC after: 1 week
Reviewed-by: ngie
Pull-Request: https://github.com/freebsd/freebsd-src/pull/2367
ghpr doesn't seem to do a `git status` prior to allowing someone to push
changes (bug pending). Revert the change so the properly tested one can
be pushed into the tree.
This reverts commit 760efcc775.
This change adds additional explicit test coverage for the following
sbuf(3) APIs:
- sbuf_clear_flags
- sbuf_get_flags
- sbuf_set_flags
While here, add a missing `sbuf_delete` to `sbuf_drain_ret0_test`: while
it isn't strictly required (the library's state is cleaned up shortly
after the test process ends), tools such as Coverity and LSAN flag
issues with leaked memory. Adding the sbuf_delete(3) call to the test
quells that issue.
MFC after: 1 week
Reviewed-by: ngie
Pull-Request: https://github.com/freebsd/freebsd-src/pull/2367
The while loop previous can only be break when ret == ETIMEDOUT. They
never produce EBUSY. Remove the deadcode here.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60711
LIBPTHREAD_QUEUE_FIFO is used in bitwise offset, we set the limit to
0~31 so that it won't cause undefined behavior. Also, create a new
helper function to do getenv++strtol directly and check the boundary of
the valid value.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60487
Fix all pointer-sign warnings generated when compiling libifconfig.
A couple more snuck in while the previous batch of fixes was landing.
Fixes: 963f1a5455 ("ifconfig: add CMIS support for 400GbE optics")
Reviewed by: kevans
Approved by: kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D60573
The kernel sends PF_STP_MAX_WIN and PF_STP_MSS for both peers of a
state, but struct pfctl_state_peer has no fields for them and libpfctl
dropped them. Add the fields and parse the attributes.
Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60544
The IRPERF MSR counter (0xc00000e9) exposes an instructions-retired count
when read. Its support is advertised through CPUID leaf 0x80000008 EBX bit 1.
If this bit is set, the CPU supports the IRPERF MSR. For it to be used
by the system, bit 30 of the HWCR MSR (0xC0010015) needs to be enabled.
This patch checks for availability of the feature and enables the bit. If
the feature is available, the hwpmc PERF class detects its presence and
registers a third PERF MSR counter that allows hwpmc users to measure
instructions retired using IRPERF. This is AMD-only, as Intel does not
support IRPERF.
Due to erratum #1054 affecting AMD Zen 1 before model 30h, IRPERF is only
enabled for AMD Zen 1 model 30h onwards and later microarchitectures. This
commit also implements a validation step to make sure the IRPERF counter
is actually incrementing; otherwise, the feature is not enabled. This
guarantees it is working as expected before being made available to the
system and users.
To support this, the perf_pmcdesc[] structure changed from being
statically initialized with 2 entries (MPERF/APERF) to being populated
dynamically. If both MPERF/APERF and IRPERF are supported, the structure
will contain three entries: MPERF, APERF, and IRPERF. Each entry now also
carries its own MSR address and PMC event, so perf_read_pmc() reads the
MSR to use from the matching perf_pmcdesc[] entry at runtime instead of
switching over a fixed set of row indices.
Definitions for the features available on the HWCR MSR did not previously
exist. This commit adds macros for those features, including
HWCR_IRPERFEN. The MSR definition for MSR_IRPERF was also missing and has
now been added.
This commit also updates the manual page accordingly.
Signed-off-by: Anderson Nascimento <[email protected]>
Reviewed by: mhorne, adrian
Sponsored by: AMD
Differential Revision: https://reviews.freebsd.org/D59554
The counts of a table definition were stored only if the caller's
variables already held a non-zero value, and read uninitialised ones
otherwise. pfctl_ina_define() passes the address of two uninitialised
locals and sums them up.
Reviewed by: kp
Fixes: 219ce30638 ("pf: convert DIOCRINADEFINE to netlink")
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60614
Replace the exclusion list with an allowlist of the architectures
whose libc exports brk/sbrk: amd64, i386, arm and powerpc.
On aarch64, riscv and loongarch libc does not export those symbols
and the test cannot run, so do not build it there. New architectures
now default to not building the test unless brk support is added.
MFC after: 1 week
Signed-off-by: Xiaoqiang Zhao <[email protected]>
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D60357
Like yieldloops, we shoulde be able to set _thr_spinloops to zero.
Originally, it makes us to enformce default spin time even if we try to
disable it. Make MUTEX_ADAPTIVE_SPINS a one time initialization now.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60486
Reword the UL_GETFSIZE and UL_SETFSIZE descriptions to say 512-byte
blocks and make the setter's argument clearer.
While here, improve mdoc markup and pull in other small improvements.
Reviewed by: des
MFC after: 3 days
Obtained from: https://github.com/apple-oss-distributions/libc
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D60467
While testing the bare values happens to work, the intent is to test
for their definition.
Reviewed by: emaste
Fixes: 9a16bd169e ("libsysdecode: support errno and syscalls for arm64 Linux")
Fixes: b69ae1a34c ("libsysdecode: Add preliminary support for decoding Linux syscalls")
Differential Revision: https://reviews.freebsd.org/D60415
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
1. When contester > 2, a release causes kernel set CONTENTION bit but
with no owner. In this case, the userspace should be able to try the
lock instead of fall immediately. We copy this from trylock2.
2. A PI mutex should consult to kernel instead of decided by userspace
itself.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60427
On a 64 byte cache line CPU (amd64), m_owner is contended by all of
the shared processes. However, after finding one winner, mtx is
enqueued, which trigger a cache refresh from other processors. Reorder
mtx so that m_lock and m_qu will not be in the same cache line.
Notice that this doesn't affet arch that expose 128 bytes cache line
line aarch64 or powerpc.
Reviewed by: kib, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60434
counter + 1 > 0 is a undefined behavior and nobody guarantee that it
will be honestly perform by the compiler that counter + 1 will always be
INT_MIN. We switch to INT_MAX check instead to provide a deterministic
result.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60426
eXpat 2.9.0 deprecates XML_GetCurrentLineNumber() in favour of
XML_GetCurrentLineNumber64(). The new function behaves the same
as the old one but is not prone to 32 bit integer wrap-around.
Commit 1a296762b3 made libcasper pass PD_NOWAITPID to pdfork(2).
Kernels predating the flag (15.1 and earlier, since the flag first
ships in 15.2) reject it with EINVAL, which makes cap_init() and every
service fork fail when a newer world runs on an older kernel, for
example in a poudriere jail.
Add casper_pdfork(), which retries without the flag on EINVAL, and use
it at both pdfork(2) call sites. The retry is safe because the kernel
validates pdfork flags before creating a child. On such kernels the
zombie must still be reaped with waitpid(2), as before the flag was
introduced.
The fallback is compiled out once __FreeBSD_version reaches 1700000,
so it disappears from main when stable/16 branches while remaining in
the stable/15 and stable/16 branches that need it.
Reviewed by: kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D60401
Nothing in the tree calls any of the three. Remove them rather than
fix them: pfctl_get_states_h() does the same with the handle that the
caller has. pfctl_free_states(), struct pfctl_states and the list
entry in struct pfctl_state were there for pfctl_get_states() alone,
and go with it.
Reviewed by: kp
Approved by: kp (mentor)
Fixes: 2a478dfc7f ("libpfctl: retrieve family id only once")
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60248
in particular, if the old environment is NULL.
Among making it less surprising for userspace to observe NULL environ,
the change also prevents NULL deref in __rebuild_environ() when
terminating the empty as NULL environment with the NULL pointer.
Reported by: Leo Bicknell <[email protected]>
PR: 298747
Reviewed by: emaste, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59996
The PFNL_CMD_TABLE_TEST_ADDRS reply carries only the match count, so
the per-address feedback from pfr_tst_addrs() is lost:
"pfctl -v -T test" lists nothing and "pfctl -vv -T test" reports
every address as "nomatch".
Return each address, as updated by pfr_tst_addrs(), in a nested
PF_TAS_ADDR attribute, and decode them into the caller's array in
libpfctl. PF_TA_ADDR is not reused: it shares its value with
PF_TAS_ASTATS, which older libpfctl would decode into an
uninitialised target. That target was also read when no reply was
parsed, so the match count could be garbage; initialise it.
Add a regression test.
Reviewed by: kp
Approved by: kp (mentor)
Fixes: 281282e935 ("pf: convert DIOCRTSTADDRS to netlink")
See also: https://redmine.pfsense.org/issues/17135
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60146
The chunked table address functions (set, add, del, clr_astats) add
each chunk's result to the caller's counter without initialising it.
pfctl reuses nadd for the number of tables created, so a replace that
also creates the table is off by one:
pfctl -t foo -T replace 192.0.2.1
reports "2 addresses added".
Zero the counters first, as pfctl_test_addrs() already does. Remove
the workaround for the add case from pfctl (da64f6e047), which is
no longer needed.
Add a regression test.
Reviewed by: kp
Approved by: kp (mentor)
Fixes: 08ed87a4a2 ("pf: convert DIOCRSETADDRS to netlink")
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60174
When setting up an FTP transfer, we need to dereference the cached
connection before returning after a failure.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D60017
When we get a 304 Not Modified response, we need to go through the error
path to properly free any resources we've allocated instead of just
returning NULL directly.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D60016
When processing a redirect, if we get multiple Location headers, we free
the previous one using free(new) instead of fetchFreeURL(new), which
leaks new->doc.
While here, rename new to loc since new is a reserved word in C++.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D60015
If a URL contains credentials, check that neither the user name nor the
password contain control characters which might confuse the server,
especially in the FTP case.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D60008
When reading an FTP or HTTP response, error out if we read 64 kB before
hitting a newline. Otherwise a runaway or malicious server could have
us spinning for quite a while allocating more and more memory before we
gave up or crashed.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D60007