From: "Никита Попов via Libc-alpha" <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org
Subject: [PATCH] librt: fix NULL pointer dereference (bug 28213)
Date: Mon, 9 Aug 2021 17:25:33 +0500 [thread overview]
Message-ID: <CA+cA0PA3mNB=QW_oSd2BAuRsr=6Hmt1bt61kanQ=_vcN4ygeYQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-librt-fix-NULL-pointer-dereference-bug-28213.patch --]
[-- Type: text/x-patch, Size: 1557 bytes --]
From c69f990e356dd8e756b0025e026d59db5af6e059 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npv1310@gmail.com>
Date: Mon, 9 Aug 2021 17:15:52 +0500
Subject: [PATCH] librt: fix NULL pointer dereference (bug 28213)
To: libc-alpha@sourceware.org
Helper thread frees copied attribute on NOTIFY_REMOVED message received from the OS kernel. Unfortunately, it fails to check whether copied attribute actually exists (data.attr != NULL). This worked earlier because free() checks passed pointer before actually attempting to release corresponding memory. But __pthread_attr_destroy assumes pointer is not NULL. So passing NULL pointer to __pthread_attr_destroy will result in segmentation fault. This scenario is possible if notification->sigev_notify_attributes == NULL (which means default thread attributes should be used).
---
sysdeps/unix/sysv/linux/mq_notify.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c
index 9799dcdaa4..eccae2e4c6 100644
--- a/sysdeps/unix/sysv/linux/mq_notify.c
+++ b/sysdeps/unix/sysv/linux/mq_notify.c
@@ -131,7 +131,7 @@ helper_thread (void *arg)
to wait until it is done with it. */
(void) __pthread_barrier_wait (¬ify_barrier);
}
- else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED)
+ else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED && data.attr != NULL)
{
/* The only state we keep is the copy of the thread attributes. */
__pthread_attr_destroy (data.attr);
--
2.17.1
next reply other threads:[~2021-08-09 12:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-09 12:25 Никита Попов via Libc-alpha [this message]
2021-08-09 13:21 ` [PATCH] librt: fix NULL pointer dereference (bug 28213) Siddhesh Poyarekar
2021-08-09 13:27 ` Florian Weimer via Libc-alpha
2021-08-09 13:32 ` Siddhesh Poyarekar
2021-08-09 13:45 ` Никита Попов via Libc-alpha
2021-08-09 14:35 ` Siddhesh Poyarekar
2021-08-09 14:50 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+cA0PA3mNB=QW_oSd2BAuRsr=6Hmt1bt61kanQ=_vcN4ygeYQ@mail.gmail.com' \
--to=libc-alpha@sourceware.org \
--cc=npv1310@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).