From nobody Mon Jun 1 04:10:56 2026 X-Original-To: bugs@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 4gTL9X2XwBz6gHbr for ; Mon, 01 Jun 2026 04:10:56 +0000 (UTC) (envelope-from bugzilla-noreply@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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gTL9X1rN2z3mkQ for ; Mon, 01 Jun 2026 04:10:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780287056; 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=3Vkpi6ltnT0XSQyWdNYPRjC55AlxA5fb9NfP4grsNjk=; b=ZejjjtxvwCdfgitscqI8U8CLJcG/vKmDahx8CPupXLOmcYfp0lcNJev0PzJihIIBJsd0Kj 9lNfXke9/J918vZ4nRlnNlIC5pMFVxHMVpS7B/ZoiuTIgb3p936bx82FCgcipHFgIg1LeU SdCzPp61I65qKeTymeo3t2joKrq85kN69lLBA9OgLceVXLaeC/Wv0P856Ik0k2sc4N6psM W1/HwBSsiGD9NjNA9Rko9lut6Hf+oTXWhUyFk/xbeX3JkltR/w2W6eQ8MGEHHN5ClfR0fL xZQpLt/Ybv/+Rvpdd81XNrg+7RcH4AJjFjjiFrl5ReCQNTanbp00btH1+t2HNA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780287056; a=rsa-sha256; cv=none; b=auJkPXc+51JMkgKTogEW4ptW378k4hxXF/fNz/HaJZ4rjYxIThYdICOk31cWCLrk5f6Eol bnpTf/+3N6CFzi/8405OJROe3YosO9T2m3MIVpvLW3/STNAqCNKZcy1Z5GIuxUFdAJCscp rZderb5niJVM0kPa2FynDDLwGmp7E490cPhHflBp+fZ0SorbTt3uVm1jaNL0awMgb4EXmC jLAquvzuCqSrl+c53w1ZcbUTyhtfn1A5RBLx45BPuQYjE8783L/bqZlusM48AwDhDiKr76 rJ2gu3hqDcS+RAgRcH60MOhdP/rV9hRNuAA6kNVAoStIJTbHDLYaeAoyk8gefw== 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=1780287056; 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=3Vkpi6ltnT0XSQyWdNYPRjC55AlxA5fb9NfP4grsNjk=; b=aXEI/aoI2xsgGnO4BMRqDI6xVRkkWJA6mYx+kGuNoF1fnC9P8lkn9kUIZjRp/6IqWsdlVM 3eRWaxBB3fLKbf+e8MuO9hViFlLuKOevbbjIS5Dj6C5pGoyLB3U/qjAaHZL6kXBauCOCVR cNfrs/7ZSBrFvZm4DJZJ3YOxEZTXmBYb/Rqdbd6wvHzJ19Xx6PMCYUKccJ78ZhGzbuqKbG GoGqnkQDzCIzZsV7BpWib5tNh08gwUEgcp4lUcVLKhEIAHAGxvsUBcPtxzWl8IbNfHxrxg Yzh4hgiNxl9INuUzTL5d/8XAln/RZVA6B9lYXQLUyo2IM8E7/sTmfhCXQDmbyg== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4gTL9X1SWlz6LY for ; Mon, 01 Jun 2026 04:10:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 6514AuAO060456 for ; Mon, 1 Jun 2026 04:10:56 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 6514AuB2060455 for bugs@FreeBSD.org; Mon, 1 Jun 2026 04:10:56 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 295764] ctl/camsim: cfcs_init() leaves CTL port registered on later init failure, causing panic during module load rollback Date: Mon, 01 Jun 2026 04:10:56 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 14.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: lihaoxiang@isrc.iscas.ac.cn X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D295764 Bug ID: 295764 Summary: ctl/camsim: cfcs_init() leaves CTL port registered on later init failure, causing panic during module load rollback Product: Base System Version: 14.4-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: lihaoxiang@isrc.iscas.ac.cn Created attachment 271389 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D271389&action= =3Dedit ctl/camsim: clean up partially initialized cfcs state cfcs_init() registers its CTL port before allocating/registering the CAM SI= M, If any step after ctl_port_register() fails, cfcs_init() jumps to bailout. = The bailout path frees only CAM resources and does not deregister the CTL port.= The port remains visible in CTL state even though the camsim frontend did not finish initialization. This also makes module-load rollback unsafe. When cfcs_init() returns an er= ror, the module loader may call the frontend shutdown path. cfcs_shutdown() currently assumes softc->sim and softc->path are valid and calls ctl_port_offline(), xpt_free_path(), xpt_bus_deregister(), and cam_sim_free= () unconditionally. With fault injection immediately after a successful ctl_port_register(), I reproduced a kernel panic in a FreeBSD 14.4-RELEASE amd64 QEMU guest. Reproduction setup: 1. Build ctl.ko with this temporary fault injection immediately after ctl_port_register() succeeds in cfcs_init(): printf("%s: forcing failure after ctl_port_register() for repro\n", __func__); retval =3D ENOMEM; goto bailout; 2. Boot FreeBSD 14.4-RELEASE amd64 in QEMU. 3. Load the injected module: kldload /tmp/ctlmod/ctl.ko Observed result: cfcs_init: forcing failure after ctl_port_register() for repro camsim frontend init error: 12 KDB: stack backtrace: ctl_port_offline+0x20 cfcs_shutdown+0x12 linker_load_module+0xbdf kern_kldload+0x165 sys_kldload+0x59 Thus, If initialization fails after ctl_port_register(), cfcs_init() should deregister the CTL port and release any partially initialized CAM resources. cfcs_shutdown() should also tolerate being called after a partial initialization failure. --=20 You are receiving this mail because: You are the assignee for the bug.=