From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 12215 invoked from network); 6 Oct 2022 18:22:10 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 6 Oct 2022 18:22:10 -0000 Received: (qmail 11327 invoked by uid 550); 6 Oct 2022 18:22:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 11283 invoked from network); 6 Oct 2022 18:22:05 -0000 Date: Thu, 6 Oct 2022 14:21:51 -0400 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20221006182151.GV29905@brightrain.aerifal.cx> References: <033092a85a52d9f8e8d73a235e2381ae@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <033092a85a52d9f8e8d73a235e2381ae@ispras.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] MT fork and key_lock in pthread_key_create.c On Thu, Oct 06, 2022 at 09:37:50AM +0300, Alexey Izbyshev wrote: > Hi, > > I noticed that fork() doesn't take key_lock that is used to protect > the global table of thread-specific keys. I couldn't find mentions > of this lock in the MT fork discussion in the mailing list archive. > Was this lock overlooked? I think what happened was that we made the main list of locks to review and take care of via grep for LOCK, and then manually added known instances of locks using other locking primitives. This one must have been missed. Having special-case lock types like this is kinda a pain, but as long as there aren't too many I guess it's not a big deal. > Also, I looked at how __aio_atfork() handles a similar case with > maplock, and it seems wrong. It takes the read lock and then simply > unlocks it both in the parent and in the child. But if there were > other holders of the read lock at the time of fork(), the lock won't > end up in the unlocked state in the child. It should probably be > completely nulled-out in the child instead. Conceptually, perhaps it should be taking the write-lock instead? But null-out is probably okay too, and less costly. Rich