Skip to content

Conversation

ceolin
Copy link
Member

@ceolin ceolin commented Feb 29, 2024

Backport of #65546 for v2.7-branch.

Fixes #66775

peter-mitsis and others added 3 commits February 29, 2024 23:20
The Z_DETECT_POINTER_OVERFLOW() macro is intended detect whether
or not a buffer spans a region of memory that goes beyond the
highest possible address (thereby overflowing the pointer).

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This macros needed additional checks before invoking
arch_buffer_validate.

- size can not be less then 0. Some functions invoke this macro
  using signed type which will be promote to unsigned when invoking
  arch_buffer_validate. We need to do an early check.
- We need to check for possible overflow, since a malicious user
  application could use a negative number that would be promoted
  to a big value that would cause a integer overflow when adding it
  to the buffer address, leading to invalid checks.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Since K_SYSCALL_MEMORY can be called with signed/unsigned size types, if
we check if size >= 0, static anlysis will complain about it when
size in unsigned.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
@github-actions github-actions bot added the area: API Changes to public APIs label Feb 29, 2024
@ceolin ceolin requested a review from cfriedt February 29, 2024 23:34
@ceolin ceolin linked an issue Feb 29, 2024 that may be closed by this pull request
@cfriedt cfriedt changed the title [Backport v2.7-branch] backport #65546 [Backport v2.7-branch] backport #65546: userspace: Additional checks in K_SYSCALL_MEMORY Feb 29, 2024
@cfriedt
Copy link
Member

cfriedt commented Mar 1, 2024

Assuming that the doc build failure is unrelated.

@cfriedt cfriedt merged commit e9fcfa1 into zephyrproject-rtos:v2.7-branch Mar 1, 2024
@ceolin ceolin deleted the v2.7-fixes branch September 21, 2024 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Backport v2.7-branch] Failed to backport #65546
4 participants