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 5DCC844CF52; Tue, 16 Jun 2026 15:40:53 +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=1781624455; cv=none; b=P+ZqrfRF11X9XYUx961c6umNC5o5tQEnC6z0TIUKbJjoa1cSiJzS5Tjhysu/8cjnYR9VNMPBrKsouc3WTjCld+MaHP8sVgWM6F4/wXv5TTHn17bTuKTSerpB9ErGgsfD9n3zKQvq12AQJGbAWwDJLeJZf5EejAJ9aTJOpSmLkJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781624455; c=relaxed/simple; bh=yf4raD4d3j6q2WSfic+OZyzX30c1KVFJWvtQuq75aYY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i85k22VI8Li79K5Ia3xMiH5AoVdfXTPHNL8moJeqmn3BvtbcbcdF28NefUMW57u/auHArtDMSzzgGKD/7Y+89dPgy3jOpi+ikAgvguAHMj7e4/2oaa/+14ciNWGY4FTwxF0n6KKHe/J/7RAdj02HAxJGW7mTg9LbegP5OnFk+Do= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xucVjo+I; 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="xucVjo+I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF9EB1F000E9; Tue, 16 Jun 2026 15:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781624453; bh=fRzJRujR+HueZybQgM945awLo1Ie5/jVSC8yyuurnnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xucVjo+I7mAkb2RZo5ZKZJELk3wf9jJQlLt1qYFrT9LiDVwB4UKJeDFRyt7mB6pvg Va4ZUDEo8WfZPfcqiGo6BIybzYTB6ifzcBbXu6pL5vxXujsJrwi+O4MmWpy2ExSDSB KG+9mtHBwjsKbF60LIdISYdSroLM5lIrONcChxvE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Usama Arif , Pedro Falcato , Kairui Song , Lorenzo Stoakes , Johannes Weiner , Baoquan He , Chris Li , Jann Horn , "Liam R. Howlett" , Rik van Riel , Shakeel Butt , Vlastimil Babka , Andrew Morton Subject: [PATCH 7.0 306/378] mm/mincore: handle non-swap entries before !CONFIG_SWAP guard Date: Tue, 16 Jun 2026 20:28:57 +0530 Message-ID: <20260616145126.267203777@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145109.744539446@linuxfoundation.org> References: <20260616145109.744539446@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: Usama Arif commit 0c25b8734367574e21aeb8468c2e522713134da7 upstream. mincore_swap() also fields migration/hwpoison entries (and shmem swapin-error entries), which can exist on !CONFIG_SWAP builds when CONFIG_MIGRATION or CONFIG_MEMORY_FAILURE is enabled. The !IS_ENABLED(CONFIG_SWAP) guard ran before the non-swap-entry early return, so mincore_pte_range() can spuriously WARN and report these pages nonresident on !CONFIG_SWAP kernels. Move the guard below the non-swap-entry check so only true swap entries trip the WARN, and migration/hwpoison entries take the existing "uptodate / non-shmem" path. Link: https://lore.kernel.org/20260602172247.279421-1-usama.arif@linux.dev Fixes: 1f2052755c15 ("mm/mincore: use a helper for checking the swap cache") Signed-off-by: Usama Arif Reviewed-by: Pedro Falcato Reviewed-by: Kairui Song Reviewed-by: Lorenzo Stoakes Acked-by: Johannes Weiner Cc: Baoquan He Cc: Chris Li Cc: Jann Horn Cc: Liam R. Howlett Cc: Rik van Riel Cc: Shakeel Butt Cc: Vlastimil Babka Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/mincore.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/mm/mincore.c +++ b/mm/mincore.c @@ -64,11 +64,6 @@ static unsigned char mincore_swap(swp_en struct folio *folio = NULL; unsigned char present = 0; - if (!IS_ENABLED(CONFIG_SWAP)) { - WARN_ON(1); - return 0; - } - /* * Shmem mapping may contain swapin error entries, which are * absent. Page table may contain migration or hwpoison @@ -77,6 +72,11 @@ static unsigned char mincore_swap(swp_en if (!softleaf_is_swap(entry)) return !shmem; + if (!IS_ENABLED(CONFIG_SWAP)) { + WARN_ON(1); + return 0; + } + /* * Shmem mapping lookup is lockless, so we need to grab the swap * device. mincore page table walk locks the PTL, and the swap 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 382AB4657D0; Tue, 16 Jun 2026 17:19:29 +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=1781630371; cv=none; b=gxDYlUtVin95gLyOEjMmD2vpQwVeQ2O+sk/LURcDNM1Q8dM51Ax1XIc5cGtQxrJG4DLCiaL+iAD701tqp5xwws9X7fOqSkQbv50FZHIykL81CLL1uLyo/UjEYCZnbUZyUfLt6VjPbe0gPdkkWo166OXLdWhAIuOD3A0pRu3JiQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781630371; c=relaxed/simple; bh=57EON4Ym8lM/oVzOh5Qr0InksdGtoiBrVPZY21sRxL4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sa1qvCWzcIRK8/a7hqnoNv1dmz5u5CowJXQOK9xOPXH3c1Id2lscfu3/mHqG34mSxvglQHvieEgHSor7Stf8L7p5h5QpZFfZ9wx7JD4AOfJLaBN9vCM4dQ8JWvK/5QIi+rpiNjL6C9BhkVn4mkx+x7hh8DNii5EfnRYvGFk91M0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mTozNr13; 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="mTozNr13" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDDA41F000E9; Tue, 16 Jun 2026 17:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781630369; bh=XBNLP/CkDe+Ijq0k20mMoVovWRzKs5TCn4VL5JTd+Yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mTozNr134kpRJFp2Fnv6G21BNlCuehCTBLoOyRfbKIHF29PLBbX18X7q+TLOhdmzW 70/agrp+LuaUSYOwkHvgKUC7AOlnpzd8c4b5C9nHfzYKLGAGyU7prNGZs1yy08znCf rBIP7gxrLIwUE9aYJNYWiXA6kQ1MErOisH0zWO/8= 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.1 016/522] tun: free page on short-frame rejection in tun_xdp_one() Date: Tue, 16 Jun 2026 20:22:43 +0530 Message-ID: <20260616145126.267203777@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145125.307082728@linuxfoundation.org> References: <20260616145125.307082728@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 Message-ID: <20260616145243.uPanzFHHPEp5a1vs3Jyqgsz8dG2TSOdXnuCbeo3WcmM@z> 6.1-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 03478ae3ff2448..1ad6af74de7c3f 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2448,8 +2448,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