From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aloka.lostca.se (aloka.lostca.se [IPv6:2a01:4f8:120:624c::2]) by sourceware.org (Postfix) with ESMTPS id CEE0C3858034 for ; Thu, 10 Jun 2021 13:12:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CEE0C3858034 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lostca.se Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lostca.se Received: from aloka.lostca.se (aloka [127.0.0.1]) by aloka.lostca.se (Postfix) with ESMTP id 99A261EB3A for ; Thu, 10 Jun 2021 13:12:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=lostca.se; h=date:from:to :subject:message-id:mime-version:content-type; s=howrah; bh=g7AT 0pcaI3Kxwm3ecReDZvAqQMQ=; b=LMHbbKopdSH4oLpkQhJQwiuXCLyhldK1EZSL WPbMkgkKtz1qdIrC+RyksZD8q/BbYSjbIax5O4Ng8WJm53Uhpvq+KmTK36+HHRrT FIMkcR1XWnilBuEeyohdOoKWBPoeXZ/ElXKO82a4oT67D7hYvXF0whS42dzUBEr/ tCu9cO0= Received: from localhost (unknown [IPv6:2a01:4f8:120:624c::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: spectre) by aloka.lostca.se (Postfix) with ESMTPSA id 5B46F1EB39 for ; Thu, 10 Jun 2021 13:12:57 +0000 (UTC) Date: Thu, 10 Jun 2021 13:12:57 +0000 From: Arjun Shankar To: libc-stable@sourceware.org Subject: [COMMITTED 2.33] Use __pthread_attr_copy in mq_notify (bug 27896) Message-ID: <20210610131255.GA86500@aloka.lostca.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2021 13:13:02 -0000 Make a deep copy of the pthread attribute object to remove a potential use-after-free issue. (cherry picked from commit 42d359350510506b87101cf77202fefcbfc790cb) --- NEWS | 6 ++++++ sysdeps/unix/sysv/linux/mq_notify.c | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 0c33a80af9..b9e570b4a4 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,12 @@ Major new features: a dump of information related to IFUNC resolver operation and glibc-hwcaps subdirectory selection. +Security related changes: + + CVE-2021-33574: The mq_notify function has a potential use-after-free + issue when using a notification type of SIGEV_THREAD and a thread + attribute with a non-default affinity mask. + The following bugs are resolved with this release: [15271] dlfcn function failure after dlmopen terminates process diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c index cc575a0cdd..f7ddfe5a6c 100644 --- a/sysdeps/unix/sysv/linux/mq_notify.c +++ b/sysdeps/unix/sysv/linux/mq_notify.c @@ -133,8 +133,11 @@ helper_thread (void *arg) (void) __pthread_barrier_wait (¬ify_barrier); } else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED) - /* The only state we keep is the copy of the thread attributes. */ - free (data.attr); + { + /* The only state we keep is the copy of the thread attributes. */ + pthread_attr_destroy (data.attr); + free (data.attr); + } } return NULL; } @@ -255,8 +258,7 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification) if (data.attr == NULL) return -1; - memcpy (data.attr, notification->sigev_notify_attributes, - sizeof (pthread_attr_t)); + __pthread_attr_copy (data.attr, notification->sigev_notify_attributes); } /* Construct the new request. */ @@ -270,7 +272,10 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification) /* If it failed, free the allocated memory. */ if (__glibc_unlikely (retval != 0)) - free (data.attr); + { + pthread_attr_destroy (data.attr); + free (data.attr); + } return retval; } -- 2.31.1