From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 751173858D3C for ; Mon, 20 Sep 2021 16:54:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 751173858D3C Received: by mail-pf1-x42b.google.com with SMTP id g14so16870669pfm.1 for ; Mon, 20 Sep 2021 09:54:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a6HmNB9osnU5p7WGHaBvJ/L7i48466JSIvXMnh74wLg=; b=H8svuNN75a91Eo28majeaq+Sdq4XcFdsBwpZJJ8z7vVgICcImnbtmzynlO6mQjrAy3 G8r/BMwuEv5YT8GO9fwWYPSg+a9kVvZknTtDZOQy7qrY2G3GaFqqLUsggYEnXNFwFu4j VenBaLvMoJM/GwDcbjgPs9+Kb+r6cck44/EOsTsrOpq1LHkZzV779vCdQKqYqJvaGC1T cmRlsxaH3DpEvzAo7DebnZTOhbWIMYRkX4Tw3hXUvoPmzp0yAPVCHAraP/LfCi4xPgh3 slAk5+wXpIqQmqLwO0BKW4QguScNAHFq2n9RFe0Rt9ORvJeca1W1734zsSq6X2qMphFo 5FGA== X-Gm-Message-State: AOAM533iX2ZlPV9SgdBgBkcq3PNduHMNCtFQAjcUqEeRKaV28FldvPsK FuFlb0afuMG8IVAAQrhRWHJ6/cpggg5nfibqdqSu0KQd X-Google-Smtp-Source: ABdhPJzbjGyt3nwjuohxmhYTRX57EefvrsHmnCvN5FwyxM9PD5vCoaby7mKzfckXdNNMgatHV1GPvNiUIWv1s1nsR/Y= X-Received: by 2002:a63:1a64:: with SMTP id a36mr24069240pgm.225.1632156866246; Mon, 20 Sep 2021 09:54:26 -0700 (PDT) MIME-Version: 1.0 References: <20210817184546.3330651-1-hjl.tools@gmail.com> In-Reply-To: <20210817184546.3330651-1-hjl.tools@gmail.com> From: "H.J. Lu" Date: Mon, 20 Sep 2021 09:53:49 -0700 Message-ID: Subject: PIN^1 [PATCH] elf: Guard against __LM_ID_CALLER [BZ #27609] To: GNU C Library , Florian Weimer Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3029.5 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-List-Received-Date: Mon, 20 Sep 2021 16:54:28 -0000 On Tue, Aug 17, 2021 at 11:45 AM H.J. Lu wrote: > > do_dlopen calls _dl_open with nsid == __LM_ID_CALLER (-2). When _dl_open > fails in nptl/tst-setuid1 , we can reach > > 881 /* Avoid keeping around a dangling reference to the libc.so link > 882 map in case it has been cached in libc_map. */ > 883 if (!args.libc_already_loaded) > 884 GL(dl_ns)[nsid].libc_map = NULL; > 885 > > with nsid == -2. Guard against __LM_ID_CALLER before updating libc_map > to avoid buffer underflow. 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 e90287bc62..5c54df5b7f 100644 > --- a/elf/dl-open.c > +++ b/elf/dl-open.c > @@ -885,7 +885,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) > + if (!args.libc_already_loaded && nsid >= 0) > GL(dl_ns)[nsid].libc_map = NULL; > > /* Remove the object from memory. It may be in an inconsistent > -- > 2.31.1 > PING. -- H.J.