References: CVE-2026-16529
Description: libpcp: fix integer overflow in __pmGetPDU() (CWE-190)
 When php->len is near INT_MAX (e.g. 0x7FFFFFFF), the buffer size
 computation PDU_CHUNK * (1 + php->len / PDU_CHUNK) overflows signed
 int, producing a negative value that permanently corrupts the static
 maxsize variable.  Every subsequent __pmFindPDUBuf() call returns NULL,
 rendering the affected daemon (pmlogger, pmcd) unable to process any
 further PDUs for the remainder of its lifetime — a persistent denial
 of service requiring a restart.
 .
 Fix: add an overflow guard (php->len > INT_MAX - PDU_CHUNK) before
 the multiplication, returning PM_ERR_TOOBIG for absurdly large PDU
 lengths.  This protects the NO_LIMIT code path used by pmcd and
 pmlogger that is not covered by the existing ceiling check.
 .
 Also add _filter_pmcd() to qa/common.pmcd.pdu to normalize fd=N in
 pmcd log output, and qa/2105 with a crafted PDU exercising the
 overflow.
 .
 Reported-by: Francisco Alisson Bezerra, TIM Security Red Team
 Reported-by: Lucas Gabriel Alves, TIM Security Red Team
 Reported-by: Massimiliano Brolli, TIM Security Red Team
 .
 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
 .
Author: Nathan Scott <nathans@redhat.com>
Origin: upstream, https://github.com/performancecopilot/pcp/commit/ef848fb978d26335f9676933f541c73b58f130a6
Last-Update: 2026-07-25
 Backport-Note:
 Backported to PCP 6.3.8 (applies unchanged). No libpcp3 tree in 6.3.8, so that mirror hunk is dropped.


--- a/src/libpcp/src/pdu.c
+++ b/src/libpcp/src/pdu.c
@@ -658,6 +658,14 @@
 
 	PM_LOCK(pdu_lock);
 	if (php->len > maxsize) {
+	    if (php->len > INT_MAX - PDU_CHUNK) {
+		PM_UNLOCK(pdu_lock);
+		if (pmDebugOptions.pdu)
+		    pmNotifyErr(LOG_ERR, "%s: fd=%d PDU len=%d too large",
+				__FUNCTION__, fd, php->len);
+		__pmUnpinPDUBuf(pdubuf);
+		return PM_ERR_TOOBIG;
+	    }
 	    tmpsize = PDU_CHUNK * ( 1 + php->len / PDU_CHUNK);
 	    maxsize = tmpsize;
 	}
