From nobody Thu Oct 2 19:19:53 2025 X-Original-To: dev-commits-src-main@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 4cd1p14WhVz69r5k; Thu, 02 Oct 2025 19:19:53 +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 4cd1p13nrTz3G4t; Thu, 02 Oct 2025 19:19:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759432793; 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=bFzTqCHJhp0MHWa+M7mEnnpmNMPlqKfFulwsRUQqeeA=; b=tn2ZXzY6EAGxxPo1aa0iyydux1XvZN/PUumTdpG8yZEMCoyMibWyRcj3UgH1qTEjdm3uMB 2WS7SI8PTXOOi18Cou6zgrR7zBnQrGhOLquhHdfn+cPD9Jxz2u4vb8cLmXpJRKuV0vpgjm Ph2ggy1rCSOmGkcdac493jsjOYCHVXnrU0Jo3p8LPOuVQ3NnYx4DHBgmqW3Ixv4ioLi130 RlF4/EA4VdNFnR3D08T3ErAWvfScNNtXNGXd0nPPVHTwzToDxPcme/7AoOGUcPXHQaUd6S NisgDAemlLP7T0odlRtbjik5grAiqkPCfmXrDqKF36KR4zXwtoTEt8wO6ZupbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759432793; 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=bFzTqCHJhp0MHWa+M7mEnnpmNMPlqKfFulwsRUQqeeA=; b=IFNtoRohPqJCW2IRaONoljiM9G1g7Er2ZhZrSJE1TkVyxGnuSxzrmNFkST9QEQASipd+Dn 3rOfT4DEv93vRbbWyYGmws0QVlBfaF0nRQe4KlTBuAdGNWoL0U1dwnTc/fqp3uhF3Df4tw DmAH2FQQD4PDqo70wCs6qaAFtCdcezOSzTbiKdiW5SUltdWiyqhaZyUvrec+IbWkObhCTc 07o981axSKFgfL0k1PK4UsYMetBat8dAbKC9mYZTtsu3EfDRpEJGnCZW09huZq+PI6wFaA m7BW+6bQlHoAeggQG7b+btTk8VTmI8bmYpMC3xZicx/SvpMWNJFVJGHJUP8m5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759432793; a=rsa-sha256; cv=none; b=Z4pgOtSAomeiZJaSiMY2NMYV/gvokm29fq62YG1WwAux0dO0HSpddqmxlJWHK5ZX1Db50k otL5NzVu9uG8G4U5AkZaw2HnsRG8LLS8e+7u0XdaEXAZJtszQPkYLi4+IIS3qEEacAzsja p9pKA30Rs2CEK5Z0Xm2N5X0ZzkpoK3HTvgwrujF1GOqPK0IPiV2f6xiy9hwm2BL9Qd1WVT 4w+IbTadwXX9p187gotuLRCxQKGY2hqUYyQncUAvJiSN8LMU0EbCTdoI+AtpKkFmUs33LV I93P5yQMtyUzSN4RJ8uFdCPZGsgJ9M1QR8UPd1LBDUfmVBp5On21muqp//Y34A== 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 4cd1p12qgnz5lk; Thu, 02 Oct 2025 19:19:53 +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 592JJrCp098813; Thu, 2 Oct 2025 19:19:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 592JJrfv098810; Thu, 2 Oct 2025 19:19:53 GMT (envelope-from git) Date: Thu, 2 Oct 2025 19:19:53 GMT Message-Id: <202510021919.592JJrfv098810@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: dd2fc08d8543 - main - pf: fix possibe SCTP panic List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: dd2fc08d85431e10ad60e01e97b98e9dc23322bd Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dd2fc08d85431e10ad60e01e97b98e9dc23322bd commit dd2fc08d85431e10ad60e01e97b98e9dc23322bd Author: Kristof Provost AuthorDate: 2025-10-02 14:48:22 +0000 Commit: Kristof Provost CommitDate: 2025-10-02 19:17:00 +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") --- 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 2c6d62078e6a..25ae1193bfff 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); } @@ -7634,6 +7634,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(); @@ -7753,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; } @@ -7786,6 +7788,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; } @@ -10634,17 +10637,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: {