Skip to content

Reachable unwrap panic in sys_munmap() at legacy.rs #141

@Marsman1996

Description

@Marsman1996

Describe the bug

There is a reachable unwrap panic in sys_munmap() caused by aligning large len (i.e., 0xffffffffffffffff) of a munmap syscall.

let layout = Layout::from_size_align(len, 8).unwrap();

To Reproduce

  1. Compile a program which calls munmap:
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>

int main()
{
    void *addr = mmap(NULL, 4096, 0x3, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    munmap(addr, 0xffffffffffffffff);

    return 0;
}

With following features:

alloc 
irq
musl
multitask
fs
pipe
poll
rtc
signal
virtio-9p
  1. Run the compiled program in RuxOS.

Expected behavior

RuxOS reports panic and is terminated.

Environment

  • RuxOS version: main b1f880b
  • ubuntu:22.04 in Docker
  • 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz

Logs

[1728388549.205894 0:2 ruxos_posix_api::imp::mmap::legacy:67] sys_munmap <= start: 0xffffff80003fe000, len: 18446744073709551615
[1728388549.206739 0:2 ruxruntime::lang_items:14] panicked at api/ruxos_posix_api/src/imp/mmap/legacy.rs:72:54:
called `Result::unwrap()` on an `Err` value: LayoutError
[1728388549.207796 0:2 ruxhal::platform::x86_pc::misc:16] Shutting down...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions