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

sched/sem_holder.c: When accessing SEM_WAITLIST, use holder's addrenv #11191

Merged
merged 1 commit into from Nov 15, 2023

Conversation

pussuw
Copy link
Contributor

@pussuw pussuw commented Nov 15, 2023

Summary

If the semaphore is shared, the holder has put its own mmapped address to pholder->sem. This means we must switch to the holder's address environment when going through the held semaphores list.

A better option would be to get the kernel mapped address for the semaphore's physical page, but that mechanism is not functional yet.

This fixes a full system crash when CONFIG_PRIORITY_INHERITANCE=y and CONFIG_BUILD_KERNEL=y and user makes shared semaphore via:

int semfd = shm_open("sem", O_CREAT | O_RDWR, 0666);
sem_t *sem = mmap(0, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, semfd, 0);

Impact

Fixes system crash as mentioned above

Testing

MPFS target with kernel mode, priority inheritance and shared semaphores

If the semaphore is shared, the holder has put its own mmapped address
to pholder->sem. This means we must switch to the holder's address
environment when going through the held semaphores list.

A better option would be to get the kernel mapped address for the
semaphore's physical page, but that mechanism is not functional yet.

This fixes a full system crash when CONFIG_PRIORITY_INHERITANCE=y and
CONFIG_BUILD_KERNEL=y and user makes shared semaphore via:

int semfd  = shm_open("sem", O_CREAT | O_RDWR, 0666);
sem_t *sem = mmap(0, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, semfd, 0);
@xiaoxiang781216 xiaoxiang781216 merged commit b7b0a17 into apache:master Nov 15, 2023
26 checks passed
@pussuw pussuw deleted the semholder_addrenv_fix branch November 15, 2023 11:57
@jerpelea jerpelea added this to To-Add in Release Notes - 12.4.0 Dec 27, 2023
@jerpelea jerpelea moved this from To-Add to core in Release Notes - 12.4.0 Jan 8, 2024
@jerpelea jerpelea moved this from core to processed in Release Notes - 12.4.0 Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants