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 8A2771DE8AE; Sun, 7 Jun 2026 10:08:10 +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=1780826891; cv=none; b=XY55BU++wGqWwItQwoKsgYQdw/I2OHTA4bgi/g1Z2ql11/CEB5zw7tGDahzC7oHOlMXM6cFGU3tT2j8vR7s9nF7VqQr2iikNSpgc+JGmJTmKbnyAAkKFIavODLBYZVuUOudH/8jh/uAdZBER0Zqngjd1zyOf3oWKGMNg4ZppLxo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780826891; c=relaxed/simple; bh=PFoCUWaYjgVnl8azmYs7RZaAm/y3dVsMngdyvzpnlOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rWhVJU/YI117iHlomy+u/wgB6NnVKbtF44ID76h7ZpUbvYGhXKEethJxC0FkV4lVcTTiUuVYjNzjLoXI/yBgpMz2pScMNAaGVr+RvlDRkBhmEURwRPKgQYjrTjap8oRGFzLVT6oml1wXhtg47P+xxIuNHwmx08NWTmhNhJw+6vk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=i/Xf/Th+; 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="i/Xf/Th+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D281B1F00893; Sun, 7 Jun 2026 10:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780826890; bh=SJNTW/w9m6sltcXGpVvWjlwNrj3AqwKIkP2yBUelgaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i/Xf/Th+QRN8d0hboYJHU7CEZLYQO1vqDNvsIWqj8vMT49Hi9IOjBX5tojgknYWQ7 qUK3lWvDHivUDq+6kMV95u6ygobCkQXaGkweZRvGKoMFqvUCTUc5uS4V2r4BwlYTeL wW3Ob26jTWYOkuuTratwSouaOc3FvMJpPbkBMuZI= 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.18 020/315] tun: free page on short-frame rejection in tun_xdp_one() Date: Sun, 7 Jun 2026 11:56:47 +0200 Message-ID: <20260607095728.235630824@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.528828913@linuxfoundation.org> References: <20260607095727.528828913@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.18-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 8192740357a09c..afba37965ce3b7 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2392,8 +2392,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