From patchwork Thu Feb 23 08:09:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stsp X-Patchwork-Id: 1746666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=LSlpM3vh; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PMm0M1c6xz245y for ; Thu, 23 Feb 2023 19:09:55 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C8483858C30 for ; Thu, 23 Feb 2023 08:09:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C8483858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677139787; bh=nZihGjoaGJvHThZq1CM+FMCZNvKR6LheeR/xgcK1we4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=LSlpM3vhVtzYj9oXf5oUglNmiEYdNUKxZKluAC6hYGc7dK1ZN3hAtzbfsBmmaeEoo y4bBTFq/yQYOUPvPzLOO/H2xho6AoKY/kXv8ZFkpGn6z9mfJs/sJglXcYcHap7bIbT 8uLeXVhfmdvCNuKEj9msVdd181bbag6Lx/ziI+OU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::608]) by sourceware.org (Postfix) with ESMTPS id B3D1D3858C83 for ; Thu, 23 Feb 2023 08:09:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3D1D3858C83 Received: from forward102q.mail.yandex.net (forward102q.mail.yandex.net [IPv6:2a02:6b8:c0e:1ba:0:640:516:4e7d]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 9BA434C33B6 for ; Thu, 23 Feb 2023 11:09:27 +0300 (MSK) Received: from vla3-79cc00068f6d.qloud-c.yandex.net (vla3-79cc00068f6d.qloud-c.yandex.net [IPv6:2a02:6b8:c15:2582:0:640:79cc:6]) by forward102q.mail.yandex.net (Yandex) with ESMTP id 97486BF00002 for ; Thu, 23 Feb 2023 11:09:27 +0300 (MSK) Received: by vla3-79cc00068f6d.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id O9KEnmwXZmI1-2aNllbba; Thu, 23 Feb 2023 11:09:26 +0300 X-Yandex-Fwd: 1 To: libc-alpha@sourceware.org Cc: Stas Sergeev Subject: [PATCH 1/2] elf/dl-open: fix audit wrt RTLD_NOLOAD [BZ #30127] Date: Thu, 23 Feb 2023 13:09:13 +0500 Message-Id: <20230223080914.2961911-2-stsp2@yandex.ru> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230223080914.2961911-1-stsp2@yandex.ru> References: <20230223080914.2961911-1-stsp2@yandex.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Stas Sergeev via Libc-alpha From: stsp Reply-To: Stas Sergeev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Currently dlmopen() does not allow to load objects into an audit namespace. But the RTLD_NOLOAD case was forgotten, so the too restrictive check prevents even getting a handle for an objects in an audit namespace. This patch fixes the problem by relaxing a check in case of RTLD_NOLOAD. Test-case on x86_64 revealed no regressions. Signed-off-by: Stas Sergeev --- elf/dl-open.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elf/dl-open.c b/elf/dl-open.c index 91a2d8a538..c7ce0396d3 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -864,7 +864,8 @@ no more namespaces available for dlmopen()")); DL_NNS is 1 and so any NSID != 0 is invalid. */ || DL_NNS == 1 || GL(dl_ns)[nsid]._ns_nloaded == 0 - || GL(dl_ns)[nsid]._ns_loaded->l_auditing)) + || (GL(dl_ns)[nsid]._ns_loaded->l_auditing && + !(mode & RTLD_NOLOAD)))) _dl_signal_error (EINVAL, file, NULL, N_("invalid target namespace in dlmopen()"));