From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.100 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== 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== 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 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 ; Thu, 3 Dec 2026 11:13:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E7D8D606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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-Envelope-To: netdev@vger.kernel.org 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 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 Content-Type: text/plain; charset=us-ascii X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Subject: Re: [PATCH net v2] tcp: avoid table_perturb overflow on single node hosts From: Muchun Song In-Reply-To: <20261202-tcp-perturb-kvmalloc-v2-1-03af5be7b237@amir.fyi> Date: Thu, 3 Dec 2026 19:13:34 +0800 Cc: Muchun Song , Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Mike Rapoport , netdev@vger.kernel.org, linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Message-Id: <5973F1BE-2789-412E-A333-920F7B1C7515@linux.dev> References: <20261202-tcp-perturb-kvmalloc-v2-1-03af5be7b237@amir.fyi> To: me@amir.fyi X-Mailer: Apple Mail (2.3901.200.71.1.16) > On Dec 3, 2026, at 03:35, Amir Hosseini via B4 Relay = wrote: >=20 > From: Amir Hosseini >=20 > 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. >=20 > 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. >=20 > 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(). >=20 > 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. >=20 > 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. >=20 > Fixes: e67b72b90b7e ("tcp: use alloc_large_system_hash() to allocate = table_perturb") > Cc: stable@vger.kernel.org > Suggested-by: Mike Rapoport > Link: https://lore.kernel.org/all/aw7fxwCeHX5jFYW1@kernel.org/ > Assisted-by: Claude:claude-opus-5-5 > Signed-off-by: Amir Hosseini Acked-by: Muchun Song (ByteDance) Thanks.