From nobody Tue Jan 14 23:14:05 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YXlLj5lL3z5kZDf; Tue, 14 Jan 2025 23:14:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YXlLj4RgMz3QS8; Tue, 14 Jan 2025 23:14:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736896445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sr4BobZtwHQCSM90Jtyzhmub6i+jBNsHdcQKMtWkcqQ=; b=wGm9spjuyEbTnYf0/ULG0Q7EXDzmF77VMHCtJmO4JqyVhxWMTT3DNdxn0Qr9WEi73DkAu9 0d8Npfc427erPYZ6tsoxlwsFgYqvXGc/U8KGEQyALp0/7YVUzB6XBOXsMNkZ9acBrmVh92 DjzAnTJcjrtdDesNHaR78fdXuYx1DZGDMmwYFs8YMUE89YOP+MaGNkDvlRwBkVGftJ5PQY 6BEoC4CXcny2NbWlBQ2jE+QQaYner6eXSXLBSt8eT8vvr0nw1PTMHaOjwSIZm8cFmhvxKN klebXQEGPYOx6eaR+rXuaipGLGiWS9TEB/OfdC1MVwe+w9zrWX2ZCBZUfyVITA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736896445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sr4BobZtwHQCSM90Jtyzhmub6i+jBNsHdcQKMtWkcqQ=; b=UFM/anovoAEZjs48pHhkTcivYsgaJyAIQvOIzR2m5uemgCwKIMcjBnYHbTvYB7YcskTpRj 58bwxn99aEsMRoxW8MwI3fk6W6pES8RbgPfGOaa+b1OJ0pFhxn6bHsAIn9tr85omprjjXb m4y63JVgY6Y39rx/YP9vgcC48vrzZ1e6hn9kUOo1XBmYB9aWp8LzLKZUyi93LmQ+db8hpR brPBV9bAYv++oVOgngZGMDJlD1k/NXblY9pcmLx4m71TvXGeR6gF+QMwO88c7uHF4qJC8D wYSD8MzPQ95lLjBKnEO6yuGe8TaUOj7rcjjR9jQ5hbvOIwxI1iDxd6msd78MlQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736896445; a=rsa-sha256; cv=none; b=FKNWb9t0wVvyMPJU9cl8+OJgh+UwVuFHzclkiKRcKGAx/UHq5lP6DZ69tCfsQD016W0EF/ ZcuoPlOChbuZzcvSXCvta5ygj6FP+Ad7bozdxb6WCgb7oKX4atFyPy2lg99dKkaH2HsiiB 5K3gFcooy9Sdy5v2zAaSW+v+0W7K+HNlh7QXe27Nx7p96xmCOK9pqxzf7z8PpSZ9W2GPAd 73ehi8nT5HbbcYPxHuXOwnP5/f/M4Rbk8jsu1XYEKGXz4+ue8F1eZpK+OgxYO1wXrTGNA+ NyfOThhnjNQ8cXKrqCrh4uHNWNT7p1+F8rTEeFQfAkJlaUgbgMQnQ6ruo2Y7tw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YXlLj3wvNz5nd; Tue, 14 Jan 2025 23:14:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50ENE5TX072653; Tue, 14 Jan 2025 23:14:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50ENE57F072650; Tue, 14 Jan 2025 23:14:05 GMT (envelope-from git) Date: Tue, 14 Jan 2025 23:14:05 GMT Message-Id: <202501142314.50ENE57F072650@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 676be27133fa - main - libpthread_init(): ensure curthread == NULL until set explicitly List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 676be27133fa3296f3d9083732d8837a3eaa5ea4 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=676be27133fa3296f3d9083732d8837a3eaa5ea4 commit 676be27133fa3296f3d9083732d8837a3eaa5ea4 Author: Konstantin Belousov AuthorDate: 2025-01-14 22:11:48 +0000 Commit: Konstantin Belousov CommitDate: 2025-01-14 23:14:00 +0000 libpthread_init(): ensure curthread == NULL until set explicitly Otherwise libthr::_get_curthread() returns a garbage kept there from allocate_initial_tls(), until libthr initialization proceeds enough to set initial pcb->pcb_thread. The garbage pcb_thread was dereferenced as struct pthread and some memory read as TID. Since the read might not be consistent between reads, thr_malloc_umtx unlock sometimes returned EPERM instead of clearing the lock word. Reported by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/libthr/thread/thr_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index 708c425d69c1..8855491b91cb 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -334,6 +334,8 @@ _libpthread_init(struct pthread *curthread) /* Set the initial thread. */ if (curthread == NULL) { first = 1; + /* Force _get_curthread() return NULL until set. */ + _tcb_get()->tcb_thread = NULL; /* Create and initialize the initial thread. */ curthread = _thr_alloc(NULL); if (curthread == NULL)