Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
L
llvm-project
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 17
    • Issues 17
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 7
    • Merge Requests 7
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Morello
  • llvm-project
  • Issues
  • #1

Closed
Open
Opened Oct 28, 2020 by Robert N. M. Watson@rwatsonDeveloper

Small alloca() have unnecessarily padded bounds

Our CheriABI integration test cases for small dynamic stack allocations using alloc() show a minimum bounds of 16 bytes, rather than being byte granularity:

TEST: test_bounds_stack_dynamic_uint8: Check bounds on 8-bit dynamic stack allocation
FAIL: test_bounds_stack_dynamic_uint8: length (16) not expected 1: 0x0000fffffff3cf90 [rwRW,0x0000fffffff3cf90-0x0000fffffff3cfa0]
TEST: test_bounds_stack_dynamic_uint16: Check bounds on 16-bit dynamic stack allocation
FAIL: test_bounds_stack_dynamic_uint16: length (16) not expected 2: 0x0000fffffff3cf90 [rwRW,0x0000fffffff3cf90-0x0000fffffff3cfa0]
TEST: test_bounds_stack_dynamic_uint32: Check bounds 32-bit dynamic stack allocation
FAIL: test_bounds_stack_dynamic_uint32: length (16) not expected 4: 0x0000fffffff3cf90 [rwRW,0x0000fffffff3cf90-0x0000fffffff3cfa0]
TEST: test_bounds_stack_dynamic_uint64: Check bounds on 64-bit dynamic stack allocation
FAIL: test_bounds_stack_dynamic_uint64: length (16) not expected 8: 0x0000fffffff3cf90 [rwRW,0x0000fffffff3cf90-0x0000fffffff3cfa0]

The test cases are as follows:

static void
test_bounds_stack_alloca(size_t len)
{       
        void * __capability c = (__cheri_tocap void * __capability)alloca(len);
        
        test_bounds_precise(c, len);
}

void
test_bounds_stack_dynamic_uint8(const struct cheri_test *ctp __unused)
{
        
        test_bounds_stack_alloca(sizeof(uint8_t));
}

void
test_bounds_stack_dynamic_uint16(const struct cheri_test *ctp __unused)
{
        
        test_bounds_stack_alloca(sizeof(uint16_t));
}

void
test_bounds_stack_dynamic_uint32(const struct cheri_test *ctp __unused)
{

        test_bounds_stack_alloca(sizeof(uint32_t));
}

void
test_bounds_stack_dynamic_uint64(const struct cheri_test *ctp __unused)
{

        test_bounds_stack_alloca(sizeof(uint64_t));
}

Full test suite here: https://github.com/CTSRD-CHERI/cheribsd/tree/master/bin/cheritest

Tagging @jrtc27 @brett.gutstein @arichardson as FYIs.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: morello/llvm-project#1