From nobody Fri Sep 01 02:10:54 2023 X-Original-To: dev-commits-src-main@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 4RcM2Q4gwMz4rv56; Fri, 1 Sep 2023 02:10:54 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RcM2Q3dBNz4HBD; Fri, 1 Sep 2023 02:10:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693534254; 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=9MvCiEGwSjDgtXlLMY8cdD+ahKPUnZ66+pKY1O7aBps=; b=fegPbIDrBakK2GRapuTTAJKKx91UlzXV65gqdFsDnOlNnFeLJ6DZ1RD/rFZPkh6q6sA+LR etNg/zCbqsMqDypxiLYsgNm61VohsFC2qG8t66mMRwTJ9/NtpEO4o4wquqDKFAKZDOsoxa poX3co/6XjoP2n74cEBJvJ9O4B90m6/J1rgxO0Mfv+bWS0fv5kj4YgdlfUcG10DMu3/Nse K7PuXND8DgUmp57XU+VHQu5WthraUCFBpVKnbhXnlJSRc8mIz+pUBfEnei7ehQR6GWm8WA dpYe6PZBWboGaPcTwO/C8Fnwx1mhjhX+gW7xvjZ6YHgNFQVHqfNKBC0MoE5SCg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693534254; a=rsa-sha256; cv=none; b=j2+8VNSCPglQa9WTjK3QsQ0HOjPXQt41Dn9c7FOLHyaIy8/KpIdv4keucdCWOYFZYy6KqS MZMbaBt0noF1MWxorPWOvANkrmaAcOoq11ZjgERH2bcTBsTo1KYh/K0oc7CONsEiHgoYRe xdrbdDk9sMl4I4rjmcCDBC0Sk8bQRtnAooPsJyiihfb7msTKkBzOwBQxobM2CCX9UIRUdq xh9LjkLT6A/rIiwMGaGm2EsTUvsywyXV8HxtXGXruR6DyOw3/6c3ViBGPkEoH4Pc1zlIU8 eZySoBBtoYXq4Iuowaj8mrbwSUNqVlCn/tQJelafGDWJFn63N8P4ubNjyGea7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693534254; 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=9MvCiEGwSjDgtXlLMY8cdD+ahKPUnZ66+pKY1O7aBps=; b=ooHLQLNXh5zT9m9aFLDVpIdPiIR4ti+7Lx2fIqaY86Ddv9AG3a6UJ54c+QLKZzzmLD9AGY Rc+aru9LYFVRvjvnV+nYJUQVePAUFYLn7G0ZhtuivH10by0dhUEilauKjwKbwNlAV0kp6o 6+Q6GcmvB9bm+Hasixz52My/covQeWkP+OTVBY9PshMdXL+TXGcF6jALuxsEsaQ+D7klKk 4hK508PDswuc+FR6qS9U6AzZ70U2RksUx3nnVHXTociKXhqSQ3OJMmbsO6tyZsWARZs9vJ adKugnDTTJ4lxC/XWrjl2Cs7gfyYauI8lUI9YBaZ6JnYuOWUHT5Etbc49DeRng== 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 4RcM2Q2k4qzjRQ; Fri, 1 Sep 2023 02:10:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3812AsYG004234; Fri, 1 Sep 2023 02:10:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3812AsLs004231; Fri, 1 Sep 2023 02:10:54 GMT (envelope-from git) Date: Fri, 1 Sep 2023 02:10:54 GMT Message-Id: <202309010210.3812AsLs004231@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 03d104888cae - main - arm64: initialize pcb in the TBI/PAC/etc. fault case List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 03d104888caea595960605a9ff010da7f39133dc Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=03d104888caea595960605a9ff010da7f39133dc commit 03d104888caea595960605a9ff010da7f39133dc Author: Kyle Evans AuthorDate: 2023-09-01 02:10:38 +0000 Commit: Kyle Evans CommitDate: 2023-09-01 02:10:38 +0000 arm64: initialize pcb in the TBI/PAC/etc. fault case After 2c10be9e06d, we may jump to the bad_far label without `pcb` being set, resulting in a follow-up fault as we may dereference it immediately after the jump if td_intr_nesting_level == 0. In this branch, it should be safe to dereference `td` as we're not handling the special case mentioned below of accessing it during promotion/demotion. This seems to fix a null ptr deref I hit during my most recent pkgbase build attempt on the Windows DevKit, though that was admittedly encountered while we were on the way to a panic from an apparent use-after-free in ZFS bits. Reviewed by: andrew, markj Fixes: 2c10be9e06d ("arm64: Handle translation faults for thread [..]") Differential Revision: https://reviews.freebsd.org/D41677 --- sys/arm64/arm64/trap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index 15f1f5e86a08..d1a48a2fd9f4 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -277,6 +277,7 @@ data_abort(struct thread *td, struct trapframe *frame, uint64_t esr, } else if (!ADDR_IS_CANONICAL(far)) { /* We received a TBI/PAC/etc. fault from the kernel */ error = KERN_INVALID_ADDRESS; + pcb = td->td_pcb; goto bad_far; } else if (ADDR_IS_KERNEL(far)) { /*