From patchwork Thu Sep 30 18:23:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 45618 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 B50443857C52 for ; Thu, 30 Sep 2021 18:23:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B50443857C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633026223; bh=ny06NC+whtPACWCU/Dme+72o3OmAX1O+MvohmV8LbS0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=rzlTV2t3jMPAcb+8v71Q0hXqywuGFmAxxvIQC5NoThi0pHwUKfurgz2Ffd5sZW8Uj ELSe7hG/Oa6dJuZITIyyEG+2zMew+nAOXYn5Sg7RMxcPDjStIQDJIDHUW1tsVIcqit g6kjeHYXtzYIkfUDeZBCC/BeY/unyP/NhzBKShUo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 7BD943858C2C for ; Thu, 30 Sep 2021 18:23:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7BD943858C2C Received: by mail-pj1-x1034.google.com with SMTP id k23-20020a17090a591700b001976d2db364so5463401pji.2 for ; Thu, 30 Sep 2021 11:23:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ny06NC+whtPACWCU/Dme+72o3OmAX1O+MvohmV8LbS0=; b=D4d9LntjxZT+RX3rVyymqOeanPjQ4cC+uCLTr8naClbpiGEyWKidplcAex+GeWii8O lqKyDqoGXsyi/4y3YauTeQyZgvqTjxBVKYla/8tBW82fWbw0+COU98wx94ZSreRIR67n UbLZ3ga8gjSOFHlfMRCxPWiKsZwo0kC0u3JDI35/7DV4nuPgKGMIJwIOme6gUrX55MeC VK6s85RQR8+mzkRrc21oMwPdkS4lERCrnkKWQ4OBfGSEuU6qjw2IMHX5e3gQFbEel8MI Q80CbrcvjFYb5cIf27pFY5VIZbPfjCdMuNVl7jGhQ1BNSbhu85iSC/I1d4l9hNchFxWH hWcA== X-Gm-Message-State: AOAM532qlN0xR4hqLqK2fkXRmRKkS7Dx6M/383XUibxfyhnBYtVtW9JV jQXyku6KLanx5FuOb5hus/IOkXpfUYs= X-Google-Smtp-Source: ABdhPJxDfnz27c+38m1+T3J6j7KFUf3RGWudGmFkmI4lCkrL7aWoCeVa1PEFpq7Rpo473gFyKQgC1w== X-Received: by 2002:a17:90b:4d90:: with SMTP id oj16mr14819979pjb.170.1633026201555; Thu, 30 Sep 2021 11:23:21 -0700 (PDT) Received: from gnu-gram-1.localdomain (2603-800c-230f-d241-0000-0000-0000-112a.res6.spectrum.com. [2603:800c:230f:d241::112a]) by smtp.gmail.com with ESMTPSA id v7sm3689326pff.195.2021.09.30.11.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 11:23:21 -0700 (PDT) Received: from gnu-gram-1.localdomain (localhost [IPv6:::1]) by gnu-gram-1.localdomain (Postfix) with ESMTP id A2382E0072; Thu, 30 Sep 2021 11:23:19 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2] elf: Replace nsid with args.nsid [BZ #27609] Date: Thu, 30 Sep 2021 11:23:11 -0700 Message-Id: <20210930182311.3718571-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3032.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" do_dlopen calls _dl_open with nsid == __LM_ID_CALLER (-2), which calls dl_open_worker with args.nsid = nsid. dl_open_worker updates args.nsid if it is __LM_ID_CALLER. After dl_open_worker returns, use args.nsid instead of nsid. This fixes BZ #27609. --- elf/dl-open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elf/dl-open.c b/elf/dl-open.c index a25443f6d1..5295e931b0 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -886,7 +886,7 @@ no more namespaces available for dlmopen()")); /* Avoid keeping around a dangling reference to the libc.so link map in case it has been cached in libc_map. */ if (!args.libc_already_loaded) - GL(dl_ns)[nsid].libc_map = NULL; + GL(dl_ns)[args.nsid].libc_map = NULL; /* Remove the object from memory. It may be in an inconsistent state if relocation failed, for example. */