This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v3] dl-load: add memory barrier before updating the next
- From: Torvald Riegel <triegel at redhat dot com>
- To: Maninder Singh <maninder1 dot s at samsung dot com>
- Cc: libc-alpha at sourceware dot org, szabolcs dot nagy at arm dot com, pankaj dot m at samsung dot com, ajeet dot y at samsung dot com, a dot sahrawat at samsung dot com, lalit dot mohan at samsung dot com, akhilesh dot k at samsung dot com, hakbong5 dot lee at samsung dot com, Vaneet Narang <v dot narang at samsung dot com>
- Date: Mon, 03 Apr 2017 15:25:14 +0200
- Subject: Re: [PATCH v3] dl-load: add memory barrier before updating the next
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=triegel at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 15F3B627C5
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15F3B627C5
- References: <CGME20170403113000epcas5p37d569cf71eda2d413cfab5e7f7e3591d@epcas5p3.samsung.com> <1491218925-19517-1-git-send-email-maninder1.s@samsung.com>
On Mon, 2017-04-03 at 16:58 +0530, Maninder Singh wrote:
> [BZ #21349]: race condition between dl_open and rtld lazy symbol resolve.
>
> This patch adds C11 memory barrier before updating the liblist next.
>
> Issue Fix: race condition between add_name_to_object & _dl_name_match_p.
> One threads calling dlopen which further calls add_name_to_object &
> other thread trying to resolve RTLD_LAZY symbols through
> _dl_runtime_resolve which further calls.
>
> _dl_name_match_p checks if libname->next is valid, then it assumes
> libname->next->name to be valid. Also add_name_to_object initialized
> name first and then sets valid next pointer.
>
> This patch avoids any reorder of instruction when next is set before
> name to avoid any race.
>
> Signed-off-by: Vaneet Narang <v.narang@samsung.com>
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Please address my comments on v2 of your patch too.