From nobody Tue Dec 30 17:02:54 2025 X-Original-To: freebsd-current@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 4dgfXx5K3mz6MCnG for ; Tue, 30 Dec 2025 17:02:57 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dgfXx4nZZz3CBr; Tue, 30 Dec 2025 17:02:57 +0000 (UTC) (envelope-from glebius@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767114177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=VrxedRPFPZGr/FXZboUO6Zc0mvrdUDRjC7YpDYU4/bc=; b=XlfiQ3mxlPQ1tkZakdFpfrOFzloSPlsuwLNtk65+/8EtKBlSKMnD6PeTRsp8ubUsZWgmAT +Zp5D2y4Em8CnUox26vZM+aTntnwb10wqzVbhexenxvgik5zzgmZpfXANgdoXyX/UAIOJR V89pMxovqh4E3pmRYk/5I6HQicTKiorxsHpwYgWD8WAieRMMmN9Q4FGFFFhCxUQwUH+Nkh p2F1xmaEcWGlRtEJtYEPFMM+qKjWOr9P5jfTwSLSBilDbIHQL5bn4xE6lpIWQ+B66Zj1Q6 OLREwyxXSthm5kmIkKfKcEwzF5DGzuGnemvt4Lk/PrZullvSJDVJb8xHfzqpfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767114177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=VrxedRPFPZGr/FXZboUO6Zc0mvrdUDRjC7YpDYU4/bc=; b=BRs7FtC6xyTNV1gFEwjr8mUJxECWekp3TQa5MXVC4hKbOYYmIwvaBPWPJCpUNcwo3u8k0u yENk3BWPbnNswUEZthiYGzsrqJfGGhZ9H7RmU4Bhe3UqmuY6AF3tdPf8rV9RDk7cyoefpa aKwTirglqFHbyfQ0Rt0OF698kpkZ2B9+VWiYGBJ5MUfChBTfUFf0UTMwsjcjbtn2faGPGK MqsYbhRULnSHobnILjy6rljN8O5bESDqoPFbB8aP4mNxb2oyvqZlwIDiHbugiXKJcAr9ax Vw0rPhSAwuefFRaNoFezs1oin6CptuDa7ViXUlbhv8abtZf3Srw4CwHxE6Vlzw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767114177; a=rsa-sha256; cv=none; b=BfFcpJDLpvr5zm+XRDX97pMAHcpH2kSVKBMO6MPNBg+0ndBdP7ijjr1vSE6JVE5wqnmcRo auconmYj4RKQ3GldPtn+kpGdfxX7ETH2GrNbRQWZuv1GqSLsB9O+u9f61KNhAr/JizXYHS I8JJdb+5gpNMl2NRxGNLsXItNbXYgrjFgPNJP6yXcaTib9SASLcThLg7Vo5XNkx7uh1/yV 2MBn56AW9ZIwSVIwGZNAUebIs30cRxK44VLxhEcoUyVFDWMd7CxY6Re9LFVR74pPmRSMAo L9RJhxrx02kLYqTpElwYXF8oamo6LtLbbDNkTTdN6wX3Ph/grJqzei19orsJqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from cell.glebi.us (glebi.us [162.251.186.162]) (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) (Authenticated sender: glebius) by smtp.freebsd.org (Postfix) with ESMTPSA id 4dgfXx0CNmz1Cq8; Tue, 30 Dec 2025 17:02:56 +0000 (UTC) (envelope-from glebius@freebsd.org) Date: Tue, 30 Dec 2025 09:02:54 -0800 From: Gleb Smirnoff To: "Dan Mahoney (ports)" , Alastair Hogge Cc: FreeBSD User , Ronald Klop , FreeBSD CURRENT Subject: Re: CURRENT: kernel panic in IPFW while stopping jails Message-ID: List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="NRMap2zL894rkLNM" Content-Disposition: inline In-Reply-To: <291e26bfbe2b51835f7672db3a2e3593@riseup.net> <0F907415-3277-4EA9-9D8E-C8D0905EC6AA@gushi.org> --NRMap2zL894rkLNM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I have found the problem, thanks to Alastair for a core file. The problem affects rules with automatic rule numbers and logging. The attached patch should fix the problem, but it is not a final version. Dan & Alastair, if any of you can confirm that the patch heals your setup - I will appreciate. Again very sorry for this breakage. -- Gleb Smirnoff --NRMap2zL894rkLNM Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename=ipfw-log.diff diff --git a/sys/netpfil/ipfw/ip_fw_bpf.c b/sys/netpfil/ipfw/ip_fw_bpf.c index d9897f700d57..2a9f8d889f43 100644 --- a/sys/netpfil/ipfw/ip_fw_bpf.c +++ b/sys/netpfil/ipfw/ip_fw_bpf.c @@ -81,6 +81,8 @@ ipfw_tap_alloc(uint32_t rule) struct ipfw_tap *tap, key = { .rule = rule }; int n __diagused; + MPASS(rule > 0); + tap = RB_FIND(tap_tree, &V_tap_tree, &key); if (tap != NULL) { MPASS(tap->rule == rule); @@ -106,9 +108,10 @@ ipfw_tap_alloc(uint32_t rule) void ipfw_tap_free(uint32_t rule) { - struct ipfw_tap *tap, key = { .rule = rule }; + MPASS(rule > 0); + tap = RB_FIND(tap_tree, &V_tap_tree, &key); MPASS(tap != NULL); if (--tap->refs == 0) { diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index a91fb2e84da9..38e134a21141 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -210,7 +210,7 @@ ipfw_free_rule(struct ip_fw *rule) */ if (rule->refcnt > 1) return; - if (ACTION_PTR(rule)->opcode == O_LOG) + if (ACTION_PTR(rule)->opcode == O_LOG && rule->rulenum != 0) ipfw_tap_free(rule->rulenum); uma_zfree_pcpu(V_ipfw_cntr_zone, rule->cntr); free(rule, M_IPFW); @@ -552,6 +552,8 @@ ipfw_commit_rules(struct ip_fw_chain *chain, struct rule_check_info *rci, memcpy((char *)ci->urule + ci->urule_numoff, &rulenum, sizeof(rulenum)); } + if (ACTION_PTR(krule)->opcode == O_LOG) + ipfw_tap_alloc(krule->rulenum); } /* duplicate the remaining part, we always have the default rule */ @@ -2513,9 +2515,6 @@ import_rule_v1(struct ip_fw_chain *chain, struct rule_check_info *ci) /* Copy opcodes */ memcpy(krule->cmd, urule->cmd, krule->cmd_len * sizeof(uint32_t)); - - if (ACTION_PTR(krule)->opcode == O_LOG) - ipfw_tap_alloc(krule->rulenum); } /* --NRMap2zL894rkLNM--