From nobody Tue Jun 2 09:15:16 2026 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 4gV4tF1Mdhz6fMTw for ; Tue, 02 Jun 2026 09:15:17 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gV4tF09hRz41RY for ; Tue, 02 Jun 2026 09:15:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780391717; 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: content-transfer-encoding:content-transfer-encoding; bh=jt2Az3zb7EDsOpGmPkLBsF3KPuAcgPOCSzQ9Si3i3nE=; b=NbgZ7PDaWCNfzpH7YsrFjEfyzukdoxpejTAfqjgyGSodAEq/dy9pjomt8Q6bG0p4qtYZW3 FY7CRc307KxMLJlzIOXbTJPhpG056oRowslSt0wuEON9RSk95ClGgNC/EUQvXL18E5N1+J +s0n9UVuZohKsVXywySdJY1L50+rsMS3fUmCWypsqpf9y9jxwjtJKIrhcwAcC7W/LXhcYj lA0MLLUJSYhYx6Q4nM/3ghitlvaC2HggwOMw4YWCrLV8YZNBRO5LD6q7ytu0eb73/m5HpA oFN0WbYh4hdKllex5sGSu0SNcKnCsDTWZr0uGhpp4kDMMvp8VzC+erJJAc+YYQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780391717; a=rsa-sha256; cv=none; b=UmAQE4O+8rS+zfifJRd9RY05gtFnOB5NNCF/Xht57NGcr6G/VXysVnhfVzYsmFdzaHqark 239C5Zz5VR43+c6I4GujzfWgRpcc1POesHIxAc3G6aIPOzFQL8mZ3urFTN3cEKEgyH2BWH AJAP4+14z7+kozwZgcDlCI0H/NtiwjygpisxS4gJAtgqyzcpQnEyVmFLE0VgoU22VpBoRz m6vrqw/W5JJGFJkTg1x8aNHT+TO/WtwRbu59gAgOx4FOA5qsFlvySg/arVNgwf2/fTl2OF V9blaAOErVzqgWpxN4HF9/69Dnjpr+Y00uUH28mVE6iaCJoFJkA+FIWGj/gZhQ== 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=1780391717; 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: content-transfer-encoding:content-transfer-encoding; bh=jt2Az3zb7EDsOpGmPkLBsF3KPuAcgPOCSzQ9Si3i3nE=; b=KLbB72fgWuEIEGBP5Yol2jV/u9KYKTfAqhdIRDWVKrNRcGjZCIMTzQQsUdL+XkqzOvVvqJ 2/NhFWdA7gwMc1uvVTeUHnyrrbd9ioPVK2aDkNvSTqSS2l7kauC485400EFPbMpILfEqNP tJD3plE7kuIXMF6Qi0VHbvI0okM1DHhwt0yma41ZB+eYBPr4w0FbBJwZVdA9LEsBWIEaNy 4eZS4DiZrCOABywUtjPk9cFfKnsJeuZ2rxP0cikYnCdbgwStmW3QFy6Y1nmk99xlIE/OO2 zXV7Gjr90nnIxwH157kHL7jULriL1FhfX95UgPxTZI5Fgd6scYo10Kbnqzx4Hg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gV4tD6bBmz3sW for ; Tue, 02 Jun 2026 09:15:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3415d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 02 Jun 2026 09:15:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Teddy Engel From: Pouria Mousavizadeh Tehrani Subject: git: ea4888e63f6a - main - nat64lsn: Fix type confusion panic when using wrong NAT64 instance type 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pouria X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ea4888e63f6ac89c38982ffee693f89a5927e9c9 Auto-Submitted: auto-generated Date: Tue, 02 Jun 2026 09:15:16 +0000 Message-Id: <6a1e9f24.3415d.3521dad4@gitrepo.freebsd.org> The branch main has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=ea4888e63f6ac89c38982ffee693f89a5927e9c9 commit ea4888e63f6ac89c38982ffee693f89a5927e9c9 Author: Teddy Engel AuthorDate: 2026-06-01 16:42:56 +0000 Commit: Pouria Mousavizadeh Tehrani CommitDate: 2026-06-02 09:14:26 +0000 nat64lsn: Fix type confusion panic when using wrong NAT64 instance type When an ipfw rule references a NAT64 instance by name using 'nat64lsn', the kernel looks up the instance in the shared srvstate[] array without verifying the instance type. If the named instance is actually a nat64clat or nat64stl instance (created with 'nat64clat' or 'nat64stl'), the code incorrectly casts the instance to nat64lsn_instance and dereferences the ->cfg pointer, which causes a kernel panic. The root cause is that all NAT64 instance types share the same srvstate[] array but have different struct layouts. For nat64lsn_instance, the field after 'no' is a pointer to nat64lsn_cfg. For nat64clat_cfg, the same offset contains an embedded nat64_config struct. Fix by adding a type check after NAT64_LOOKUP() to verify that the instance's etlv matches IPFW_TLV_NAT64LSN_NAME before proceeding. If the type doesn't match, return IP_FW_DENY to reject the packet safely rather than crashing. Signed-off-by: Teddy Engel PR: 292023 Reported by: pouria Reviewed by: ae Pull-Request: https://github.com/freebsd/freebsd-src/pull/2249 --- sys/netpfil/ipfw/nat64/nat64lsn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/ipfw/nat64/nat64lsn.c b/sys/netpfil/ipfw/nat64/nat64lsn.c index 1bac425afc30..9d2ee5e650df 100644 --- a/sys/netpfil/ipfw/nat64/nat64lsn.c +++ b/sys/netpfil/ipfw/nat64/nat64lsn.c @@ -1731,7 +1731,8 @@ ipfw_nat64lsn(struct ip_fw_chain *ch, struct ip_fw_args *args, if (cmd->opcode != O_EXTERNAL_ACTION || insntod(cmd, kidx)->kidx != V_nat64lsn_eid || icmd->opcode != O_EXTERNAL_INSTANCE || - (i = NAT64_LOOKUP(ch, icmd)) == NULL) + (i = NAT64_LOOKUP(ch, icmd)) == NULL || + i->no.etlv != IPFW_TLV_NAT64LSN_NAME) return (IP_FW_DENY); *done = 1; /* terminate the search */