This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 4/5] Fix deadlock in _int_free consistency check
- From: Andreas Schwab <schwab at suse dot de>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: "libc-alpha\@sourceware.org" <libc-alpha at sourceware dot org>, nd <nd at arm dot com>
- Date: Thu, 12 Oct 2017 12:01:14 +0200
- Subject: Re: [PATCH 4/5] Fix deadlock in _int_free consistency check
- Authentication-results: sourceware.org; auth=none
- References: <DB6PR0801MB20537B594B5629491605CD74834B0@DB6PR0801MB2053.eurprd08.prod.outlook.com>
On Okt 12 2017, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index c00df205c6004ee5b5d0aee9ffd5130b3c8f9e9f..f4f44400d120188c4d0bece996380e04b35c8fac 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -4168,15 +4168,14 @@ _int_free (mstate av, mchunkptr p, int have_lock)
> >= av->system_mem, 0))
> {
> /* We might not have a lock at this point and concurrent modifications
> - of system_mem might have let to a false positive. Redo the test
> - after getting the lock. */
> - if (!have_lock
> - || ({ __libc_lock_lock (av->mutex);
> - chunksize_nomask (chunk_at_offset (p, size)) <= 2 * SIZE_SZ
> - || chunksize (chunk_at_offset (p, size)) >= av->system_mem;
> - }))
> + of system_mem might result in a false positive. Redo the test after
> + getting the lock. */
> + if (!have_lock)
> + __libc_lock_lock (av->mutex);
> + if (chunksize_nomask (chunk_at_offset (p, size)) <= 2 * SIZE_SZ
> + || chunksize (chunk_at_offset (p, size)) >= av->system_mem)
There is no need to redo the tests if we had the lock.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."