From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 491CE313298; Sun, 7 Jun 2026 10:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780827238; cv=none; b=fWXUtGbroCtd0Z7o+UJaw2CtWEMNh5qPCFxloM+EPQ29WefdSgaTX4MqKtUV9+uk5eZklHF1+TgcsAllMUs+QUkDCp9Fw3yUVQAPppmzmnrRx2y+HS8UmIS4U0NhizqwVGOhGWJ+uDmxlfXs/dd6gJq7kDeBEQrktCJJFvo+sWw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780827238; c=relaxed/simple; bh=jRSigBwup/bININSGzpTofe8PWDhpWgFnjEzy/XhNIs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o89KfAkGX94sEw/zFU0x8Qaui7H/PxSWyiVOhD1Gm/Ey5dTpj0cWPi/NMkXL2Ot74k7nzD5lczXoht8sqWpVW/RihN8STAY/f1lU6ipBSgky+MQDnOqnWKdLzABF/6fdfj3mb0L/HvZPJl7ZxHtKB1cxZmjh4EU0Ut3l36ZPN7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Xnj3nZiU; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Xnj3nZiU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EFCF1F00893; Sun, 7 Jun 2026 10:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780827237; bh=UEoALubXXuq+SA6xzqk9TyEKH+u6Mhd/1XVwsmVmFKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xnj3nZiUXnhgy/DI4KAV+7GKjlFPCOjQoaDLXB0xiGFsJt0i3Ko6onug57HF/1VcB WbrHQ9/uVPhEZbFAuLc1t6zs2Y3DPr8i/kqdv2mXX9c9EzP8j+o8q9YmjejyQvQxNm q9CaoHZEcTiZ/TVcf+6j3U4GVxfUaLSR01h0CguE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiang Mei , Weiming Shi , Dongli Zhang , Willem de Bruijn , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12 034/307] tun: free page on short-frame rejection in tun_xdp_one() Date: Sun, 7 Jun 2026 11:57:11 +0200 Message-ID: <20260607095728.925164620@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.647295505@linuxfoundation.org> References: <20260607095727.647295505@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi [ Upstream commit f4feb1e20058e407cb00f45aff47f5b7e19a6bbf ] tun_xdp_one() returns -EINVAL on a frame shorter than ETH_HLEN without freeing the page that vhost_net_build_xdp() allocated for it. tun_sendmsg() discards that -EINVAL and still returns total_len, so vhost_tx_batch() takes the success path and never frees the page; each short frame in a batch leaks one page-frag chunk. A local process that can open /dev/net/tun and /dev/vhost-net can hit this path: it attaches a tun/tap device as the vhost-net backend and feeds TX descriptors whose length minus the virtio-net header is below ETH_HLEN. Each kick leaks the page-frag chunks for that batch, and a tight submission loop exhausts host memory and triggers an OOM panic. Free the page before returning -EINVAL, matching the XDP-program error path in the same function. Fixes: 049584807f1d ("tun: add missing verification for short frame") Reported-by: Xiang Mei Signed-off-by: Weiming Shi Reviewed-by: Dongli Zhang Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20260520160020.375349-2-bestswngs@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/tun.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index fb9d425eff8c1b..19c33d21bab947 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2459,8 +2459,10 @@ static int tun_xdp_one(struct tun_struct *tun, bool skb_xdp = false; struct page *page; - if (unlikely(datasize < ETH_HLEN)) + if (unlikely(datasize < ETH_HLEN)) { + put_page(virt_to_head_page(xdp->data)); return -EINVAL; + } xdp_prog = rcu_dereference(tun->xdp_prog); if (xdp_prog) { -- 2.53.0