Article View: linux.kernel.netdev
Article #26290Re: [PATCH net v2] tcp: avoid table_perturb overflow on single node hosts
From: Muchun Song
Date: Thu, 03 Dec 2026 11:13
Date: Thu, 03 Dec 2026 11:13
53 lines
10788 bytes
10788 bytes
> On Dec 3, 2026, at 03:35, Amir Hosseini via B4 Relay <devnull+me.amir.fyi@kernel.org> wrote:
>
> From: Amir Hosseini <me@amir.fyi>
>
> Since commit e67b72b90b7e ("tcp: use alloc_large_system_hash() to
> allocate table_perturb"), table_perturb comes from
> alloc_large_system_hash(). On 64-bit hosts with more than one node with
> memory, hashdist is set and the table comes from vmalloc_huge().
> Everywhere else it needs one contiguous 256KB block.
>
> When that block isn't there, for example after many HugeTLB pages were
> reserved at boot, alloc_large_system_hash() retries with smaller sizes
> and ignores low_limit. The caller is never told. __inet_hash_connect()
> still uses all INET_TABLE_PERTURB_SIZE entries, so the first connect()
> writes past the end of the table.
>
> I hit this on a single node QEMU guest with KASAN, using fail_page_alloc
> to fail just this allocation. The table was halved to 32768 entries and
> the kernel crashed on the first connect().
>
> Switch to kvmalloc_array(). If a contiguous block is free, the table
> comes from the linear map. If not, kvmalloc_array() falls back to
> vmalloc(). Either way the table keeps its full size.
>
> kvmalloc_array() was also proposed in 2022, but
> alloc_large_system_hash() was picked because it spread the table across
> NUMA nodes. That changed with commit a06157804399 ("mm/vmalloc: request
> large order pages from buddy allocator"). Now vmalloc() takes the whole
> table as one block from one node when it can, and only spreads the
> pages when there is no such block. That is the same case where
> kvmalloc_array() falls back to vmalloc(), so NUMA hosts lose nothing.
>
> Fixes: e67b72b90b7e ("tcp: use alloc_large_system_hash() to allocate table_perturb")
> Cc: stable@vger.kernel.org
> Suggested-by: Mike Rapoport <rppt@kernel.org>
> Link: https://lore.kernel.org/all/aw7fxwCeHX5jFYW1@kernel.org/
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Amir Hosseini <me@amir.fyi>
Acked-by: Muchun Song (ByteDance) <muchun.song@linux.dev>
Thanks.
Technical Details
Message-ID:
<5973F1BE-2789-412E-A333-920F7B1C7515@linux.dev>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376506-linux-kernel-netdev=dewy.ruReferences:
<20261202-tcp-perturb-kvmalloc-v2-1-03af5be7b237@amir.fyi>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376506-linux-kernel-netdev=dewy.ru From: muchun.song@linux.dev (Muchun Song) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] tcp: avoid table_perturb overflow on single node hosts Date: Thu, 3 Dec 2026 19:13:34 +0800 Organization: Usenet Network Message-ID: <5973F1BE-2789-412E-A333-920F7B1C7515@linux.dev> References: <20261202-tcp-perturb-kvmalloc-v2-1-03af5be7b237@amir.fyi> MIME-Version: 1.0 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="2469402"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:lq51EEaDpD8jQs9nxGukusnCusc= sha256:FW8oPLuie6tXsVe9qa9E6I+YnH70pYWcRJjEwihZAT4= sha1:TYxs7c8KRUzuJ/xs8YDnvMDFwx8= sha256:PvmgKnhEOTQ43LYYMSfQ0TNPVY3SrY3DVaRD8NGTdqs= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 9DDBD1178E5; Thu, 3 Dec 2026 14:14:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.399 X-Spam-Status: No, score=-3.399 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Oil-7bs5XL3q; Thu, 3 Dec 2026 14:14:11 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376506-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 526E41178E1; Thu, 3 Dec 2026 14:14:02 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 2EBE2251AA; Thu, 3 Dec 2026 11:14:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796296439; b=N//jlU4cZJakbrYXwUAVyy/uXs2g3gtP71f2DnZ9UuYAEIb1XlVI4q9Kl1JvoJoMxGg3 9UZmjXr1pNPNgHVISO6JdPWX0MMwRvlWwHWU1S8ekTOu3jUJT+rzwbNDDR3fD5fZtWbw0 K2CG9o6c1Qo3IFJCgcK3iCI+l3EfaHFsPniuUgtIYmDCOmWyTZLVjlVRvqh2SPYojZ8uu hmw8cN90HvD5xPxSywML4MEECILYnjthPZ3ZJWJZIaoglHP9/MmOF3Ob8PlF8qMa5b22g Z6K31IvHTgLot7pol4iqqArOYAz/yG4+SqEuOdnQm3+Irms+8wQ+rAyVXinGYJ3yMww== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296439; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=T0pTszg9cQCQ6HBtSu6QtN/qiFdANbTWtds4Cqhj8SY=; b=pe+8ozUtCXmY0qYmw3/K2cCcehx0s8hAvXf7bnK8z9jus9DtvZSOYayS4xNPnwJxodwo qt6scfHFqwV6oUWRjoZsdrJXvNvTDFrLDAAAPPbatK86g1k8cGf6kGVpQqqyKqTPRVNyy +31koe3Pd5Qp3Hefb9JyG+rso/1Gz6/F3Hx7TZ8JlHZDrWv6nNXgW6J6a1IwAwaHk7nQj o9y4PGvWqZzgySYd5VdmytXurug/iyv9rBwKE689MuYaFEA+iagxBid0vEK5Detj8AJtf JqXuCFgyqnGHThg407JG3GKnV2StO8knXwet3He/Pqsl6riYye2Bcg6HZNKgvGl7nVQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XHbe0hKq; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25591606A334; Thu, 3 Dec 2026 11:13:59 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XHbe0hKq X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.100 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796296438; b=MVtlaB/mVZuCQM9sA4zctUO5AAwu0CzLAqs0BrryRTL+noBwKbWQyeI/FAZGPoCVQGMP Ame8uQ+GoEm8ufVM8caGL/p0TZxLGLtES14k2LwySw0837sUduPSgNqD4YgjIUm05POqW DNzYGfn3f90/mk6ph9aFB99V0F2mWyuGHwSwtMFr/6sn/Bbdj9142/nKObHtRFJ1wKLAk kGoge00i/kJeLq4GInXIEBoI0PEk8MPbU/4K/Rd9YHmAhl2CkkJjipOhCLFxBkWHwdt6z 9byVPMutxXalAtTCo1tT2g4wwRswBJbXLoZwqYDXNrL05uDc2cJDrHhQqztzHeRibGw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296438; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=T0pTszg9cQCQ6HBtSu6QtN/qiFdANbTWtds4Cqhj8SY=; b=qJuhRgcw0cm/d/GuIK4vCxAoXA+QZfuWvyrI2Oq5hHXvgZeKoTJmeSIMe+KiE4eeQKuK urZmL0E5D1nt+MjRcjnH3DD59DlZJ/UacDmcmJJ55u/yUTM/1jqp/D0Kn+XfiVSbF6S+W zbBLbedLHbjEv3cGUoVZV3zWyB18qB/N1O8xHn9OLpxX5evFyDTfXbokLW5SvESakm+sg pI2WpbOQf03oRY0cgk2GMmPR9YmVrCV2IKcGowCsaOzEXhoJ4VJlVpWOA8zDkj7Dax3RK aicftqYm7zaSBDZRa8c8rlmlKb3U334y7P1vSI/ppzpTqIh4O4a3wMB3PiLrPjOs1lA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XHbe0hKq; arc=none smtp.remote-ip=95.215.58.100 X-Received: from mta1.migadu.com (out-100.mta1.migadu.com [95.215.58.100]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7D8D606A322 for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 11:13:56 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E7D8D606A322 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=T0pTszg9cQCQ6HBtSu6QtN/qiFdANbTWtds4Cqhj8SY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796296434; v=1; x=1796901234; b=XHbe0hKqJ/z2hxrJIT6XL6NdITu6ohAYHPiPbNyBV5x7Y7qnXEQyl/EYpB3utIbsvA6+xMvx EXgqvwLn/pd42vaa4S4/+E4nIIfwHRk7/qUsn2uv18pDyqgWtuVgy4qKZT2acFzWx5/Oei4cQQR m611eRTdXLH/YapxcwCVFvAk= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 1a19c0dc4923c78c; Thu, 03 Dec 2026 11:13:54 +0000 X-Mizu-Trace-ID: 1a19c0dc4923c78c X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261202-tcp-perturb-kvmalloc-v2-1-03af5be7b237@amir.fyi> X-Cc: Muchun Song <muchun.song@linux.dev>, Eric Dumazet <edumazet@kernel.org>, Neal Cardwell <ncardwell@google.com>, Kuniyuki Iwashima <kuniyu@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, Mike Rapoport <rppt@kernel.org>, netdev@vger.kernel.org, linux-mm@kvack.org X-Mailer: Apple Mail (2.3901.200.71.1.16)