From patchwork Wed Dec 16 13:26:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 41457 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCD0738754A1; Wed, 16 Dec 2020 13:27:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCD0738754A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608125279; bh=JCjqhkb7Mg2ruCT/zpjmvbd0XfWMWTdboQbdyWS/4XQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QUrqn+KW0TotX36M0tikc7iUKzqZpTMsKb/ozp/YlfXxL2BEvk2T2Fz+3za8Mk138 QegHZ9N0GPBlpWPntCtXxDsqPbz1SDgYNZBuPfTkaBg+CqbVku8lDib+YYSzVyGtSb 81dJiv4MTGehpW8+r6iCSkjO1fWfol8TQoytviKE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by sourceware.org (Postfix) with ESMTPS id 4190E38708DA for ; Wed, 16 Dec 2020 13:27:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4190E38708DA Received: from noise.cbg.collabora.co.uk (unknown [IPv6:2001:4d48:ad5c:ef00:8e70:5aff:fe59:c29c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id A0E531F456A0 for ; Wed, 16 Dec 2020 13:27:46 +0000 (GMT) To: libc-alpha Subject: [RFC][PATCH v7 15/20] Suppress audit calls when a (new) namespace is empty Date: Wed, 16 Dec 2020 13:26:45 +0000 Message-Id: <20201216132650.22949-16-vivek@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201216132650.22949-1-vivek@collabora.com> References: <20201216132650.22949-1-vivek@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Vivek_Das=C2=A0Mohapatra_via_Libc-alpha?= From: Vivek Dasmohapatra Reply-To: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" When preparing an RTLD_SHARED proxy in a new namespace it is possible for the target namespace to be empty: This can happen for RTLD_SHARED + LM_ID_NEWLM. The audit infrastructure should not be invoked at this point (as there's nothing there to audit yet). --- elf/dl-load.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 68587831fd..9bd4884a88 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1127,8 +1127,11 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, && __glibc_unlikely (GLRO(dl_naudit) > 0)) { struct link_map *head = GL(dl_ns)[nsid]._ns_loaded; - /* Do not call the functions for any auditing object. */ - if (head->l_auditing == 0) + /* Do not call the functions for any auditing object. + Do not try to call auditing functions if the namespace + is currently empty. This can hapen when opening the first + DSO in a new namespace. */ + if (head && head->l_auditing == 0) { struct audit_ifaces *afct = GLRO(dl_audit); for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)