Article View: linux.kernel.netdev
Article #6066[PATCH net] net: reject flow_limit_table_len values below 2
From: Dudu Lu
Date: Wed, 21 Oct 2026 15:55
Date: Wed, 21 Oct 2026 15:55
74 lines
13465 bytes
13465 bytes
flow_limit_table_len_sysctl() rejects non-powers-of-two but accepts 1,
which is 2^0. A length of 1 then gives log_buckets = ilog2(1) = 0, and
skb_flow_limit() computes hash_32(hash, 0):
include/linux/hash.h:68
return __hash_32(val) >> (32 - bits); /* bits == 0 -> shift by 32 */
A shift by 32 is undefined and, on arm64/x86, the "hash" becomes the full
32-bit product val * GOLDEN_RATIO_32 -- an unbounded index into a
buckets[] flex array that is one byte long inside a 289-byte allocation:
UBSAN: shift-out-of-bounds in ./include/linux/hash.h:68:24
shift exponent 32 is too large for 32-bit type 'unsigned int'
__ubsan_handle_shift_out_of_bounds+0x11c/0x208
enqueue_to_backlog+0xbe4/0xc44
netif_rx_internal+0x130/0x4d4
The subsequent read-modify-write at dev.c:5443-5446 is an out-of-bounds
write into the allocation (also observed as use-after-free). Require at
least two buckets so log_buckets is never 0.
Fixes: 99bbc7074190 ("rps: selective flow shedding during softnet overflow")
Assisted-by: LLM
Signed-off-by: Dudu Lu <phx0fer@gmail.com>
---
Tested base
-----------
Detected on Linux 7.3-rc4 (commit 93f51579e7df), arm64 QEMU guest.
Re-checked against mainline f47d223627f8 (v7.3-341): the affected code
is unchanged between the two, so the bug is still present there.
Checked against linux-next next-20261021 (commit 9a482184d910): the
affected code is unchanged there as well, so the bug is still present in
linux-next too.
Reproducer status
-----------------
A reproducer was written and executed on an arm64 QEMU guest (KASAN + UBSAN);
UBSAN fired at the claimed sink. The reproducer source is not posted here per
Documentation/process/security-bugs.rst; it is available on request.
Triggering conditions
---------------------
root (flow_limit_table_len and netdev_max_backlog live only in the init-net
net_core_table, absent from the netns table).
Notes
-----
Built and checkpatch-clean: this patch was applied on top of 7.3-rc4
(commit 93f51579e7df) and a full arm64 kernel (defconfig) was built with
it -- no new warnings or errors. scripts/checkpatch.pl reports 0 errors,
0 warnings.
net/core/sysctl_net_core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index eb35da3556f4..bb0fa69f94f5 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -283,7 +283,12 @@ static int flow_limit_table_len_sysctl(const struct ctl_table *table, int write,
ptr = table->data;
old = *ptr;
ret = proc_dointvec(table, write, buffer, lenp, ppos);
- if (!ret && write && !is_power_of_2(*ptr)) {
+ /* A length of 1 is a power of two but gives log_buckets == 0,
+ * which makes skb_flow_limit() compute hash_32(hash, 0) -- a
+ * shift by 32 -- and index the one-byte buckets[] array with the
+ * full 32-bit hash. Require at least two buckets.
+ */
+ if (!ret && write && (*ptr < 2 || !is_power_of_2(*ptr))) {
*ptr = old;
ret = -EINVAL;
}
Technical Details
Message-ID:
<20261021155505.67208-1-phx0fer@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350092-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350092-linux-kernel-netdev=dewy.ru
From: phx0fer@gmail.com (Dudu Lu)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net: reject flow_limit_table_len values below 2
Date: Wed, 21 Oct 2026 23:55:05 +0800
Organization: Usenet Network
Message-ID: <20261021155505.67208-1-phx0fer@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="4189995"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:L5/YBfkSloH2lQcrfjl3sV53feM= sha256:jwzjFcVIAM16eliQeLJ2rNavq5zFIQ3fPCQ7cbeWq44=
sha1:PkmFnV2vEh3u2jj34BD/2QwDbzg= sha256:kNxtG142v1KqyZCNcxC7AOftCFgb+rwhxXG87JKntl0=
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 92D13111069; Wed, 21 Oct 2026 18:59:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.047
X-Spam-Status: No, score=-3.047 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
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 82lE8OJxPT8r;
Wed, 21 Oct 2026 18:59:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-350092-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id E3C57110F5D; Wed, 21 Oct 2026 18:59:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id 147642C10A; Wed, 21 Oct 2026 15:55:14 +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=1792598113;
b=TUJ4Y580Ebi7zkuNBqpwDB7nFrWHSMj+reJtOgY4NHuzz8+U06YHYVzKaAsxlqWPlkh0
crgMnmHeGIv6gUJCli43naPNfql1bqnfExaPZXXSq3mHN5N6ImDpnd4KCrNO+GjUHoNBG
63BzFdl2X7MaSOMJlvKCRe0xMk+bR2x1+AeHIaE5sNEmmVwSIbO/qRcpZqgHWvtrrSB9x
F6qdElVm1bf85L5ktviR2diNOY1Ig3udwglSlJpUuhm1gDZka17GAyGChLLlq8XYp/3Lm
VPCVrIO61i65ti8RuBykRNGTcrAB19rrif/+tFlSLXZ9DwrbHHOml30dgWrZe7Cahkg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792598113;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:Content-Type:
Content-Transfer-Encoding;
bh=eWU2bVlaO64KjekmMIRHMOpynADD/F8s5EOK5FvSh1I=;
b=s1PAklwVjQPsBGShqmnCaorUauzuZckyyg+v5xnfCVOL+/Mt9rny1SCdCUliIH5/FP5y
kDTZc/3vnChKzh/TDpjLj16Qm3c/b5iAyJ+FcCrk/0QGP29bebtbJn3IPK60h426JX0oC
TPICoizPma0OlMDhsf8qbYV/wXqPWXLLp9SZBZ5kMWTh6KvmHNGLIZTzjFZVFQzV+9iJG
TCuX3JxrX+tY6NdrXSVaVtKbcOmutqSxkp6DwJPxVtK6AkPdbpgkme7oYbZRWCv4G2+cy
6w4gngcL4/EMFkWGFwTLu7z/dVwKPQTV0LiVeoFfSUI47+xbT4s/utKjxpaSrVNSAvw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=AGwbTHXu;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 56E31606A321;
Wed, 21 Oct 2026 15:55:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=AGwbTHXu
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.47
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792598112;
b=j6HHpPOwkzbeQJTMD+ljfaP5P3+PRySwf9o/aL9UFLseAa423fLaJxfizNNd/OHmERyE
7+ngQN/0axuKTCkHFEOTexa5pHFKFBx5Q4T8Qz4jcRahWzpQhCERo4nBI9ki8ov4g8zP+
asTFxDFuCNaKM3RJ8stdp78KNpFLsQpoDXcfu3NMSMsrSIOKHTCW1isOx+UffpZHOFXQN
SAyBPzb36G4cHbpkPvWzIjA0+07uYQiyrYjEfFxPJUf2fUkQcQ08S83yM4HCUV1CaIOTy
D9pcgt3oP/YK2l11vEeRAY8EgESS08yOS9UUiBdTQcrEKKjMN67XlaxJQz3X8AjZxHw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792598112;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-Id:X-Mailer:MIME-Version:Content-Type:
Content-Transfer-Encoding;
bh=eWU2bVlaO64KjekmMIRHMOpynADD/F8s5EOK5FvSh1I=;
b=b7PbWTfDmajRQI8aIrQcLsCTbScERAqX+1hVL1+v2EgHiSNZhY2cNm9S0ZKmmaQ7alQz
YRG0FxCBVBIyTL+q0mUt356U8/tqjpprGym+NB4LcKt1ZDvTFHDmpe3KKxAGi+NIbD6Nq
9SdsjRv6MXpCFr6/Nr/tH8FCGFJgcJuYe0PAfFqSI8umDf/YXSNHtORnUhHjRASuBD6xy
51eBRy60AMWNlCZYlgoHMNPFCuYfN7AjB9kH3scCE6YrBe2nXFk0fFd0/c8p/H/ZlL4L7
qwMddwTMLnexhhBE2YYe82b1sfVOaOtZvLDYGprxsmhmty5x7bdJzvWBxgvgrmIOuVw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=AGwbTHXu;
arc=none smtp.remote-ip=209.85.216.47
X-Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47])
(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 23522606A319
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 15:55:11 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 23522606A319
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3ab9268d90eso571349a91.3
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 08:55:11 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792598111; x=1793202911; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:message-id:date
:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=eWU2bVlaO64KjekmMIRHMOpynADD/F8s5EOK5FvSh1I=;
b=AGwbTHXuya85RfypvX6CFIjkACpyctue6wii2WjTQ+ldve+tEzx65iAiEC2DbtA+FF
IcTT9THDgYhB8F6M+A3Rzz6w6Rumo3JmpE2iEumgv2yxiWY9kaaID1t84QxZPAVQuF44
61WDZ9epkpDwWYH8RMfpPPbhBmDaz3ro5rwaL1zhb/Glax+gYYuBnuYMc8dD3ibqkXAY
bU7fTfDwBFXFyoBru/RtbNPwifh1CmFH5YGQbLuSTlBKk5snjFABHZgBQvmuPjrwmvVP
ETix/cvnewbZae4ZJPxkm4h95Zu/MQcyhg6jOvmNASfKfiw9slFaq4uWh0fQ+0Iq7hNG
Y7Ew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792598111; x=1793202911;
h=content-transfer-encoding:content-type:mime-version:message-id:date
:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=eWU2bVlaO64KjekmMIRHMOpynADD/F8s5EOK5FvSh1I=;
b=nClYdkUV6yqSf37hyskdP58/+IlxU1M+dchmelNdv+w1xTqbGKSrT0oybzKg/4KKd6
HZKWmrWNt+4KpAwghhUsUD6KfkrVQcmqyGs3DsJeB/mKhw6sysM5o0+w/TGI/8+cD514
sIhnMYCafY2cxHy1O3T69SxpXJX/LkSHYJ03oDKrVlPJe+p26lYXPBcHlL2d1n9Za889
1KirmMdkxGFSxkI0j3teFVYxEFZltmU/OqP+39FE/m71+LsHkpdoV0kIZlYJyAcK/vUv
jC2I7GWYifI/HroznCfc1G6p8gw0W78YDz1ntysAbkOyctsQ1eBPTYhWyu9NWHtKFBxu
A35A==
X-Gm-Message-State: AFq9FYJBI2RtPrW3j12T6GTbXY/vrNW4RetqrkaL6v4n3MABXnoQPCkb
ZxOQ0bPeJYnSBenIuOHvcWpM7M1exrPUCi7kL1QZVtcxj1iEatRjci8l
X-Gm-Gg: AYBFou02PUc/adVsF4Gk97KR1+f/9QmFAlyrbr66CC72tVfpyzPqWxb4B3ZxpyCO5r3
rFtbnLmCOsbww3rJAH+rt5zjq0uymTChI65W2Y1f0yz7fjZjYNID3D7DLlalc7w7Sa4HfvIEQp7
cz9//omHGRTXAIzeUWiN+KUvscpXv18eh04Z+vlPmhPopTYAo5VUpDhJXMTM1CBkP+wmbEQGE31
ik0ed4uqfRO2WfvksqhZf9QNTs56ZBjZ0pegLV4DG4pYW2e3mC6n+0+cgio+VmoJNo+XatrmWeh
DlCe87E73VWWVQaofGQL4bHBMVY9Oxoe3PdjIVFkBr8rIKlQ27bnZkqtDpQPEmLf3AvCzajUyma
2gFgLsyx9NbBpQTYPWmwaMJ2D3RFHdtB+NYFo7J6MqD2PBxkzGqIA7o1iRZqFoKoGrLgEBFnj6m
WvNK1lRhyv70ITYxwllfX0iBEWEYQObpkyvqXnEch3W8WVQN8oXY/Xy1m2R3yDPXoZqlj7BvTnQ
uDPYesGeKqBbTUyOuNPCk6PG937g113l5MXVcliUo3Rs0JLFD3o/MeCaWI8RbBkD2v+1CEPEUeE
GvsFvoqq47uisG+vwDKHrS9UKdMfRCN6eiUItm+FbI7JkXpyAC8UztN5jG8=
X-Received: by 2002:a17:90b:3cc7:b0:3ac:d19e:85f1 with SMTP id 98e67ed59e1d1-3ad86d7e7b9mr1991380a91.53.1792598111346;
Wed, 21 Oct 2026 08:55:11 -0700 (PDT)
X-Received: from localhost.localdomain (69-172-67-073.static.imsbiz.com. [69.172.67.73])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ada49544f1sm60771a91.16.2026.10.21.08.55.09
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Wed, 21 Oct 2026 08:55:10 -0700 (PDT)
X-Cc: netdev@vger.kernel.org
X-Mailer: git-send-email 2.39.3 (Apple Git-145)
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