From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aloka.lostca.se (aloka.lostca.se [178.63.46.202]) by sourceware.org (Postfix) with ESMTPS id 716573857C7F for ; Thu, 10 Jun 2021 13:09:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 716573857C7F 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 E89061EABF for ; Thu, 10 Jun 2021 13:09:41 +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=x4dQ z2P9WPWH8AkTXfpaJKicKcQ=; b=jLScTkWLx1Di5Q/BkSlx7xqUb3OEU3bocB/E +n+RBpMCiHejeRr52XglFIVr3BjPSPNZyvRThVn7R2d+rpGnDvzZKWVgYXjHNDlu sw16vqAylMKMPI1+4rRjzJSpCwrjkckQtnXXbBd/072WUpFyKyMlbB3ID+e3foDl fR+zjuE= 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 8A5001EABE for ; Thu, 10 Jun 2021 13:09:41 +0000 (UTC) Date: Thu, 10 Jun 2021 13:09:41 +0000 From: Arjun Shankar To: libc-stable@sourceware.org Subject: [COMMITTED 2.32] Use __pthread_attr_copy in mq_notify (bug 27896) Message-ID: <20210610130939.GA86427@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=-11.9 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:09:49 -0000 Make a deep copy of the pthread attribute object to remove a potential use-after-free issue. (cherry picked from commit 42d359350510506b87101cf77202fefcbfc790cb) --- NEWS | 4 ++++ sysdeps/unix/sysv/linux/mq_notify.c | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index f278041512..2afe250ccf 100644 --- a/NEWS +++ b/NEWS @@ -208,6 +208,10 @@ Security related changes: invoked with input containing redundant shift sequences in the IBM1364, IBM1371, IBM1388, IBM1390, or IBM1399 character sets. + 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: [9809] localedata: ckb_IQ: new Kurdish Sorani locale diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c index 61bbb03b64..f404acfdfe 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