freebsd-src/sys
Olivier Certner afc10f8bba
sys_procctl(): Make it clear that negative commands are invalid
An initial reading of the preamble of sys_procctl() gives the impression
that no test prevents a malicious user from passing a negative commands
index (in 'uap->com'), which is soon used as an index into the static
array procctl_cmds_info[].

However, a closer examination leads to the conclusion that the existing
code is technically correct.  Indeed, the comparison of 'uap->com' to
the nitems() expression, which expands to a ratio of sizeof(), leads to
a conversion of 'uap->com' to an 'unsigned int' as per Usual Arithmetic
Conversions/Integer Promotions applied by '<=', because sizeof() returns
'size_t' values, and we define 'size_t' as an equivalent of 'unsigned
int' (which is not mandated by the standard, the latter allowing, e.g.,
integers of lower ranks).

With this conversion, negative values of 'uap->com' are automatically
ruled-out since they are converted to very big unsigned integers which
are caught by the test.  An analysis of assembly code produced by LLVM
16 on amd64 and practical tests confirm that no exploitation is possible.

However, the guard code as written is misleading to readers and might
trip up static analysis tools.  Make sure that negative values are
explicitly excluded so that it is immediately clear that EINVAL will be
returned in this case.

Build tested with clang 16 and GCC 12.

Approved by:    markj (mentor)
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
2024-04-10 17:15:25 +02:00
..
amd64 NOTES: Move NVMe entries to MI file 2024-04-09 15:02:58 -07:00
arm bcm2838_xhci: add module 2024-04-09 21:11:39 -06:00
arm64 NOTES: Move NVMe entries to MI file 2024-04-09 15:02:58 -07:00
bsm
cam CTL: Drop Format Device and Rigid Disk Geometry mode pages 2024-02-27 13:28:44 -05:00
cddl arm64: Use void pointers for arguments to arm64_get_writable_addr 2024-03-15 10:10:24 -07:00
compat LinuxKPI: Stub sysfs_remove_link in linux/sysfs.h 2024-04-08 09:47:43 +03:00
conf NOTES: Move NVMe entries to MI file 2024-04-09 15:02:58 -07:00
contrib zfs: merge openzfs/zfs@39be46f43 2024-03-30 23:54:24 +01:00
crypto
ddb ddb: Fix format string errors in db_pprint.c 2024-04-03 14:14:13 -04:00
dev pcireg.h: Add AMD IOMMU Base Cap definitions 2024-04-10 08:28:24 +03:00
dts arm/nvidia: Fix DTS build 2024-03-22 07:49:54 +01:00
fs unionfs_lookup(): fix wild accesses to vnode private data 2024-04-09 17:36:59 -05:00
gdb
geom graid: unbreak Promise RAID1 with 4+ providers 2024-02-12 14:33:43 +07:00
gnu
i386 NOTES: Move NVMe entries to MI file 2024-04-09 15:02:58 -07:00
isa new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE 2024-03-13 15:05:54 -07:00
kern sys_procctl(): Make it clear that negative commands are invalid 2024-04-10 17:15:25 +02:00
kgssapi
libkern
modules bcm2838_xhci: add module 2024-04-09 21:11:39 -06:00
net debugnet: Fix logging of frame length 2024-04-09 00:47:10 +08:00
net80211 net80211: Fix two typos in kernel messages 2024-02-19 12:08:07 +01:00
netgraph ng_socket: Treat EEXIST from kern_kldload() as success 2024-04-09 18:04:47 +08:00
netinet tcp: Make tcp_var.h more self-contained 2024-04-10 08:53:49 -04:00
netinet6 icmp: correct the assertion that checks limit + jitter 2024-04-08 16:54:19 -07:00
netipsec ipsec esp: avoid dereferencing freed secasindex 2024-02-26 16:27:46 +02:00
netlink linux: make linux_netlink_p->msg_from_linux be able to fail 2024-03-29 13:35:51 -07:00
netpfil pf: fix reply-to after rdr and dummynet 2024-03-28 17:06:01 +01:00
netsmb
nfs
nfsclient
nfsserver
nlm
ofed sockets: provide correct pr_shutdown for keysock and SDP 2024-01-16 12:02:59 -08:00
opencrypto
powerpc powerpc/booke: Reserve KVA for minidump working area 2024-04-04 19:03:27 -04:00
riscv NOTES: Move NVMe entries to MI file 2024-04-09 15:02:58 -07:00
rpc rpc: use new macros to lock socket buffers 2024-04-09 09:17:19 -07:00
security
sys Revert "unix: new implementation of unix/stream & unix/seqpacket" 2024-04-09 13:15:47 -07:00
teken
tests callout: retire callout_async_drain() 2024-01-24 09:33:27 -08:00
tools libsys: don't try to expose yield 2024-03-07 01:01:36 +00:00
ufs Eliminate unnecessary UFS1 integrity checks. 2024-02-19 16:17:05 -08:00
vm vm_reserv_reclaim_contig: Return NULL not false 2024-04-10 08:50:16 -04:00
x86 new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE 2024-03-13 15:05:54 -07:00
xdr
xen x86/xen: introduce non-hypercall based emergency print 2024-02-22 11:08:03 +01:00
Makefile
README.md

FreeBSD Kernel Source:

This directory contains the source files and build glue that make up the FreeBSD kernel and its modules, including both original and contributed software.

Kernel configuration files are located in the conf/ subdirectory of each architecture. GENERIC is the configuration used in release builds. NOTES contains documentation of all possible entries. LINT is a compile-only configuration used to maximize build coverage and detect regressions.

Documentation:

Source code documentation is maintained in a set of man pages, under section 9. These pages are located in share/man/man9, from the top-level of the src tree. Consult intro(9) for an overview of existing pages.

Some additional high-level documentation of the kernel is maintained in the Architecture Handbook.

Source Roadmap:

Directory Description
amd64 AMD64 (64-bit x86) architecture support
arm 32-bit ARM architecture support
arm64 64-bit ARM (AArch64) architecture support
cam Common Access Method storage subsystem - cam(4) and ctl(4)
cddl CDDL-licensed optional sources such as DTrace
conf kernel build glue
compat Linux compatibility layer, FreeBSD 32-bit compatibility
contrib 3rd-party imported software such as OpenZFS
crypto crypto drivers
ddb interactive kernel debugger - ddb(4)
fs most filesystems, excluding UFS, NFS, and ZFS
dev device drivers and other arch independent code
gdb kernel remote GDB stub - gdb(4)
geom GEOM framework - geom(4)
i386 i386 (32-bit x86) architecture support
kern main part of the kernel
libkern libc-like and other support functions for kernel use
modules kernel module infrastructure
net core networking code
net80211 wireless networking (IEEE 802.11) - net80211(4)
netgraph graph-based networking subsystem - netgraph(4)
netinet IPv4 protocol implementation - inet(4)
netinet6 IPv6 protocol implementation - inet6(4)
netipsec IPsec protocol implementation - ipsec(4)
netpfil packet filters - ipfw(4), pf(4), and ipfilter(4)
opencrypto OpenCrypto framework - crypto(7)
powerpc PowerPC/POWER (32 and 64-bit) architecture support
riscv 64-bit RISC-V architecture support
security security facilities - audit(4) and mac(4)
sys kernel headers
tests kernel unit tests
ufs Unix File System - ffs(7)
vm virtual memory system
x86 code shared by AMD64 and i386 architectures