Merge branch 'freebsd/current/main' into hardened/current/master

This commit is contained in:
HardenedBSD Sync Services 2024-11-04 12:01:25 -07:00
commit d120f9f918
No known key found for this signature in database
33 changed files with 301 additions and 97 deletions

View File

@ -51,6 +51,9 @@
# xargs -n1 | sort | uniq -d;
# done
# 20241104: remove the outdated c2x.7 symlink in favor of c23.7
OLD_FILES+=usr/share/man/man7/c2x.7.gz
# 20241023: new clang import which bumps version from 18 to 19
OLD_FILES+=usr/lib/clang/18/include/__clang_cuda_builtin_vars.h
OLD_FILES+=usr/lib/clang/18/include/__clang_cuda_cmath.h

View File

@ -42,7 +42,8 @@ MLINKS+= c.7 c95.7
MLINKS+= c.7 c99.7
MLINKS+= c.7 c11.7
MLINKS+= c.7 c17.7
MLINKS+= c.7 c2x.7
MLINKS+= c.7 c23.7
MLINKS+= c.7 c2y.7
.if ${MK_INET} != "no"
MAN+= networking.7

View File

@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd April 20, 2021
.Dd November 4, 2024
.Dt C 7
.Os
.Sh NAME
@ -34,7 +34,8 @@
.Nm c99 ,
.Nm c11 ,
.Nm c17 ,
.Nm c2x
.Nm c23 ,
.Nm c2y
.Nd The C programming language
.Sh DESCRIPTION
C is a general purpose programming language, which has a strong connection
@ -112,9 +113,12 @@ development of the language did not stop.
.Pp
The ISO C standard was later extended with an amendment as
ISO/IEC 9899/AMD1 in 1995.
This contained, for example, the wide-character support in <wchar.h> and
<wctype.h>, and also restricted character set support via diagraphs and
<iso646.h>.
This contained, for example, the wide-character support in
.In wchar.h
and
.In wctype.h ,
and also restricted character set support via diagraphs and
.In iso646.h .
This amendment is usually referred to as C95.
Two technical corrigenda were also published: Technical Corrigendum 1 as
ISO/IEC 9899/COR1 in 1994 and Technical Corrigendum 2 as ISO/IEC 9899/COR2
@ -130,18 +134,23 @@ The improvements include (but are not limited to) the following:
.Bl -bullet -offset indent
.It
digraphs, trigraphs, and alternative spellings for the operators that
use non-ISO646 characters in <iso646.h>
use non-ISO646 characters in
.In iso646.h
.It
extended multibyte and wide character library support in <wchar.h> and
<wctype.h>
extended multibyte and wide character library support in
.In wchar.h
and
.In wctype.h
.It
variable length arrays
.It
flexible array members
.It
complex (and imaginary) number arithmetic support in <complex.h>
complex (and imaginary) number arithmetic support in
.In complex.h
.It
type-generic math macros in <tgmath.h>
type-generic math macros in
.In tgmath.h
.It
the long long int type and library functions
.It
@ -157,15 +166,24 @@ BCPL style single-line comments
.It
allow mixed declarations and code
.It
the vscanf family of functions in <stdio.h> and <wchar.h>
the
.Fn vscanf
family of functions in
.In stdio.h
and
.In wchar.h
.It
allow trailing comma in enum declaration
.It
inline functions
.It
the snprintf family of functions in <stdio.h>
the
.Fn snprintf
family of functions in
.In stdio.h
.It
boolean type and macros in <stdbool.h>
boolean type and macros in
.In stdbool.h
.It
empty macro arguments
.It
@ -173,7 +191,8 @@ _Pragma preprocessing operator
.It
__func__ predefined identifier
.It
va_copy macro in <stdarg.h>
va_copy macro in
.In stdarg.h
.It
additional strftime conversion specifiers
.El
@ -185,24 +204,34 @@ and ISO/IEC 9899:1999/COR3:2007.
The improvements include (but are not limited to) the following:
.Bl -bullet -offset indent
.It
support for multiple threads of execution and atomic operations in <threads.h>
and <stdatomic.h>
support for multiple threads of execution and atomic operations in
.In threads.h
and
.In stdatomic.h
.It
additional floating-point characteristic macros in <float.h>
additional floating-point characteristic macros in
.In float.h
.It
querying and specifying alignment of objects in <stdalign.h> and <stdlib.h>
querying and specifying alignment of objects in
.In stdalign.h
and
.In stdlib.h
.It
Unicode character types and functions in <uchar.h>
Unicode character types and functions in
.In uchar.h
.It
type-generic expressions
.It
static assertions in <assert.h>
static assertions in
.In assert.h
.It
anonymous structures and unions
.It
remove the gets function from <stdio.h>
remove the gets function from
.In stdio.h
.It
add the aligned_alloc, at_quick_exit, and quick_exit functions in <stdlib.h>
add the aligned_alloc, at_quick_exit, and quick_exit functions in
.In stdlib.h
.El
.Pp
C11 was later superseded by ISO/IEC 9899:2018, also known as C17 which was
@ -211,17 +240,154 @@ It incorporates the Technical Corrigendum 1 (ISO/IEC 9899:2011/COR1:2012)
which was published in 2012.
It addressed defects and deficiencies in C11 without introducing new features,
only corrections and clarifications.
Since there were no major changes in C17, the current standard for
Programming Language C, is still considered C11 \(em ISO/IEC 9899:2011, published
2011-12-08.
.Pp
The next standard, the fifth, is currently referred to as C2x and is scheduled
to be adopted by the end of 2021, with a publication date of 2022.
When published, it will cancel and replace the fourth edition, ISO/IEC
9899:2018.
C23, formally ISO/IEC 9899:2024, is the current standard with significant
updates that supersede C17 (ISO/IEC 9899:2018).
The standardization effort began in 2016, informally as C2x, with the first
WG14 meeting in 2019, and was officially published on October 31, 2024.
C23 was originally anticipated for an earlier release, but the timeline was
extended due to COVID-19 pandemic.
With C23, the value of __STDC_VERSION__ has been updated from 201710L to
202311L.
Key changes include (but are not limited to) the following:
.Bl -bullet -offset indent
.It
Add null pointer type nullptr_t and the nullptr keyword
.It
Add constexpr keyword as a storage-class specifier for objects
.It
Redefine the usage of the auto keyword to support type inference while also
retaining its previous functionality as a storage-class specifier when used
with a type
.It
Add %b binary conversion specifier to the
.Fn printf
and
.Fn scanf
function families
.It
Add binary conversion support (0b and 0B) to the
.Fn strtol
and
.Fn wcstol
function families
.It
Add the #embed directive for binary resource inclusion and __has_embed to
check resource availability with preprocessor directives
.It
Add the #warning directive for diagnostics
.It
Add the #elifdef and #elifndef directives
.It
Add the u8 prefix for character literals to represent UTF-8 encoding,
compatible with C++17
.It
Add the char8_t type for UTF-8 encoded data and update the types of u8
character constants and string literals to char8_t
.It
Add functions
.Fn mbrtoc8
and
.Fn c8rtomb
to convert between narrow multibyte
characters and UTF-8 encoding
.It
Define all char16_t strings and literals as UTF-16 encoded and char32_t
strings and literals as UTF-32 encoded unless specified otherwise
.It
Allow storage-class specifiers within compound literals
.It
Support the latest IEEE 754 standard, ISO/IEC 60559:2020, with binary and
(optional) decimal floating-point arithmetic
.It
Add single-argument _Static_assert for compatibility with C++17
.It
Add _Decimal32, _Decimal64, _Decimal128 keywords for (optional) decimal
floating-point arithmetic
.It
Add digit separator ' (the single quote character) for literals
.It
Enable specification of the underlying type of an enum
.It
Standardize the
.Fn typeof
operator
.It
Add
.Fn memset_explicit
in
.In string.h
to securely erase sensitive data
regardless of optimizations
.It
Add
.Fn memccpy
in
.In string.h
for efficient string concatenation
.It
Add
.Fn memalignment
in
.In stdlib.h
to determine pointer alignment
.It
Add
.Fn strdup
and
.Fn strndup
in
.In string.h
to allocate string copies
.It
Introduce bit utility functions, macros, and types in the new header
.In stdbit.h
.It
Add
.Fn timegm
in
.In time.h
for converting time structures to calendar time
values
.It
Add __has_include for header availability checking via preprocessor
directives
.It
Add __has_c_attribute to check attribute availability via preprocessor
directives
.It
Add _BitInt(N) and unsigned _BitInt(N) for bit-precise integers, and
BITINT_MAXWIDTH for maximum bit width
.It
Elevate true and false to proper keywords (previously macros from
.In stdbool.h )
.It
Add keywords alignas, alignof, bool, static_assert, thread_local; previously
defined keywords remain available as alternative spellings
.It
Enable zero initialization with {} (including initialization of VLAs)
.It
Introduce C++11 style attributes using [[]], with adding [[deprecated]],
[[fallthrough]], [[maybe_unused]], [[nodiscard]], and [[noreturn]]
.It
Deprecate _Noreturn, noreturn, header
.In stdnoreturn.h
features introduced
in C11
.It
Remove trigraph support
.It
Remove K&R function definitions and declarations
.It
Remove non-two's-complement representations for signed integers
.El
.Pp
Some useful features have been provided as extensions by some compilers, but
they cannot be considered as standard features.
The next version of the C Standard, informally named C2y, is anticipated
to release within the next six years, targeting 2030 at the latest.
A charter for C2y is still being drafted and discussed, with several
papers under debate from the January 2024 meeting in Strasbourg, France
indicating that this new version may address long-standing requests and
deficiencies noted by the C community, while preserving its core strengths.
.Pp
ISO/IEC JTC1/SC22/WG14 committee is responsible for the ISO/IEC 9899,
C Standard.
@ -349,6 +515,11 @@ C Standard.
.%A ISO/IEC
.%T 9899:2018 (aka C17)
.Re
.Pp
.Rs
.%A ISO/IEC
.%T 9899:2024 (aka C23)
.Re
.Sh HISTORY
This manual page first appeared in
.Fx 9.0 .
@ -356,8 +527,6 @@ This manual page first appeared in
.An -nosplit
This manual page was originally written by
.An Gabor Kovesdan Aq Mt gabor@FreeBSD.org .
It was updated for
.Fx 14.0
by
It was updated by
.An Faraz Vahedi Aq Mt kfv@kfv.io
with information about more recent C standards.

View File

@ -40,36 +40,36 @@
#include "amdvi_priv.h"
#include "ivhd_if.h"
struct amdiommu_softc {
struct amdviiommu_softc {
struct resource *event_res; /* Event interrupt resource. */
void *event_tag; /* Event interrupt tag. */
int event_rid;
};
static int amdiommu_probe(device_t);
static int amdiommu_attach(device_t);
static int amdiommu_detach(device_t);
static int amdviiommu_probe(device_t);
static int amdviiommu_attach(device_t);
static int amdviiommu_detach(device_t);
static int ivhd_setup_intr(device_t, driver_intr_t, void *,
const char *);
static int ivhd_teardown_intr(device_t);
static device_method_t amdiommu_methods[] = {
static device_method_t amdviiommu_methods[] = {
/* device interface */
DEVMETHOD(device_probe, amdiommu_probe),
DEVMETHOD(device_attach, amdiommu_attach),
DEVMETHOD(device_detach, amdiommu_detach),
DEVMETHOD(device_probe, amdviiommu_probe),
DEVMETHOD(device_attach, amdviiommu_attach),
DEVMETHOD(device_detach, amdviiommu_detach),
DEVMETHOD(ivhd_setup_intr, ivhd_setup_intr),
DEVMETHOD(ivhd_teardown_intr, ivhd_teardown_intr),
DEVMETHOD_END
};
static driver_t amdiommu_driver = {
"amdiommu",
amdiommu_methods,
sizeof(struct amdiommu_softc),
static driver_t amdviiommu_driver = {
"amdviiommu",
amdviiommu_methods,
sizeof(struct amdviiommu_softc),
};
static int
amdiommu_probe(device_t dev)
amdviiommu_probe(device_t dev)
{
int error;
int capoff;
@ -99,7 +99,7 @@ amdiommu_probe(device_t dev)
}
static int
amdiommu_attach(device_t dev)
amdviiommu_attach(device_t dev)
{
device_set_desc(dev, "AMD-Vi/IOMMU PCI function");
@ -107,7 +107,7 @@ amdiommu_attach(device_t dev)
}
static int
amdiommu_detach(device_t dev)
amdviiommu_detach(device_t dev)
{
return (0);
@ -117,7 +117,7 @@ static int
ivhd_setup_intr(device_t dev, driver_intr_t handler, void *arg,
const char *desc)
{
struct amdiommu_softc *sc;
struct amdviiommu_softc *sc;
int error, msicnt;
sc = device_get_softc(dev);
@ -158,7 +158,7 @@ fail:
static int
ivhd_teardown_intr(device_t dev)
{
struct amdiommu_softc *sc;
struct amdviiommu_softc *sc;
sc = device_get_softc(dev);
@ -176,5 +176,5 @@ ivhd_teardown_intr(device_t dev)
}
/* This driver has to be loaded before ivhd */
DRIVER_MODULE(amdiommu, pci, amdiommu_driver, 0, 0);
MODULE_DEPEND(amdiommu, pci, 1, 1, 1);
DRIVER_MODULE(amdviiommu, pci, amdviiommu_driver, 0, 0);
MODULE_DEPEND(amdviiommu, pci, 1, 1, 1);

View File

@ -40,6 +40,9 @@
#ifndef _ICE_LIB_H_
#define _ICE_LIB_H_
/* include kernel options first */
#include "ice_opts.h"
#include <sys/types.h>
#include <sys/bus.h>
#include <sys/rman.h>

View File

@ -68,14 +68,6 @@ CTASSERT(ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE >= RSS_KEYSIZE);
#define RSS_HASHTYPE_RSS_UDP_IPV6 (1 << 9) /* IPv6 UDP 4-tuple */
#define RSS_HASHTYPE_RSS_UDP_IPV6_EX (1 << 10) /* IPv6 UDP 4-tuple + ext hdrs */
#define ICE_DEFAULT_RSS_HASH_CONFIG \
((u_int)(RSS_HASHTYPE_RSS_IPV4 | \
RSS_HASHTYPE_RSS_TCP_IPV4 | \
RSS_HASHTYPE_RSS_UDP_IPV4 | \
RSS_HASHTYPE_RSS_IPV6 | \
RSS_HASHTYPE_RSS_TCP_IPV6 | \
RSS_HASHTYPE_RSS_UDP_IPV6))
#define rss_getkey(key) ice_get_default_rss_key(key)
#define rss_getnumbuckets() (mp_ncpus)
#define rss_get_indirection_to_bucket(index) (index)
@ -113,4 +105,12 @@ rss_hash2bucket(uint32_t hash_val, uint32_t hash_type, uint32_t *bucket_id)
#endif /* !RSS */
#define ICE_DEFAULT_RSS_HASH_CONFIG \
((u_int)(RSS_HASHTYPE_RSS_IPV4 | \
RSS_HASHTYPE_RSS_TCP_IPV4 | \
RSS_HASHTYPE_RSS_UDP_IPV4 | \
RSS_HASHTYPE_RSS_IPV6 | \
RSS_HASHTYPE_RSS_TCP_IPV6 | \
RSS_HASHTYPE_RSS_UDP_IPV6))
#endif /* _ICE_COMMON_COMPAT_H_ */

View File

@ -2225,16 +2225,14 @@ void
crcopy(struct ucred *dest, struct ucred *src)
{
/*
* Ideally, 'cr_ngroups' should be moved out of 'struct ucred''s bcopied
* area, but this would break the ABI, so is deferred until there is
* a compelling need to change it.
*/
bcopy(&src->cr_startcopy, &dest->cr_startcopy,
(unsigned)((caddr_t)&src->cr_endcopy -
(caddr_t)&src->cr_startcopy));
/*
* Avoids an assertion in crsetgroups() -> crextend(). Ideally,
* 'cr_ngroups' should be moved out of 'struct ucred''s bcopied area,
* but this would break the ABI, so is deferred until there is a real
* need to change the ABI.
*/
dest->cr_ngroups = 0;
dest->cr_flags = src->cr_flags;
crsetgroups(dest, src->cr_ngroups, src->cr_groups);
uihold(dest->cr_uidinfo);
@ -2483,6 +2481,13 @@ crsetgroups(struct ucred *cr, int ngrp, const gid_t *groups)
if (ngrp > ngroups_max + 1)
ngrp = ngroups_max + 1;
/*
* crextend() asserts that groups are not set, as it may allocate a new
* backing storage without copying the content of the old one. Since we
* are going to install a completely new set anyway, signal that we
* consider the old ones thrown away.
*/
cr->cr_ngroups = 0;
crextend(cr, ngrp);
crsetgroups_internal(cr, ngrp, groups);
groups_normalize(&cr->cr_ngroups, cr->cr_groups);

View File

@ -5033,6 +5033,7 @@ sotoxsocket(struct socket *so, struct xsocket *xso)
xso->so_uid = so->so_cred->cr_uid;
xso->so_pgid = so->so_sigio ? so->so_sigio->sio_pgid : 0;
SOCK_LOCK(so);
xso->so_fibnum = so->so_fibnum;
if (SOLISTENING(so)) {
xso->so_qlen = so->sol_qlen;
xso->so_incqlen = so->sol_incqlen;

View File

@ -110,7 +110,7 @@ SRCS+= ept.c \
# amd-specific files
.PATH: ${SRCTOP}/sys/amd64/vmm/amd
SRCS+= vmcb.c \
amdiommu.c \
amdviiommu.c \
ivhd_if.c \
ivhd_if.h \
svm.c \

View File

@ -576,8 +576,10 @@ static bool
pf_is_loopback(sa_family_t af, struct pf_addr *addr)
{
switch (af) {
#ifdef INET
case AF_INET:
return IN_LOOPBACK(ntohl(addr->v4.s_addr));
#endif
case AF_INET6:
return IN6_IS_ADDR_LOOPBACK(&addr->v6);
default:

View File

@ -2224,6 +2224,7 @@ pf_scrub(struct pf_pdesc *pd)
}
/* random-id, but not for fragments */
#ifdef INET
if (pd->af == AF_INET &&
pd->act.flags & PFSTATE_RANDOMID && !(h->ip_off & ~htons(IP_DF))) {
uint16_t ip_id = h->ip_id;
@ -2231,5 +2232,6 @@ pf_scrub(struct pf_pdesc *pd)
ip_fillid(h);
h->ip_sum = pf_cksum_fixup(h->ip_sum, ip_id, h->ip_id, 0);
}
#endif
}
#endif

View File

@ -615,7 +615,8 @@ struct xsocket {
uint32_t so_qlimit;
pid_t so_pgid;
uid_t so_uid;
int32_t so_spare32[8];
int32_t so_fibnum;
int32_t so_spare32[7];
int16_t so_type;
int16_t so_options;
int16_t so_linger;

View File

@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd July 9, 2024
.Dd October 15, 2024
.Dt SOCKSTAT 1
.Os
.Sh NAME
@ -33,7 +33,7 @@
.Nd list open sockets
.Sh SYNOPSIS
.Nm
.Op Fl 46CcIiLlnqSsUuvw
.Op Fl 46CcfIiLlnqSsUuvw
.Op Fl j Ar jail
.Op Fl p Ar ports
.Op Fl P Ar protocols
@ -59,6 +59,8 @@ Display the congestion control module, if applicable.
This is currently only implemented for TCP.
.It Fl c
Show connected sockets.
.It Fl f
Show the FIB number of each socket.
.It Fl I
Show the local address of the socket to which the current socket is spliced, if
any.
@ -228,6 +230,7 @@ $ sockstat -6 -P tcp
.Xr fstat 1 ,
.Xr netstat 1 ,
.Xr procstat 1 ,
.Xr setfib 1 ,
.Xr inet 4 ,
.Xr inet6 4 ,
.Xr protocols 5

View File

@ -82,6 +82,7 @@ static int opt_4; /* Show IPv4 sockets */
static int opt_6; /* Show IPv6 sockets */
static int opt_C; /* Show congestion control */
static int opt_c; /* Show connected sockets */
static int opt_f; /* Show FIB numbers */
static int opt_I; /* Show spliced socket addresses */
static int opt_i; /* Show inp_gencnt */
static int opt_j; /* Show specified jail */
@ -140,6 +141,7 @@ struct sock {
int family;
int proto;
int state;
int fibnum;
const char *protoname;
char stack[TCP_FUNCTION_NAME_LEN_MAX];
char cc[TCP_CA_NAME_MAX];
@ -771,6 +773,7 @@ gather_inet(int proto)
sock->splice_socket = so->so_splice_so;
sock->proto = proto;
sock->inp_gencnt = xip->inp_gencnt;
sock->fibnum = so->so_fibnum;
if (xip->inp_vflag & INP_IPV4) {
sock->family = AF_INET;
sockaddr(&laddr->address, sock->family,
@ -1204,6 +1207,12 @@ displaysock(struct sock *s, int pos)
default:
abort();
}
if (opt_f) {
while (pos < offset)
pos += xprintf(" ");
pos += xprintf("%d", s->fibnum);
offset += 7;
}
if (opt_I) {
if (s->splice_socket != 0) {
struct sock *sp;
@ -1329,6 +1338,9 @@ display(void)
"USER", "COMMAND", "PID", "FD", "PROTO",
opt_w ? 45 : 21, "LOCAL ADDRESS",
opt_w ? 45 : 21, "FOREIGN ADDRESS");
if (opt_f)
/* RT_MAXFIBS is 65535. */
printf(" %-6s", "FIB");
if (opt_I)
printf(" %-*s", opt_w ? 45 : 21, "SPLICE ADDRESS");
if (opt_i)
@ -1453,9 +1465,8 @@ jail_getvnet(int jid)
static void
usage(void)
{
fprintf(stderr,
"usage: sockstat [-46CcIiLlnqSsUuvw] [-j jid] [-p ports] [-P protocols]\n");
exit(1);
errx(1,
"usage: sockstat [-46CcfIiLlnqSsUuvw] [-j jid] [-p ports] [-P protocols]");
}
int
@ -1469,7 +1480,7 @@ main(int argc, char *argv[])
int o, i;
opt_j = -1;
while ((o = getopt(argc, argv, "46CcIij:Llnp:P:qSsUuvw")) != -1)
while ((o = getopt(argc, argv, "46CcfIij:Llnp:P:qSsUuvw")) != -1)
switch (o) {
case '4':
opt_4 = 1;
@ -1483,6 +1494,9 @@ main(int argc, char *argv[])
case 'c':
opt_c = 1;
break;
case 'f':
opt_f = 1;
break;
case 'I':
opt_I = 1;
break;

View File

@ -2,6 +2,6 @@ header,113,11,socket(2),0,Mon Jun 11 10:18:45 2018, + 380 msec
argument,1,0x1c,domain
argument,2,0x2,type
argument,3,0x0,protocol
subject,root,root,wheel,root,wheel,7053,4724,37636,10.0.2.2
subject,0,0,0,0,0,7053,4724,37636,10.0.2.2
return,success,3
trailer,113