* [DM/PCI] Validate MSI-X table BIR and offset against BAR
BIR and the table offset in the MSI-X capability are controlled by the
device. msix_table_remap() used BIR directly as an index into
pdev->resource[] and never checked the table against the BAR size, so a
malicious device could make the kernel map and write to an arbitrary
physical address during probe.
Reject out-of-range BIR values, unassigned or zero-sized BARs, and
tables that do not fit completely inside the assigned BAR. Also verify
that the requested vector count does not exceed the table size read
from the MSI-X control register.
Fixes#11985
* [DM/PCI] Fix cppcheck warnings in MSI-X code
- Restore the default IRQ only when an MSI descriptor exists, avoiding
a potential NULL pointer dereference in rt_pci_msi_shutdown
- Initialize the error code in msix_setup_msi_descs so that an empty
vector list returns a defined value
is_pte_valid() accepted a GPT entry as long as both LBAs were inside the
disk, so a crafted image could set ending_lba < starting_lba. The size
computed in efi_partition() then underflowed to a huge value and was
registered as the logical partition size.
Reject entries whose end LBA is below the start LBA, and compute the
partition start/size only after the entry passed validation. This avoids
evaluating the underflow at all and reuses the validated start value for
the size calculation.
FixesRT-Thread/rt-thread#11271.
Co-authored-by: DeepSeek 4.1 Flash <noreply@deepseek.com>
Closes#10097.
The coding style only said that comments go above or to the right of the code,
without saying which applies to a macro. The repository already follows a
consistent rule, it just was not written down:
- 135 macro comments in include/ use a trailing /**<
- a further set of function-like macros use a /** block above the definition with
@def
The rule is about how much explanation the macro needs, not about line length.
A single line goes trailing; a paragraph goes above. That distinction matters
because the column-aligned groups of constant macros routinely exceed 80 columns
once the comment is appended - 87 of those 135 lines (64%) are longer than 80
columns, and shortening them would break the alignment that makes them readable.
Both language versions get the same section, with the real examples from
include/klibc/kerrno.h and include/rtdef.h, plus a note that with
MACRO_EXPANSION enabled a trailing /**< follows the expansion site while a block
comment stays with the definition - which is why frequently expanded macros
should use the block form.
sys_getaddrinfo() validated the top-level res buffer, then wrote the
resolved socket address through res->ai_addr, a user-controlled nested
pointer that was never checked. On Smart/MMU builds a user program could
therefore turn getaddrinfo() into an arbitrary kernel write. The hints
fields were also read directly from user memory after the access check,
leaving a TOCTOU window.
Copy res and hints into kernel temporaries with lwp_get_from_user() so
all nested pointers come from one validated snapshot. Write the nested
sockaddr and the outer addrinfo back with lwp_put_to_user(), which
validates the destination range and never dereferences an unchecked user
pointer in kernel context.
Also fix the servname copy check (a size_t result can never be < 0),
allocate the kernel addrinfo with sizeof(*k_hints), and release k_res on
the new error paths.
Co-Authored-By: Claude Code <noreply@anthropic.com>
- register SCMI reset and power-domain drivers during subsystem initialization
- resolve SCMI reset state through the reset-controller provider
- use the parsed DT reset domain ID when querying reset attributes
- retain the SCMI device reference in the reset provider instance
Signed-off-by: GuEe-GUI <2991707448@qq.com>
* lwp: fix pid leak on exec failure before task startup
When msh tries to execute a non-ELF path, lwp_execve() may allocate a PID
before lwp_load() fails. The old error path only dropped the LWP reference,
leaving the PID tree entry pointing to a freed LWP.
In an init-less boot flow, this can poison pid 1 after a failed command from
msh. A later LWP launch may then treat the stale pid 1 entry as a valid parent
LWP, resulting in invalid pgrp/session state and a job-control assertion during
process exit.
Add lwp_pid_rollback() for exec/spawn failures before the process becomes
runnable. Unlike lwp_pid_put(), it always releases the PID lock and does not
enter the "no more pid allocation" state when the PID tree becomes empty.
Use the rollback helper in lwp_execve() failure paths after PID allocation.
Signed-off-by: zhangyang <gaoshanliukou@163.com>
* [drivers][sdio] avoid SDHCI device name stack overflow
rt_sdhci_init_host() allocated a fixed 32-byte buffer for device-derived object names, but sdio_host_set_name() may copy up to RT_NAME_MAX bytes into the output buffer. When RT_NAME_MAX is larger than 32, this can overwrite the stack and corrupt nearby locals.
Size the temporary name buffer with RT_NAME_MAX, force it to be NUL-terminated, and derive the append offset from the actual string length. Also replace the suffix rt_sprintf() calls with bounded rt_snprintf() so timer and workqueue suffixes cannot overflow the buffer when the base name is already close to RT_NAME_MAX.
Signed-off-by: zhangyangysu <zhangyangysu0928@gmail.com>
---------
Signed-off-by: zhangyang <gaoshanliukou@163.com>
Signed-off-by: zhangyangysu <zhangyangysu0928@gmail.com>
Co-authored-by: yang.zhang <zhangyang01@kylinos.cn>
- move syscall implementations from lwp_syscall.c into syscall/
- group memory, file, socket, process, IPC and time syscalls
- add a shared syscall dispatch table and internal header
- register the new directory from the LWP build script
- no functional change
- place the TIOCLINUX case brace on its own line
- use sizeof(tty_ctrl_charset) directly as the memcpy size
- fix the cppcheck sizeofDivisionMemfunc warning
- return zero keyboard modifiers for TIOCLINUX instead of failing
- keep terminal applications that probe console state working
- initialize the TTY window size to 24x80 when none is reported
Validate option headers and declared lengths before walking or returning options. Check minimum value sizes at the MESSAGE_TYPE and REQUESTED_IP call sites and bound parsing by the received packet length.
Fixes: #11913
I no longer have the time or energy to participate in RT-Thread
community work, so I am removing my maintainer information.
Signed-off-by: Yucai Liu <1486344514@qq.com>
- read reg-shift and reg-io-width from the device tree
- select the MMIO access width from reg-io-width
- reject unsupported register widths during early setup
- keep the generic 8250 path for other compatibles
- resolve fops from dfs_file instead of vnode directly
- keep compatibility with both DFSv1 and DFSv2
- validate fops before dereferencing to avoid NULL access
* [net][sal] validate RAW socket protocol
- replace the IPPROTO_RAW-only check with VALID_PROTOCOL()
- allow RAW sockets for protocols such as ICMP
- keep the existing domain and type validation unchanged
* [net][sal] fix clang-format alignment
- align the macro continuation after the RAW protocol check
- no functional change
- UTIME_OMIT means the corresponding timestamp must not be changed
- the inverted condition overwrote mtime and ignored a valid timestamp
- correct the comparison so UTIME_OMIT leaves the attribute untouched
- add RT_LWIP_USING_LOOPBACK as a configurable option
- register lo/lo0 as a netdev and bring the link up
- make loopback the default interface when none is configured
- increase the RAW receive mailbox size for loopback echo
scons --attach prints a check mark / cross emoji as status prefix. On
Windows the standard output encoding follows the locale code page (936/GBK
on a Chinese system), which cannot encode U+2705/U+274C, so Python raises
UnicodeEncodeError and the command aborts:
UnicodeEncodeError: 'gbk' codec can't encode character '\u2705'
File "tools/attachconfig.py", line 18, in GenAttachConfigProject
All three commands go through the same function, so --attach=?,
--attach=<name> and --attach=default were all unusable on such systems.
Replace the emoji with plain ASCII markers and keep the existing ANSI colour
codes, which the other scripts under tools/ already use.
Refs #11906
Increase RT_CPUS_NR from 4 to 8 in the K1 default configuration
and regenerate rtconfig.h.
Add the SpacemiT K1 entry and peripheral support matrix to the
BSP overview.
Verified eight-core boot and root filesystem mounting with the
RISC-V ticket spinlock fix.
Signed-off-by: GuEe-GUI <2991707448@qq.com>
Eight-core boot on SpacemiT K1 could stall with one CPU in the
unlock LR/SC loop, two CPUs allocating tickets, and the remaining
CPUs waiting for the scheduler lock.
Replace LR/SC ticket allocation with amoadd.w.aqrl and release the
lock with a halfword owner update. Order critical-section accesses
after acquiring ownership and before releasing it.
Verified eight-core boot on K1 with temporary diagnostics and
reservation-clearing changes removed.
Signed-off-by: GuEe-GUI <2991707448@qq.com>
* [bsp][esp32] adapt C3/C6 to ESP-IDF v6.1 and bump RISC-V toolchain to gcc 15.2
- Adapt ESP32-C3/C6 BSP to ESP-IDF v6.1; bump RISC-V toolchain to gcc 15.2
- C6: re-enable SPI with board-local drv_spi.c; add devices.spi to CI
attachconfig; drop shared drv_spi.c spi_command_t hack
- C6: fix ADC oneshot multi-channel unit handle and mutex
- C3: fix portTRY_ENTER_CRITICAL_SAFE expansion in portmacro.h
- Compat with RT-Thread-packages/esp-idf rtt-dev used by CI: map
SYSTIMER_* to SYSTIMER_LL_* (C3 and C6 board.c), accept uart_periph.h
from hal/ or soc/
- Fix clang-format and cppcheck issues in the compat code
Signed-off-by: seteiro <chenmoushun@163.com>
Co-Authored-By: Grok <seteiro@mail.grokbot.com>
* ci: retrigger after esp-idf#18 merged
* bsp: ESP: fix C6 ADC for IDF 6.1 (adc_ll bus clock)
Replace removed PERIPH_SARADC_MODULE with adc_ll_enable_bus_clock /
adc_ll_reset_register when ESP_IDF_VERSION >= 6.0.0.
---------
Signed-off-by: seteiro <chenmoushun@163.com>
Co-authored-by: Grok <seteiro@mail.grokbot.com>
rt_console_set_device() is typically called in rt_hw_board_init() right
after rt_components_board_init(). null was INIT_DEVICE (level 3), so it
was not registered yet and could not be RT_CONSOLE_DEVICE_NAME.
Raise to INIT_BOARD_EXPORT; null is a pure software sink with no HW deps.
Co-Authored-By: Grok <seteiro@mail.grokbot.com>