From nobody Thu Nov 23 16:08:05 2023 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 4Sbjh61D4Pz51nZN; Thu, 23 Nov 2023 16:08:06 +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 4Sbjh60MJ4z4QYZ; Thu, 23 Nov 2023 16:08:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700755686; 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=SnQKMtuVawv2w4fGCRFNFw/cLVopuVCQYyJAw98S1rg=; b=rG2mcR0J0MZRFZNmxRN3B6JwE0vOr/gc2MG33AHxhdSyfMdLKic/DN/aO/hZKfp0XxOE6M MH+mLiZzWjl0VnX5UzojfhiIxyjg+FiAObLuxcjjOEFZViwsJVCq3UnzOR0vhSG/zIoAEG cXRWyX1gYbRAemBERDuhf6gP9TDQUZNfQW6cy0tH3vW7DOom+KAbceoAR/JssMSPGHS8GG LnZ7Db6Dckz153ry8dIda27vaJ2L8Wp8m2LvAXE78dT0CeD2SVsTd08YLQh1b6snMO9IUs QsM92GV5UKiAvfObt8O2wTKBxscS638KBTI0KVFsywArTbI7gVOTvslSC0a9/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700755686; 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=SnQKMtuVawv2w4fGCRFNFw/cLVopuVCQYyJAw98S1rg=; b=RSkxP0Gs8zif0KcAGoQoV3R/QOde9zK4LeM/OFKK7HYtbZ1/ZAVwoeFHm64teAxF+MiWzS mS/x/xWjrOozL6hD9P+qZ3wwWhtxmqwG/w/pH5lHOiXOkH5lVjTkPwRwxS/vuK+xAgOFmQ WOi1+D9jsiyEERmvIhmSPthYLBaBr9exJFq61lsISq328MOoStPowwDTP61Erwflq0A28k Rr3IS71MCBzVm3d/L1jWR+VudH8g5dO2raCOvEB2TDNcKN2KPh36RMbAW5SW8wH1SZx4pt pGAHoTLp+GSydm+JtR+H+QI/f4fZzHkehODuDO2FaVbkUEzoGjLxQWsgHV9QDQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700755686; a=rsa-sha256; cv=none; b=XuZz5geABCaCa6X3NuqEaRxPzC1j0U/wdc+VN41OzRVIBXxWwCMl+4380KnJ+vVkv/qCuT egNySz+BniZ5p4KM23J/k3xKpPvKA8lQtpXnLDZpFTIuzEMD2rh3h1wurcQHF6PDsTW9J3 7I/9t7f4re1ZS/2p2HhJUb8ywjFilXxT/tMAs561oKpKQt3Ap34w2/UoYL9NIAHM6m1vEv cmTeoRLcrMzHUmhpHJhGAezAnuVHSGlv1Ij2sPQXTFlkO4yg3IMYY2FFpijcTTU4QG8duV RHX8JZdYWCilFqyBC2iMKGGMKnz1A888xlHosxRYfsy9FrhCdcPLK7lQYJEXUg== 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 4Sbjh56HdTz16ny; Thu, 23 Nov 2023 16:08:05 +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 3ANG85Qj007758; Thu, 23 Nov 2023 16:08:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ANG85dQ007755; Thu, 23 Nov 2023 16:08:05 GMT (envelope-from git) Date: Thu, 23 Nov 2023 16:08:05 GMT Message-Id: <202311231608.3ANG85dQ007755@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 4e78a766f607 - main - kern_reboot(): don't clear kdb_active 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4e78a766f607192698514d970ff4e9fa91d0482d Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=4e78a766f607192698514d970ff4e9fa91d0482d commit 4e78a766f607192698514d970ff4e9fa91d0482d Author: Mitchell Horne AuthorDate: 2023-11-23 15:28:26 +0000 Commit: Mitchell Horne CommitDate: 2023-11-23 16:07:43 +0000 kern_reboot(): don't clear kdb_active It is possible to reach this function from ddb via the "reset" command. When this happens, we don't actually exit kdb, meaning we never execute the latter steps of kdb_break() to restore the system state (e.g. re-enable scheduler). Therefore, we should not clear the kdb_active flag in this function, as the debugger is still active. Put differently, kern_reboot() is not an authority on kdb state, and should not touch it. The original motivation for this assignment is not clear; I have checked thoroughly and I am convinced it is not required by any reset code. This fixes an edge case where a panic can be triggered during reset from ddb: 1. Enter ddb via keyboard break sequence (KERNEL_PANICKED() == false && td->td_critnest > 0) 2. Execute the "reset" command 3. kern_reboot() sets kdb_active = false 4. A witness_checkorder() call via shutdown handler sees !kdb_active and panics Reviewed by: imp, markj MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42684 --- share/man/man9/kern_reboot.9 | 7 ------- sys/kern/kern_shutdown.c | 3 --- 2 files changed, 10 deletions(-) diff --git a/share/man/man9/kern_reboot.9 b/share/man/man9/kern_reboot.9 index f8513c0adf18..c86e9a6cbdb9 100644 --- a/share/man/man9/kern_reboot.9 +++ b/share/man/man9/kern_reboot.9 @@ -96,13 +96,6 @@ variable to .Dv 1 , indicating that the reboot process has begun and cannot be stopped. .It -Set the -.Va kdb_active -variable to -.Dv 0 , -indicating that execution has left the kernel debugger, if it was previously -active. -.It Unless the .Dv RB_NOSYNC flag is set in diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index b69caebe17d9..ea86a7e24d06 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -492,9 +492,6 @@ kern_reboot(int howto) rebooting = 1; reboottrace(howto); - /* We are out of the debugger now. */ - kdb_active = 0; - /* * Do any callouts that should be done BEFORE syncing the filesystems. */