diff options
| -rw-r--r-- | meta/recipes-core/glibc/glibc/0026-PR25847-3.patch | 77 | ||||
| -rw-r--r-- | meta/recipes-core/glibc/glibc_2.35.bb | 1 |
2 files changed, 78 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0026-PR25847-3.patch b/meta/recipes-core/glibc/glibc/0026-PR25847-3.patch new file mode 100644 index 0000000000..4cfcca846c --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0026-PR25847-3.patch | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | From 28a5082045429fdc5a4744d45fdc5b5202528eaa Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Malte Skarupke <malteskarupke@fastmail.fm> | ||
| 3 | Date: Mon, 16 Jun 2025 23:29:49 -0700 | ||
| 4 | Subject: [PATCH] nptl: Remove unnecessary catch-all-wake in condvar group | ||
| 5 | switch | ||
| 6 | |||
| 7 | This wake is unnecessary. We only switch groups after every sleeper in a group | ||
| 8 | has been woken. Sure, they may take a while to actually wake up and may still | ||
| 9 | hold a reference, but waking them a second time doesn't speed that up. Instead | ||
| 10 | this just makes the code more complicated and may hide problems. | ||
| 11 | |||
| 12 | In particular this safety wake wouldn't even have helped with the bug that was | ||
| 13 | fixed by Barrus' patch: The bug there was that pthread_cond_signal would not | ||
| 14 | switch g1 when it should, so we wouldn't even have entered this code path. | ||
| 15 | |||
| 16 | The following commits have been cherry-picked from Glibc master branch: | ||
| 17 | Bug : https://sourceware.org/bugzilla/show_bug.cgi?id=25847 | ||
| 18 | |||
| 19 | Upstream-Status: Backport | ||
| 20 | [https://sourceware.org/git/?p=glibc.git;a=commit;h=b42cc6af11062c260c7dfa91f1c89891366fed3e] | ||
| 21 | |||
| 22 | Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com> | ||
| 23 | --- | ||
| 24 | nptl/pthread_cond_common.c | 30 +----------------------------- | ||
| 25 | 1 file changed, 1 insertion(+), 29 deletions(-) | ||
| 26 | |||
| 27 | diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c | ||
| 28 | index 306a207dd6..f976a533a1 100644 | ||
| 29 | --- a/nptl/pthread_cond_common.c | ||
| 30 | +++ b/nptl/pthread_cond_common.c | ||
| 31 | @@ -221,13 +221,7 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq, | ||
| 32 | * New waiters arriving concurrently with the group switching will all go | ||
| 33 | into G2 until we atomically make the switch. Waiters existing in G2 | ||
| 34 | are not affected. | ||
| 35 | - * Waiters in G1 have already received a signal and been woken. If they | ||
| 36 | - haven't woken yet, they will be closed out immediately by the advancing | ||
| 37 | - of __g_signals to the next "lowseq" (low 31 bits of the new g1_start), | ||
| 38 | - which will prevent waiters from blocking using a futex on | ||
| 39 | - __g_signals since it provides enough signals for all possible | ||
| 40 | - remaining waiters. As a result, they can each consume a signal | ||
| 41 | - and they will eventually remove their group reference. */ | ||
| 42 | + * Waiters in G1 have already received a signal and been woken. */ | ||
| 43 | |||
| 44 | /* Update __g1_start, which finishes closing this group. The value we add | ||
| 45 | will never be negative because old_orig_size can only be zero when we | ||
| 46 | @@ -240,28 +234,6 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq, | ||
| 47 | |||
| 48 | unsigned int lowseq = ((old_g1_start + old_orig_size) << 1) & ~1U; | ||
| 49 | |||
| 50 | - /* If any waiters still hold group references (and thus could be blocked), | ||
| 51 | - then wake them all up now and prevent any running ones from blocking. | ||
| 52 | - This is effectively a catch-all for any possible current or future | ||
| 53 | - bugs that can allow the group size to reach 0 before all G1 waiters | ||
| 54 | - have been awakened or at least given signals to consume, or any | ||
| 55 | - other case that can leave blocked (or about to block) older waiters.. */ | ||
| 56 | - if ((atomic_fetch_or_release (cond->__data.__g_refs + g1, 0) >> 1) > 0) | ||
| 57 | - { | ||
| 58 | - /* First advance signals to the end of the group (i.e. enough signals | ||
| 59 | - for the entire G1 group) to ensure that waiters which have not | ||
| 60 | - yet blocked in the futex will not block. | ||
| 61 | - Note that in the vast majority of cases, this should never | ||
| 62 | - actually be necessary, since __g_signals will have enough | ||
| 63 | - signals for the remaining g_refs waiters. As an optimization, | ||
| 64 | - we could check this first before proceeding, although that | ||
| 65 | - could still leave the potential for futex lost wakeup bugs | ||
| 66 | - if the signal count was non-zero but the futex wakeup | ||
| 67 | - was somehow lost. */ | ||
| 68 | - atomic_store_release (cond->__data.__g_signals + g1, lowseq); | ||
| 69 | - | ||
| 70 | - futex_wake (cond->__data.__g_signals + g1, INT_MAX, private); | ||
| 71 | - } | ||
| 72 | /* At this point, the old G1 is now a valid new G2 (but not in use yet). | ||
| 73 | No old waiter can neither grab a signal nor acquire a reference without | ||
| 74 | noticing that __g1_start is larger. | ||
| 75 | -- | ||
| 76 | 2.49.0 | ||
| 77 | |||
diff --git a/meta/recipes-core/glibc/glibc_2.35.bb b/meta/recipes-core/glibc/glibc_2.35.bb index 92c4dad023..5e1f45608e 100644 --- a/meta/recipes-core/glibc/glibc_2.35.bb +++ b/meta/recipes-core/glibc/glibc_2.35.bb | |||
| @@ -64,6 +64,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ | |||
| 64 | file://0025-CVE-2025-4802.patch \ | 64 | file://0025-CVE-2025-4802.patch \ |
| 65 | file://0026-PR25847-1.patch \ | 65 | file://0026-PR25847-1.patch \ |
| 66 | file://0026-PR25847-2.patch \ | 66 | file://0026-PR25847-2.patch \ |
| 67 | file://0026-PR25847-3.patch \ | ||
| 67 | \ | 68 | \ |
| 68 | file://0001-Revert-Linux-Implement-a-useful-version-of-_startup_.patch \ | 69 | file://0001-Revert-Linux-Implement-a-useful-version-of-_startup_.patch \ |
| 69 | file://0002-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch \ | 70 | file://0002-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch \ |
