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 01FA34071F8; Sun, 7 Jun 2026 10:06:06 +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=1780826767; cv=none; b=OvRJr6iQx0kdHwOh6t7IYeyDZqNXEDfGGKo6CvqSl2h+RpF9fY9GbKTPGygagTRR20grknVcfZQOofNBB6v1GAVWzz+g2uT4DJsf1K091xwSWp+LiZlJSj9Q7kd6rKyoTODWEaos2+OTsnnyCoooI1G69iVg46xBxVHiOuirjZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780826767; c=relaxed/simple; bh=o9HmAaoxjxC1dblnIuUYYb/jy8KDu67aDB8hpWpK9AQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=klDy46BCLEeuLgtPWky4rfFVBQe9Y9sUBl1q1wyie3apMI+LxzzSD45FhTazmNPKqzTQDc46iPIdPO5oTEXcrk2EaCfwvKsmDPXsIb4ihEUjiVZegmOCJRceYmj2kmcN3gRGiungrYNZEcUacmjVYoWRPZnypmBztUYvhBurfoY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ziNHZ4Iz; 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="ziNHZ4Iz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F36271F00893; Sun, 7 Jun 2026 10:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780826766; bh=Tjyx4RVsGCt4PVsS4TrvAF/hQdBe+Q+V9PxK1nHHhw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ziNHZ4IzFyQJqdX4hKa03Kg+J1beOsmuhMY9LxSm3KNkjTGU0AYxMvbXCcKL5PQK6 rr3/lssCrODAWE8qhBlBdjktTBn15ZwIbrePiyNd2/HgdYaoz2r9kf8/J0QJi/wXci ciJCrTtO3gTR6qmAqHDCFVY35jHT6u0wPB1ASoh0= 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 7.0 022/332] tap: free page on error paths in tap_get_user_xdp() Date: Sun, 7 Jun 2026 11:56:31 +0200 Message-ID: <20260607095728.883581751@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095728.031258202@linuxfoundation.org> References: <20260607095728.031258202@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 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi [ Upstream commit 3bcf7aec6a9d16438f2cec29f5d7c8d5b8edf9b2 ] tap_get_user_xdp() rejects a frame shorter than ETH_HLEN with -EINVAL, and returns -ENOMEM when build_skb() fails. Both paths jump to the err label without freeing the page that vhost_net_build_xdp() allocated for the frame. tap_sendmsg() discards the per-buffer return value and always returns 0, so vhost_tx_batch() takes the success path and never frees the page; each rejected frame in a batch leaks one page-frag chunk. Free the page on both error paths, before the skb is built. This is the tap counterpart of the same leak in tun_xdp_one(). Fixes: 0efac27791ee ("tap: accept an array of XDP buffs through sendmsg()") Fixes: ed7f2afdd0e0 ("tap: 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/20260521163230.1478627-2-bestswngs@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/tap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index a590e07ce0a98c..fae115915c8eff 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -1052,6 +1052,7 @@ static int tap_get_user_xdp(struct tap_queue *q, struct xdp_buff *xdp) int err, depth; if (unlikely(xdp->data_end - xdp->data < ETH_HLEN)) { + put_page(virt_to_head_page(xdp->data)); err = -EINVAL; goto err; } @@ -1061,6 +1062,7 @@ static int tap_get_user_xdp(struct tap_queue *q, struct xdp_buff *xdp) skb = build_skb(xdp->data_hard_start, buflen); if (!skb) { + put_page(virt_to_head_page(xdp->data)); err = -ENOMEM; goto err; } -- 2.53.0