From patchwork Tue Feb 9 17:18:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 41998 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com 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 4D8FA396AC03; Tue, 9 Feb 2021 17:18:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D8FA396AC03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1612891139; bh=jLsXnLKwFaInfes5sSoJjXvDxt/6kJY623r4QW/pGIA=; 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=OMqIBJ7RTfGXytBpgyUFdfyKDCBjAVEvruwQxxChTdT9HjsO4nonZmKeCl3QbLeLQ wEfCH+eTPHJTKXBYu0voug6rnzRchj041gr5cKfwcch+xnSB9hpL/BB7CMgwq8JYMs ySJvckqPEoqAJ/uncwpPozrF0ECbvC/ndrWvN5+g= 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 E2B97395543B for ; Tue, 9 Feb 2021 17:18:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E2B97395543B Received: from noise.lan (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 A7FBA1F451E5 for ; Tue, 9 Feb 2021 17:18:46 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [RFC][PATCH v8 15/20] Suppress audit calls when a (new) namespace is empty Date: Tue, 9 Feb 2021 17:18:34 +0000 Message-Id: <20210209171839.7911-16-vivek@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209171839.7911-1-vivek@collabora.com> References: <20210209171839.7911-1-vivek@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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 13879af82c..4e8e7ca031 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)