From patchwork Thu Mar 2 19:40:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stsp X-Patchwork-Id: 65929 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 9987D385828D for ; Thu, 2 Mar 2023 19:41:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9987D385828D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677786083; 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=ZP51w2hzTqYvDZoeSTycxUUyVa9llXBEFc7TIWWufnTLxC6ABJsticgq09L5ipQzK 0lVnk7BTK5RNjTW1y6V3nWsOTGYC8PHbnBvH9E4tE70f7eJjwJISRbxYeGg0Qf9uol y/SFHdM/CtQvYp//HscsUvy5R3l7BWTm359wtRzM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [IPv6:2a02:6b8:0:801:2::101]) by sourceware.org (Postfix) with ESMTPS id 5710C3858D33 for ; Thu, 2 Mar 2023 19:40:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5710C3858D33 Received: from iva4-143b1447cf50.qloud-c.yandex.net (iva4-143b1447cf50.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:7511:0:640:143b:1447]) by forward101j.mail.yandex.net (Yandex) with ESMTP id 8804969B52B3 for ; Thu, 2 Mar 2023 22:40:56 +0300 (MSK) Received: by iva4-143b1447cf50.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id secDfN2bcmI1-nWjHNzCx; Thu, 02 Mar 2023 22:40:56 +0300 X-Yandex-Fwd: 1 To: libc-alpha@sourceware.org Cc: Stas Sergeev Subject: [PATCH 1/3] elf/dl-open: fix audit wrt RTLD_NOLOAD [BZ #30127] Date: Fri, 3 Mar 2023 00:40:49 +0500 Message-Id: <20230302194051.3677691-2-stsp2@yandex.ru> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230302194051.3677691-1-stsp2@yandex.ru> References: <20230302194051.3677691-1-stsp2@yandex.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 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+patchwork=sourceware.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()"));