From nobody Sun Oct 05 20:51:46 2025 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 4cfvhf5x8Kz6BfmG; Sun, 05 Oct 2025 20:51:46 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cfvhf5Qmmz3vrW; Sun, 05 Oct 2025 20:51:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759697506; 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=3vvKmv9gx15d21iYt2JdhQEXKGTqi3xOzG+A0vtj+Eo=; b=CWBaqG4hxVoaOihOZ06PXBxkHhbQbHxi/n6U2MJ/UNMnsz57PQZzyiySIswccI0PmAxfmT z/0mYWpsIQHiAuBeKpHd9UE64Ik4nFszuSuTtuuu4F0gk7asnjXK3oV2x5uK7A7F23T/4h Cgp/t2udFfdLlHtRcRavF6p0isug2kYpp3ROhZkC8bbNZYN8kPCr6HG9sSeI7s5hpz4jQ7 KzhT166epbXvNLpFW7NGXn1O0nS2TGjFB0+SnYqqfXDjx2HWZiUVZlyQBGG7yRhfRZqMY4 N6duGUqnVUu5lBzAxE563sN4xASVJ0ECMbmYHmKAmIZyZ9xYd+mU+luJbmLW3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759697506; 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=3vvKmv9gx15d21iYt2JdhQEXKGTqi3xOzG+A0vtj+Eo=; b=hCSNMJEpZtIMvzRM14kfiAWVwojh8ECJ6JULAeUMXlHBHWO/orlzMuJUbniBsGQXFMYSXq OzeWlFRqSgy/mdatEBn0Vramypbko4vE65123vd19nrHTmt//xtWFaBQaP+Lm9C3h6n50t WFcrR4e7Cf9I6Y4xhCUn4CFsxVWiq95GuNg9NJ51ABCmOmk2zaaYWWU01lqyhH0VV7e8L/ 62ABbRrJSkBCutK+WkPzaVm5CpFksCZXp6T1NvTG91axvh1m1VcGjLB5+clv4VMiqxoC9p XxQOG0wWml3X52sqDKuoHoRI/24FeSh+06FiPPPngsimAnnxjVP2cwBBsbwlUw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759697506; a=rsa-sha256; cv=none; b=gNHp93mZbL+VpG3bRNRficgwoz9li9w3ul3HEwnBcWVMybpwBYrKoopfYUDCvGBIMUOz1O 7sKVFe/9NxsquSDI+9r61na6JGQAsaoYIXDexhiKIr7bGpgRqXOB9T25RUqFGOr6hn+mgi iWir4S4dAHeAxPqZMKD0Ho770DPfuuglo+ljWlSfPSieuVfKTHT4pFrbzjZLf5ozxfFDRa +tfRRkOdkY7GrzWFHawUp0eNLCd30afPQ0KBRvKpQb9ONGIR5netmF1s/VjmgFr/hCvSC7 Aq8K8aj8V/F0iTQrYuFmHFAJ+z4XdTHO4TgWqlx45aguOFYA+wwDcbwdMsNNhQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cfvhf50CrzCkF; Sun, 05 Oct 2025 20:51:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 595KpkLB039907; Sun, 5 Oct 2025 20:51:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 595Kpkgr039905; Sun, 5 Oct 2025 20:51:46 GMT (envelope-from git) Date: Sun, 5 Oct 2025 20:51:46 GMT Message-Id: <202510052051.595Kpkgr039905@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 48cbd5698d9b - stable/15 - pf: fix possibe SCTP panic 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 48cbd5698d9b4d807fdb1f9c52e3431877c1f1ac Auto-Submitted: auto-generated The branch stable/15 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=48cbd5698d9b4d807fdb1f9c52e3431877c1f1ac commit 48cbd5698d9b4d807fdb1f9c52e3431877c1f1ac Author: Kristof Provost AuthorDate: 2025-10-02 14:48:22 +0000 Commit: Kristof Provost CommitDate: 2025-10-05 20:47:34 +0000 pf: fix possibe SCTP panic While processing SCTP packets we can enqueue work for later, in the sctp_multihome_jobs queue. This deferred job includes a copy of the current struct pf_pdesc, which must contain a valid pcksum pointer (in case of NAT). However, jobs could be enqueued before we'd actually set this pointer in pf_setup_pdesc(). Set this pointer before we scan the SCTP chunk headers (and could enqueue deferred jobs.) While here sprinkle in a few more assertions to ensure we got this right. Reported-by: syzbot+974d0fb7e53c9aa31b90@syzkaller.appspotmail.com MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit dd2fc08d85431e10ad60e01e97b98e9dc23322bd) --- sys/netpfil/pf/pf.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index fb13f22bf0b1..8f151e3167f6 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -3364,7 +3364,7 @@ pf_change_ap(struct pf_pdesc *pd, struct pf_addr *a, u_int16_t *p, u_int16_t po; uint8_t u = pd->virtual_proto == IPPROTO_UDP; - MPASS(pd->pcksum); + MPASS(pd->pcksum != NULL); if (pd->af == AF_INET) { MPASS(pd->ip_sum); } @@ -7600,6 +7600,7 @@ again: nj->pd.m = j->pd.m; nj->op = j->op; + MPASS(nj->pd.pcksum); TAILQ_INSERT_TAIL(&pd->sctp_multihome_jobs, nj, next); } PF_SCTP_ENDPOINTS_UNLOCK(); @@ -7719,6 +7720,7 @@ pf_multihome_scan(int start, int len, struct pf_pdesc *pd, int op) job->pd.m = pd->m; job->op = op; + MPASS(job->pd.pcksum); TAILQ_INSERT_TAIL(&pd->sctp_multihome_jobs, job, next); break; } @@ -7752,6 +7754,7 @@ pf_multihome_scan(int start, int len, struct pf_pdesc *pd, int op) job->pd.m = pd->m; job->op = op; + MPASS(job->pd.pcksum); TAILQ_INSERT_TAIL(&pd->sctp_multihome_jobs, job, next); break; } @@ -10579,17 +10582,21 @@ pf_setup_pdesc(sa_family_t af, int dir, struct pf_pdesc *pd, struct mbuf **m0, REASON_SET(reason, PFRES_SHORT); return (-1); } - if (pf_scan_sctp(pd) != PF_PASS) { - *action = PF_DROP; - REASON_SET(reason, PFRES_SHORT); - return (-1); - } + /* * Placeholder. The SCTP checksum is 32-bits, but * pf_test_state() expects to update a 16-bit checksum. * Provide a dummy value which we'll subsequently ignore. + * Do this before pf_scan_sctp() so any jobs we enqueue + * have a pcksum set. */ pd->pcksum = &pd->sctp_dummy_sum; + + if (pf_scan_sctp(pd) != PF_PASS) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); + return (-1); + } break; } case IPPROTO_ICMP: {