Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmap() can't be called via (__)syscall #2034

Open
arichardson opened this issue Mar 7, 2024 · 2 comments
Open

mmap() can't be called via (__)syscall #2034

arichardson opened this issue Mar 7, 2024 · 2 comments

Comments

@arichardson
Copy link
Member

This is used e.g. by the sanitizer runtimes, but since unistd.h declares syscall/__syscall with an integer return value it's not possible to actually call mmap() successfully:

cheribsd/include/unistd.h

Lines 582 to 583 in 698d163

int syscall(int, ...);
off_t __syscall(quad_t, ...);

Should these be changed to intptr_t for purecap?

@brooksdavis
Copy link
Member

I suspect we should leave syscall alone (it can't be used for mmap except by accident), but likely __syscall should be int64ptr_t.

@jrtc27
Copy link
Member

jrtc27 commented Mar 7, 2024

Using it for mmap has two problems:

  1. off_t is 64-bit, so on a 32-bit system you need to use __syscall so the arguments are aligned correctly
  2. Pointers get truncated on a 64-bit system even absent CHERI

There's also shmat which suffers from 2 but not 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants