From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94828 invoked by alias); 31 Oct 2019 23:14:51 -0000 Mailing-List: contact libc-stable-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Archive: Sender: libc-stable-owner@sourceware.org Received: (qmail 94812 invoked by uid 89); 31 Oct 2019 23:14:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-17.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=Protect X-Spam-Status: No, score=-17.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 Oct 2019 23:14:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572563688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HuW/5ePzma6Fid0YX4Ck5nryYMhUojo9cTLc1rVt/lU=; b=Eu/11nu/esNEz3EMNaoCGPM15QWO5zfLsiajz+0FnIEgJ+va8iGOEJ+ZQkWprVTUzfJxzY HiiZnW2X932bWSkJ6hb8bro/ZNG/EDvKNJ07UeavBwOiSaj0iisRR/z9RspPlRfYvd5JBQ 9o7ZGOgUKV53vL3b0bxZvXD3FFc4scI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-287-XdOjFZwROci6NTTeldxfRA-1; Thu, 31 Oct 2019 19:14:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72803107ACC0 for ; Thu, 31 Oct 2019 23:14:45 +0000 (UTC) Received: from greed.delorie.com (ovpn-116-99.phx2.redhat.com [10.3.116.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 476CC10016E8 for ; Thu, 31 Oct 2019 23:14:44 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.14.7/8.14.7) with ESMTP id x9VNEhHs028350 for ; Thu, 31 Oct 2019 19:14:43 -0400 Date: Tue, 01 Jan 2019 00:00:00 -0000 Message-Id: From: DJ Delorie To: libc-stable@sourceware.org Subject: [2.28 COMMITTED] nss_db: fix endent wrt NULL mappings [BZ #24695] [BZ #24696] X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: XdOjFZwROci6NTTeldxfRA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00014.txt.bz2 From: DJ Delorie nss_db allows for getpwent et al to be called without a set*ent, but it only works once. After the last get*ent a set*ent is required to restart, because the end*ent did not properly reset the module. Resetting it to NULL allows for a proper restart. If the database doesn't exist, however, end*ent erroniously called munmap which set errno. The test case runs "makedb" inside the testroot, so needs selinux DSOs installed. (cherry picked from commit 99135114ba23c3110b7e4e650fabdc5e639746b7) (note: tests excluded as test-in-container infrastructure missing) diff --git a/ChangeLog b/ChangeLog index fcc0f8041d..d932485496 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2019-07-10 DJ Delorie + Sergei Trofimovich + + [BZ #24696] + [BZ #24695] + * nss/nss_db/db-open.c (internal_endent): Protect against NULL + mappings. + 2019-07-01 H.J. Lu =20 [BZ #24259] diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c index 8538f8e961..ac430f445a 100644 --- a/nss/nss_db/db-open.c +++ b/nss/nss_db/db-open.c @@ -63,5 +63,9 @@ internal_setent (const char *file, struct nss_db_map *map= ping) void internal_endent (struct nss_db_map *mapping) { - munmap (mapping->header, mapping->len); + if (mapping->header !=3D NULL) + { + munmap (mapping->header, mapping->len); + mapping->header =3D NULL; + } }