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 88AC23CF97E; Tue, 16 Jun 2026 18:06:19 +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=1781633180; cv=none; b=ozZidq9OIQVBUqAyyQNOd11hnP9qo6x+nMIvIMAHgHhtL9PwGjY+Yl7vekKujSo7I8MWgCavI4ALM4VT9WgPkwghKyReADY1DFTcPMHAS4X+3wEORRK7R5j6bZnD2a542YxyF/vhUaVQkmTmiMAGX0xOfQq4Z6QpkQCXw4AmMvM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781633180; c=relaxed/simple; bh=RM555ANUHfa0zcO6ZrVt3IsNsvvk28DDv2ojxL48QTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gX1j2ZIKU8PT7eqW4napVVsim5H8A6T9Mn13Nlm2gSd5tbX+L4DxvyGF4mD3Cdqw+9DHrpQm9re1tKQrvwr/yexytBoIqQhUwnzK9K0YqcY7JW11vl15OCI7fInF/TUTvGYKB41aJW0Oh5Da99wXsgJbccYKOBwu9qvXylPqFnA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ICEqbgEO; 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="ICEqbgEO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C59F1F000E9; Tue, 16 Jun 2026 18:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781633179; bh=oni1496l7cdFaqA8PFLo+5fRJSqSZCjinAD4P7Fd9cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ICEqbgEOBT8HNueR1memkcZOKwbXz1Q56yGnJzMi7rL0m1GU9W7xc+IK7OjFmXnbb jIP6cfai5ph9jDHhhzDOfEiyZef8+ErJgGvbVCbPf55OQd+4VxY3DjOFHZRK6Q+EfE EfKhdeLZ24ICKxzIKruuR0fuNl+Atjroa5MRUNSA= 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 5.15 015/411] tun: free page on short-frame rejection in tun_xdp_one() Date: Tue, 16 Jun 2026 20:24:13 +0530 Message-ID: <20260616145101.188523738@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145100.376842714@linuxfoundation.org> References: <20260616145100.376842714@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 5.15-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 5c9e7d0beffa26..803cb4722dbf4a 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2422,8 +2422,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