From nobody Fri Dec 8 22:03:11 2023 X-Original-To: dev-commits-src-branches@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 4Sn4rv5wcLz53V53; Fri, 8 Dec 2023 22:03:11 +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 4Sn4rv4KYbz4TGv; Fri, 8 Dec 2023 22:03:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702072991; 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=YGF8mwbRk9/Vhi/Tz9PTK1LSk/mEDe4iGLPKFq/al8g=; b=f1DlUY0W/aZuOVffcGi02JuX2xgmh0Dcb6bSX9OsjX7JAbAwtktssrLlrM4J6JaFAywzQi nTpYjyunvj4UW13Z5MEfJMoYYSeLaJjIW+vxA1Coc6oe/ryhajmbiZW2t3+d/PywjQ0Qmi t+ujt/xJic1c3FGNwmrxVyA0TU8vXdeyRnalYg80hev03WLwHi6TpsIU08W/0sox/JLOCA uW/UbxrgCL6h7PgPEn9GP2Lc3/FJXVFS6/yhslrnKL/1W3klpZ9haRruVnICNXnrwAOWR8 BSOGUP5vtfcP1fCFnCoIbEoYd4KHV9261qit/0/E617p60ROdI5WF7LvU0v+6Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1702072991; a=rsa-sha256; cv=none; b=MTJ6osyW1XVLwTTy77YCN3ImovSe3f6UwYVpUh2wgcOprRIv9LJeOEwFuUvBU1RlAAhtbf p72/QKGiuUV4kWGQgmDFdSSr0DxXIwqe49AFVTXOc59VxOxn/0dJrEPMf28Wo7qdPXZ6kc 9nTDKZxUVbuRSyYfPyns/CeqrM5UX+g0CYoAAjsQtvX6Lb0iljMT5fX1WLvqstiQ4xlB7Y rwU958TPNP/LEvEutjgqldXRaLhNt3kXOphIV0CNhq9EhlydRsBYVKDJ2C2/Xi4StjuuwX I747q3cSelt37bxj1OMks7vbDHUJxAAabKgSwdBIbZz2kWMl6dH7Dio4ppXHyQ== 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=1702072991; 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=YGF8mwbRk9/Vhi/Tz9PTK1LSk/mEDe4iGLPKFq/al8g=; b=tCGEV8wn7dsUcCw69FDM+KvmqTRtd0Ujmcto3PsGpQSM7BZJzbd/juQM20ViX3z6I6fAm1 JLWNRgL2bzAe3ZHsdZdohlQm3Wca4SGMb8qEeo7NS37Fbtj/kBc6+DpGwQqtRNZT2Jqn5B mqJIQAWt60QsAdXuRldxq3CrYFhEECAMiV5NVDA4S3ns38cQcYtSIf405yxEKcvXsBJq8j aW0oh9lGxcCrfkQfD0Czyg2RElZ+mUyqV0ShPxUUdwMMyEy1FAbNiB7N4VaxB1luKyPsg7 M7Z+yoTM+RuHDs83r6c2lwd2tYN2WCS0dD82FIBExqMK9V03vasz/sWtM/8KfQ== 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 4Sn4rv3Kk4zdXF; Fri, 8 Dec 2023 22:03:11 +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 3B8M3Bq7021106; Fri, 8 Dec 2023 22:03:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B8M3B51021103; Fri, 8 Dec 2023 22:03:11 GMT (envelope-from git) Date: Fri, 8 Dec 2023 22:03:11 GMT Message-Id: <202312082203.3B8M3B51021103@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: c27113379e1e - stable/14 - kern_reboot(): don't clear kdb_active List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: c27113379e1e3d2b906c09be1070dcfcf942cdee Auto-Submitted: auto-generated The branch stable/14 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=c27113379e1e3d2b906c09be1070dcfcf942cdee commit c27113379e1e3d2b906c09be1070dcfcf942cdee Author: Mitchell Horne AuthorDate: 2023-11-23 15:28:26 +0000 Commit: Mitchell Horne CommitDate: 2023-12-08 22:02:45 +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 (cherry picked from commit 4e78a766f607192698514d970ff4e9fa91d0482d) --- 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. */