Article View: linux.kernel.netdev
Article #16467[PATCH net-next v5 1/8] vxlan: vnifilter: reject VNIs outside the 24-bit space
From: Ali Firas
Date: Sat, 14 Nov 2026 22:14
Date: Sat, 14 Nov 2026 22:14
99 lines
15300 bytes
15300 bytes
VXLAN_VNIFILTER_ENTRY_START and VXLAN_VNIFILTER_ENTRY_END are bare
NLA_U32, so neither is bounded before vxlan_process_vni_filter() hands
them to vxlan_vni_add_del():
int v, err = 0;
...
for (v = start_vni; v <= end_vni; v++)
v is int and end_vni is __u32, so the comparison is done unsigned. A
request carrying only START=0xffffffff has vni_start == vni_end ==
0xffffffff and looks like a single VNI; v is then -1, the comparison
promotes it to 0xffffffff and passes, v++ makes v 0, and the loop walks
the space upwards from there, creating a VNI node and a per-CPU stats
block per iteration under rtnl_lock. Any range ending at 0xffffffff
behaves the same way.
Separately, a VNI at or above VXLAN_N_VID is accepted and stored even
though the VXLAN header carries only 24 bits: vxlan_vni_field() shifts
without masking, so such an entry keeps its own rhashtable slot while
being truncated on the wire.
Range-validate both attributes against the 24-bit space, as vxlan_mdb.c
already does for its own VNI attributes. Since commit 599d0e97610f
("vxlan: vnifilter: validate the VXLAN_VNIFILTER_ENTRY nest") linked the
nest to this policy, an out-of-range endpoint is rejected during netlink
policy validation, before vxlan_process_vni_filter() runs and before
anything is allocated. Without that commit the range would be checked
one entry at a time, by the nla_parse_nested() in
vxlan_process_vni_filter(), after the earlier entries of the message had
been applied. How many VNIs a single in-range request may span is a
separate question, bounded later in this series by "vxlan: vnifilter:
bound the number of VNIs one request may touch"; that limit is not a
policy check and runs in the handler.
Make the loop counter u32 as well. With the range bounded it is no
longer what keeps the loop finite, but it drops the undefined signed
overflow past INT_MAX and matches the u32 vni that vxlan_vni_add() and
vxlan_vni_del() already take.
Found by code review: vxlan_mdb.c range-checks its VNI attributes
against VXLAN_N_VID, and the vnifilter policy did not. In QEMU on
net-next (production build, 2 vCPU), VNI 16777216 is accepted and
stored, and a lone START=0xffffffff wraps the loop counter and keeps
allocating VNI nodes under rtnl_lock.
This targets net-next without a Fixes tag and is not a backport
candidate. Reviewing the earlier posting of this range check alone,
Jakub said it was either a security fix needing a stronger check or
something making things slightly better that did not deserve Fixes or
stable.
Link: https://lore.kernel.org/netdev/20260905123900.23984eda@kernel.org/
Signed-off-by: Ali Firas <alishmery18@gmail.com>
---
v5: state the dependency on the applied nest patch, named by commit id
(Paolo and review of v3); name the cap patch by subject instead of "the
next patch"; the changelog no longer calls this "not a fix" and says how
the gap was found and what it did in QEMU (review of v4, sinfo bot);
policy lines wrapped to 80 columns; rebased. v4: no functional change;
rebased onto net-next.
drivers/net/vxlan/vxlan_vnifilter.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_vnifilter.c
index 124ba47758e9..2b02f448c3e9 100644
--- a/drivers/net/vxlan/vxlan_vnifilter.c
+++ b/drivers/net/vxlan/vxlan_vnifilter.c
@@ -491,9 +491,15 @@ static int vxlan_vnifilter_dump(struct sk_buff *skb, struct netlink_callback *cb
return err;
}
+static const struct netlink_range_validation vni_filter_vni_range = {
+ .max = VXLAN_N_VID - 1,
+};
+
static const struct nla_policy vni_filter_entry_policy[VXLAN_VNIFILTER_ENTRY_MAX + 1] = {
- [VXLAN_VNIFILTER_ENTRY_START] = { .type = NLA_U32 },
- [VXLAN_VNIFILTER_ENTRY_END] = { .type = NLA_U32 },
+ [VXLAN_VNIFILTER_ENTRY_START] =
+ NLA_POLICY_FULL_RANGE(NLA_U32, &vni_filter_vni_range),
+ [VXLAN_VNIFILTER_ENTRY_END] =
+ NLA_POLICY_FULL_RANGE(NLA_U32, &vni_filter_vni_range),
[VXLAN_VNIFILTER_ENTRY_GROUP] = NLA_POLICY_EXACT_LEN(sizeof_field(struct iphdr, daddr)),
[VXLAN_VNIFILTER_ENTRY_GROUP6] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
};
@@ -914,7 +920,8 @@ static int vxlan_vni_add_del(struct vxlan_dev *vxlan, __u32 start_vni,
int cmd, struct netlink_ext_ack *extack)
{
struct vxlan_vni_group *vg;
- int v, err = 0;
+ int err = 0;
+ u32 v;
vg = rtnl_dereference(vxlan->vnigrp);
--
2.53.0
Technical Details
Message-ID:
<20261114221412.255825-2-alishmery18@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363477-linux-kernel-netdev=dewy.ruReferences:
<20261114221412.255825-1-alishmery18@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363477-linux-kernel-netdev=dewy.ru
From: alishmery18@gmail.com (Ali Firas)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v5 1/8] vxlan: vnifilter: reject VNIs outside the 24-bit space
Date: Sun, 15 Nov 2026 01:14:05 +0300
Organization: Usenet Network
Message-ID: <20261114221412.255825-2-alishmery18@gmail.com>
References: <20261114221412.255825-1-alishmery18@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1675411"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CTUQhyISOORarvMFHnOD0wAp/DI= sha256:1mlXsNz8PstIwejF7E2tSFPvVOrmHy9X4tBtNOIqIEk=
sha1:ISCqFIPd5aK3EWfSPdG1Jidcve0= sha256:z46sbo3mxPJpgQ285v/OLmzLCVViNNCf3F0evZquIHw=
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 7BC301148F7; Sun, 15 Nov 2026 01:16:19 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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.249,
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 (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 bNPeUZQEKn_h;
Sun, 15 Nov 2026 01:16:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-363477-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 830AD116028; Sun, 15 Nov 2026 01:16:07 +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 73AAD33972; Sat, 14 Nov 2026 22:15:52 +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=1794694537;
b=4HcHBDPrT5B4H0O5ASoLpCCYbnYShf69cU8Qafp5d6Shq+DgoE5/mL3YxnYxA1nhmF3T
hvd6w8gvsPxNfLC3zuwMDWrGZHgtjxEHClzU9j/4pHGFR7PYS+J92Plb8zfJcaHEdWCQm
TsexKZ9r9uaTchmFV9cIe9n5e5U78mdZ8l9WHVwBJvEJST/ekoM7Bo2gXUWjnOGkOSf52
SWcqKNc+H97+hmrzT081FYvPOAE9ZhQJ1WO8sgGcCgGBxH2ygP4KsM9G/fPZPKem8H1sm
tXpwn3LKb7mUmowYzc1Hu2po7OfGzqj3iyNklihNWv+4YXWQ10ORsk7lpdRj4RyU6CQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794694537;
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:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=sFCil6/GykmHC8UZ+eSxB0rc3OAECvi79g/NHfkD1vc=;
b=xdFMDx9nRK5ctuyonGbPrXkwpIIc6Nm+y6M69EgBcNZriLqVA3mlgj4NwuuEvNVX6zTE
jli7nDcuKIg9NdWg3cDNXbNNig8D7O+Oh4Ilq/XtqoREMDjC19c+qWGFhp1M67SimjObu
nKLNmYA7b3Sw+RRhgWL2IeWZA8vUaxwlVK+wJ+IPl4hbPJKhOlED0URtWsdmWAdBLDYcC
oaqxV6UUeVSfqAJ0kX5BDfjyjjofY1F4u9IADBBbZtgqvGT/R1xMlxrDUzsrOfDfNrXyE
ynWfy9x9UlLYNYvxbCizwPSaK3Ligf6xemcL/5ZM4MwNu7QyHe/fW5ct579fO/ku6yA==
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=20260707 header.b=kdIQm6En;
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 58B4C606A89F;
Sat, 14 Nov 2026 22:15:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=kdIQm6En
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.53
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794694536;
b=Ia9fJM6EP1fWX7uRU5X+E2GvPcDbIfJlbUtCbAZBFt1+1dh6Ezp5M4MTsa9qGUm6nqWT
2miQr42AcrY6l4Om+FxjOBHmuYF3R55PXv2lYDOsM+lyMuSJ2nNc2rzDhdFz25/uiif6T
VpTERPJHf7dQIDop94EL7rlFmPw1laVhZH0wCsi721YJqBh+/EomhVq1OUg7NnKMZZ45g
ize74kwtMQRg4Thsw5rR3s4C4JcaH1U7YkX/gX/m9Th+eUJgjr3sj2W3P6JWE9ZHYGvPo
PNUsySnTGlKP+H6MoEnWD9XA2iNKgZ2sfOJFBOsJM8jpDOIXQssQmmE4VMg1K+IlJZw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794694536;
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:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=sFCil6/GykmHC8UZ+eSxB0rc3OAECvi79g/NHfkD1vc=;
b=tFHk6TfLfL2G1oEGZ0y4KAjkkmQZLaZYHn/DgfekrrvMT2uXw4XpPhh1PYgnqmeSUhoi
JGWG0pR6QgCCDugnKFs4lS9WG0KelCZTFL/N3QzmroWgJX0FfFTFwXSKdVEUp9joH/H7h
Ta7F5WIZJcy6labvqEAZIV6U7Q9m4HyKy7JU3KoL2VM1B/ZvtKX3cFlg97sGspI1/tgQ7
ncSvyxa0SUqRkuurPvMH8ZSlfLpUtXqQ4J9eBBEqXqXqZ8G83wJIYFbAY06/PBgxUMcK0
m9k0iur25JkPgPx2LXKKrkXeQiZPlWI6AgZCud6WTB6tHZWWLygVQBd6Wgnc2VSXbow==
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=20260707 header.b=kdIQm6En;
arc=none smtp.remote-ip=209.85.128.53
X-Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53])
(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 D65C1606A894
for <netdev@vger.kernel.org>; Sat, 14 Nov 2026 22:15:35 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D65C1606A894
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-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4a207b02a2cso11916795e9.1
for <netdev@vger.kernel.org>; Sat, 14 Nov 2026 14:15:35 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794694534; x=1795299334; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=sFCil6/GykmHC8UZ+eSxB0rc3OAECvi79g/NHfkD1vc=;
b=kdIQm6Eno9IUfOMTOu8gndMuAs02BU2lSZB4SE1JJ0QophMAJF6Yowsx7p9Y+QlcCg
kMrrQGfi4vH14yn/H1RziG363GHfFRfvBlYINIPtTn77YUvMeaIJHQzYNTj5X4lXHs+7
QB5lCvQzeV90uRiDrejM1eBiaj9RpG1f/isUqLYfZFjUjyl2zTwbu3OHOZxFuToEd8U+
WQATOqMZ4EkHyoTBM9ToJI+cPYR9YnGtDjORBdsQtJ/ImXUhX0tgmydJZgR4d8HcF77e
6gGlAQBcZq3flcLXg9kCgc2wGaBk5kMywdelpvB5afNYq6QdtIIulbsk0dp+LIb1S3J2
gxZQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794694534; x=1795299334;
h=content-transfer-encoding:mime-version:references:in-reply-to
: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=sFCil6/GykmHC8UZ+eSxB0rc3OAECvi79g/NHfkD1vc=;
b=ZAGgsdtKLIHV9GcHRoMJKL/Scf8ldT9fi8tmiwodoNTvLNu0t0EQU6EITbZu13Y72L
ewU5v81dwx0M8HFzUGIh4ulinvYMyZlCOaICdu6ydtRNhsEC9hlqQZ0Dkq0t7+r2lj8O
toQ31OWVr0YPmZc2nJ0n2iSPLpYyNS/7ftYtO2UrdhqKwD977slnmFLpmysu1QhxEG33
aEq2/CJyjK07WFhk8d1wzudut/WwdEGmMqRQlFATnnLTvUr78wTRmGKrIrn5jW1v8/H0
+dhoJmHHmTgTYr9pnNydxz8dNawqiKQKtXlDmaT/WuFHQV/WXrECQ0sLBMYxgcyBceQR
+d5w==
X-Gm-Message-State: APuU4Z+GK6Pxvf0iFixkhu+dutusaCS8p6NREiJ3TJpeNHwko8yI7ehT
+tmm8aLXH0e1w8fAQjHAUEGN8Di78ZtyWhvFU6mtgIM94UsMQSndujXJJN3V5BgCujw=
X-Gm-Gg: AYBFou29XPZ17jNv1rAn1UmrTamjJStkroSENhYwcTHX73jDsLwQ2zr0qSGvlhjcZhe
MsoV37+Urgxny1v42FaRVX1Y7k8IOyFH7MYYzjjqHQYYHOdXdreG8P8MwXjniT5V8nL+OJY7YDT
/xznFcPRZM4iBXXeCwbQvvm/7+25QV+5BpuzxoNvxNu46AkCudc7AYZ9G8OJTm60krrdPr68bFR
ngUvPLauVSInFYKm0NWWqUcOzNm6d3Hp93A8TYNMrMEWLSbv1spEKNVIAGoWcXGc7go0q0zoAbL
5sdmLRDY2xakJtTrN1+wGV9x7dMrWl/OisNEv/vCL6zwN73qR7Sy9rbjWjT4ozMU2rqO/ZAxhnQ
66ebz1aJM9wnZ/d1+HTuO+1qgk4SMR84ixKbA9PuULSUbQjjVXVs0vF0AO6La4grZxEzBQK7eQB
9KPliwDVzGHbnSy8Kz4mwBLjrSMtnwQE1LILBpppMYOm/obhT19ydf1f0k6zRlnlHHEUfOc4Z0c
jdGZ4AjdR0pi+5QnrQ8U82D9cXV8RAXNgu9Kg5tvGwcFQ7YD60l+zhWq2OqsL5nv2XgPAJCy/GM
uWfBtEV0E7WU+apwSu47w8BaJvBb6NYnKVnObZxdzh7caw==
X-Received: by 2002:a05:600c:3e19:b0:4bb:665f:7e52 with SMTP id 5b1f17b1804b1-4bb665f8108mr45213385e9.10.1794694534138;
Sat, 14 Nov 2026 14:15:34 -0800 (PST)
X-Received: from kali ([169.224.126.250])
by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c5d223a29sm13514941f8f.8.2026.11.14.14.15.30
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sat, 14 Nov 2026 14:15:33 -0800 (PST)
X-Cc: kuba@kernel.org,
pabeni@redhat.com,
davem@davemloft.net,
edumazet@kernel.org,
andrew+netdev@lunn.ch,
horms@kernel.org,
razor@blackwall.org,
roopa@nvidia.com,
kuniyu@google.com,
petrm@nvidia.com,
aroulin@nvidia.com,
shuah@kernel.org,
linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Ali Firas <alishmery18@gmail.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261114221412.255825-1-alishmery18@gmail.com>
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