Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Feb 2024 15:04:27 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: d146da5d08d4 - stable/14 - libthr: Force the thr_wake() symbol to be resolved during initialization
Message-ID:  <202402091504.419F4R23085559@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=d146da5d08d432b455d717e03d9130be166b8edb

commit d146da5d08d432b455d717e03d9130be166b8edb
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-02-02 14:23:53 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-02-09 14:55:46 +0000

    libthr: Force the thr_wake() symbol to be resolved during initialization
    
    Otherwise the lock upgrade performed by rtld's load_filtees() can result
    in infinite recursion, wherein:
    1. _rtld_bind() acquires the bind read lock,
    2. the source DSO's filtees haven't been loaded yet, so the lock upgrade
       in load_filtees() cause rtld to jump to _rtld_bind() and release the
       bind lock,
    3. _thr_rtld_lock_release() calls _thr_ast(), which calls thr_wake(),
       which hasn't been resolved yet,
    4. _rtld_bind() acquires the bind read lock in order to resolve
       thr_wake(),
    5. ...
    
    See the linked pull request for an instance of this problem arising with
    libsys.  That particular instance is also worked around by commit
    e7951d0b04e6.
    
    Reported by:    brooks
    Reviewed by:    kib
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/908
    MFC after:      1 week
    Sponsored by:   Innovate UK
    
    (cherry picked from commit 36f0a34ca645d49ec79d60ea7e773374ef0991ea)
---
 lib/libthr/thread/thr_rtld.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c
index 9026abf941e2..767b4735e1fa 100644
--- a/lib/libthr/thread/thr_rtld.c
+++ b/lib/libthr/thread/thr_rtld.c
@@ -238,6 +238,7 @@ _thr_rtld_init(void)
 
 	mprotect(NULL, 0, 0);
 	_rtld_get_stack_prot();
+	thr_wake(-1);
 
 	li.rtli_version = RTLI_VERSION;
 	li.lock_create  = _thr_rtld_lock_create;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402091504.419F4R23085559>