|
|
0b26f7 |
commit 79474303223c5665bec75ffbdb2a86ee04a2514b
|
|
|
0b26f7 |
Author: Nikita Popov <npv1310@gmail.com>
|
|
|
0b26f7 |
Date: Mon Aug 9 20:17:34 2021 +0530
|
|
|
0b26f7 |
|
|
|
0b26f7 |
librt: fix NULL pointer dereference (bug 28213)
|
|
|
0b26f7 |
|
|
|
0b26f7 |
Helper thread frees copied attribute on NOTIFY_REMOVED message
|
|
|
0b26f7 |
received from the OS kernel. Unfortunately, it fails to check whether
|
|
|
0b26f7 |
copied attribute actually exists (data.attr != NULL). This worked
|
|
|
0b26f7 |
earlier because free() checks passed pointer before actually
|
|
|
0b26f7 |
attempting to release corresponding memory. But
|
|
|
0b26f7 |
__pthread_attr_destroy assumes pointer is not NULL.
|
|
|
0b26f7 |
|
|
|
0b26f7 |
So passing NULL pointer to __pthread_attr_destroy will result in
|
|
|
0b26f7 |
segmentation fault. This scenario is possible if
|
|
|
0b26f7 |
notification->sigev_notify_attributes == NULL (which means default
|
|
|
0b26f7 |
thread attributes should be used).
|
|
|
0b26f7 |
|
|
|
0b26f7 |
Signed-off-by: Nikita Popov <npv1310@gmail.com>
|
|
|
0b26f7 |
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
|
0b26f7 |
(cherry picked from commit b805aebd42364fe696e417808a700fdb9800c9e8)
|
|
|
0b26f7 |
|
|
|
0b26f7 |
diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c
|
|
|
0b26f7 |
index 9799dcdaa479a1d5..eccae2e4c6cdfefa 100644
|
|
|
0b26f7 |
--- a/sysdeps/unix/sysv/linux/mq_notify.c
|
|
|
0b26f7 |
+++ b/sysdeps/unix/sysv/linux/mq_notify.c
|
|
|
0b26f7 |
@@ -131,7 +131,7 @@ helper_thread (void *arg)
|
|
|
0b26f7 |
to wait until it is done with it. */
|
|
|
0b26f7 |
(void) __pthread_barrier_wait (¬ify_barrier);
|
|
|
0b26f7 |
}
|
|
|
0b26f7 |
- else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED)
|
|
|
0b26f7 |
+ else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED && data.attr != NULL)
|
|
|
0b26f7 |
{
|
|
|
0b26f7 |
/* The only state we keep is the copy of the thread attributes. */
|
|
|
0b26f7 |
__pthread_attr_destroy (data.attr);
|