![]() |
|
Message-ID: <455063b99060bfd0d01aff1666ebb3892e001256.camel@gmail.com> Date: Fri, 31 Jan 2025 10:31:46 +0100 From: Daniele Personal <d.dario76@...il.com> To: Florian Weimer <fweimer@...hat.com>, Rich Felker <dalias@...c.org> Cc: musl@...ts.openwall.com Subject: Re: pthread_mutex_t shared between processes with different pid namespaces On Tue, 2025-01-28 at 19:24 +0100, Florian Weimer wrote: > * Rich Felker: > > > Yes, the pid namespace boundary is your problem. Process-shared > > mutexes only work on the same logical system with a unique set of > > thread identifiers. If you're trying to share them across different > > pid namespaces, the same pid/tid may refer to different > > processes/threads in different ones, and it's not usable as a mutex > > ownership identity. >From what I see, the problem seems to happen only in case of contention of the mutex. int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at) { if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL && !a_cas(&m->_m_lock, 0, EBUSY)) return 0; int type = m->_m_type; int r, t, priv = (type & 128) ^ 128; r = __pthread_mutex_trylock(m); if (r != EBUSY) return r; IIUC, if it is not locked, the __pthread_mutex_timedlock will acquire it and return 0 (don't understand if with the first check or with the __pthread_mutex_trylock) and everything works. If instead it is locked the problem arises only inside the container. If it was a pthread_mutex_lock it waits forever, if it was a timed lock it exits after the timeout and you can retry. Is this correct? > > Is this required for implementing the unlock-if-not-owner error code > on > mutex unlock? No, I don't see problems related to EOWNERDEAD. > > By the way, there is a proposal to teach the kernel to rewrite the > ownership list of task exit: > > [PATCH v2 0/4] futex: Drop ROBUST_LIST_LIMIT > > <https://lore.kernel.org/linux-kernel/20250127202608.223864-1-andreal > meid@...lia.com/> > > I'm worried about the compatibility impact. > > Thanks, > Florian > Thanks, Daniele.
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.