Date: Thu, 25 May 2023 22:38:39 -0400 From: Rich Felker <dalias@...c.org> To: Markus Wichmann <nullplan@....net> Cc: musl@...ts.openwall.com Subject: Re: vm lock needed in mprotect? On Thu, May 25, 2023 at 06:53:19PM +0200, Markus Wichmann wrote: > Hi all, > > I'm wondering if the vm lock is needed in mprotect(), similar to > munmap(). Reason for the vm lock was that if an application had two > threads waiting on a process-shared barrier, and one thread came out of > it to immediately unmap the SHM segment, then the other thread might not > yet have had a change to exit pthread_barrier_wait(), and since that > function accesses the barrier object after the last futex wait call, it > would crash. > > So what if that first thread, instead of unmapping the SHM, just changes > its protection to read-only? That would also crash. Or is that somehow > not valid? If so, why? Thanks! I'll have to think about it more, but offhand I think your reasoning is correct for pthread_barrier_wait. We might want to reconsider whether this use of vm_lock is needed or if there's another way to do things. The essential use that can't be eliminated is handling the pending slot for robust mutexes, and that use is not subject to the issue you're asking about. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.