libpcap: Fix CVE-2026-18313

NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-18313
Upstream-commit: https://github.com/the-tcpdump-group/libpcap/commit/f9775af1a0ec76db60c7213241e6b48f1be10ac7

(From OE-Core rev: 6cdcaaf4c347a32d5408653f8eb343c8e4fb04ff)

Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Paul Barker <paul@pbarker.dev>
This commit is contained in:
Jaipaul Cheernam authored and Paul Barker committed 2026-10-19 09:03:19 +01:00
1 parent b4a184a4b7
commit 358a044360
2 files changed
+85

No files matched your search

@@ -0,0 +1,84 @@
From f9775af1a0ec76db60c7213241e6b48f1be10ac7 Mon Sep 17 00:00:00 2001
From: Denis Ovsienko <denis@ovsienko.info>
Date: Sat, 1 Aug 2026 18:24:48 +0100
Subject: [PATCH] CVE-2026-18313: Fix a memory leak in rpcapd.
This vulnerability was originally reported publicly, hence no credit is
given.
daemon_unpackapplyfilter() can allocate a temporary buffer for up to
RPCAP_BPF_MAXINSNS (8192) BPF instructions (65536 bytes) per each
received RPCAP_MSG_UPDATEFILTER_REQ or RPCAP_MSG_STARTCAP_REQ message.
It never frees the memory, so repeated messages from a client will
eventually leak enough memory on the server to cause problems. This
holds for all connections that pass the validation and some connections
that do not.
48 bytes in 1 blocks are definitely lost in loss record 2 of 2
at 0x4844818: malloc (vg_replace_malloc.c:446)
by 0x111AAB: daemon_unpackapplyfilter (daemon.c:2372)
by 0x113279: daemon_msg_startcap_req.constprop.0 (daemon.c:2139)
by 0x114808: daemon_serviceloop (daemon.c:901)
by 0x115BC7: accept_connection (rpcapd.c:1321)
by 0x115BC7: accept_connections (rpcapd.c:1118)
by 0x115BC7: main_startup (rpcapd.c:709)
by 0x1112BD: main (rpcapd.c:567)
To fix this, after a successful malloc() return exactly once, after the
free() call.
(backported from commit 26a1c75702b105ac8788014f35f1b5c57fa6043b)
(cherry picked from commit f9775af1a0ec76db60c7213241e6b48f1be10ac7)
Notes on backporting to 1.10.4:
- The upstream CHANGES/changelog hunk is not backported.
Upstream-Status: Backport [https://github.com/the-tcpdump-group/libpcap/commit/f9775af1a0ec76db60c7213241e6b48f1be10ac7]
CVE: CVE-2026-18313
Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
---
diff --git a/rpcapd/daemon.c b/rpcapd/daemon.c
index 9b0f8285..b0268688 100644
--- a/rpcapd/daemon.c
+++ b/rpcapd/daemon.c
@@ -2378,14 +2378,8 @@ daemon_unpackapplyfilter(SOCKET sockctrl, SSL *ctrl_ssl, struct session *session
{
status = rpcapd_recv(sockctrl, ctrl_ssl, (char *) &insn,
sizeof(struct rpcap_filterbpf_insn), plenp, errmsgbuf);
- if (status == -1)
- {
- return -1;
- }
- if (status == -2)
- {
- return -2;
- }
+ if (status == -1 || status == -2)
+ goto free_and_return_status;
bf_insn->code = ntohs(insn.code);
bf_insn->jf = insn.jf;
@@ -2401,16 +2395,19 @@ daemon_unpackapplyfilter(SOCKET sockctrl, SSL *ctrl_ssl, struct session *session
if (bpf_validate(bf_prog.bf_insns, bf_prog.bf_len) == 0)
{
snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "The filter contains bogus instructions");
- return -2;
+ status = -2;
+ goto free_and_return_status;
}
if (pcap_setfilter(session->fp, &bf_prog))
{
snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "RPCAP error: %s", pcap_geterr(session->fp));
- return -2;
+ status = -2;
}
- return 0;
+free_and_return_status:
+ free(bf_prog.bf_insns);
+ return status;
}
static int
@@ -22,6 +22,7 @@ SRC_URI = "https://www.tcpdump.org/release/${BP}.tar.gz \
file://03-CVE-2026-31911.patch \
file://04-CVE-2026-6244.patch \
file://05-CVE-2026-6554.patch \
file://06-CVE-2026-18313.patch \
"
SRC_URI[sha256sum] = "ed19a0383fad72e3ad435fd239d7cd80d64916b87269550159d20e47160ebe5f"