Article View: linux.kernel.netdev
Article #12993[PATCH iproute2 v2 1/2] ip route: use the request size as the limit when adding encap
From: Fang Jiabao
Date: Mon, 09 Nov 2026 05:32
Date: Mon, 09 Nov 2026 05:32
60 lines
10739 bytes
10739 bytes
iproute_modify() passes a hardcoded 1024 as the size limit to
addraw_l() when it adds the encap attribute. The request buffer is
larger than that, and every other attribute in this function is bounded
by sizeof(req). With a seg6 encap of 60 segments the request still fits
in the buffer, but addraw_l() prints "addraw_l ERROR: message exceeded
bound of 1024" and returns -1. The return value is ignored, so ip sends
the request without the encap attribute and exits with status 0, and a
route without encap is installed silently.
Use sizeof(req) as the limit, like the other attributes, and return an
error if addraw_l() fails instead of sending an incomplete request.
Fixes: 1e5293056a02 ("lwtunnel: Add encapsulation support to ip route")
Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Fang Jiabao <kaquoin@163.com>
---
Changes since v1:
- use sizeof(req) as the limit instead of 1024, as suggested by
Stephen Hemminger; keep the check of the return value
- rewrite the commit message to describe the cause
- add the same fix for ip nexthop as patch 2/2
v1: https://lore.kernel.org/netdev/20261102090535.226168-1-kaquoin@163.com/
Tested on current main (d95f6650, "man: ip-neighbour.8: document
protocol keyword"), in a network namespace with a dummy device, with:
ip -6 route add fc00:ff::N/128 encap seg6 mode encap segs <N SIDs> dev d0
With 59, 60 and 62 segments the route is added with encap, exit status
0. Before, 60 segments printed an addraw_l() error and installed a route
without encap, exit status 0 (observed on e4cd9f1d, the only commit
since then changes a man page). With 63 segments the result is
unchanged: error from lwt_parse_encap(), exit status 255, no route
installed. I did not find a way to make addraw_l() fail from the command
line after this change, so that error path is not tested.
ip/iproute.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/ip/iproute.c b/ip/iproute.c
index 1ce71f78..067569c2 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1525,9 +1525,10 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
lwt_parse_encap(rta, sizeof(buf), &argc, &argv,
RTA_ENCAP, RTA_ENCAP_TYPE);
- if (rta->rta_len > RTA_LENGTH(0))
- addraw_l(&req.n, 1024
- , RTA_DATA(rta), RTA_PAYLOAD(rta));
+ if (rta->rta_len > RTA_LENGTH(0) &&
+ addraw_l(&req.n, sizeof(req), RTA_DATA(rta),
+ RTA_PAYLOAD(rta)) < 0)
+ return -1;
} else if (strcmp(*argv, "ttl-propagate") == 0) {
__u8 ttl_prop;
--
2.43.0
Technical Details
Message-ID:
<20261109053209.65753-1-kaquoin@163.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-359034-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-359034-linux-kernel-netdev=dewy.ru From: kaquoin@163.com (Fang Jiabao) Newsgroups: linux.kernel.netdev Subject: [PATCH iproute2 v2 1/2] ip route: use the request size as the limit when adding encap Date: Mon, 9 Nov 2026 13:32:08 +0800 Organization: Usenet Network Message-ID: <20261109053209.65753-1-kaquoin@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="280993"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:aA38Dk4wCfgQVi1BUDqe/xWn4P0= sha256:oSDfmzZtHPvZ4vl6rJid42NJvfChMvaOght1BR5MwQ8= sha1:aVMd4VCzHCy64vdrRYn4DGutXsk= sha256:AlrXYV9hPmbSIlHMH/tyImIhjcfKqcnbOiafDDuxAWo= 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 BB5AE1136DD; Mon, 9 Nov 2026 08:33:25 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.048 X-Spam-Status: No, score=-3.048 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, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.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 7dXYsodnbMxO; Mon, 9 Nov 2026 08:33:21 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359034-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 3133F113461; Mon, 9 Nov 2026 08:33:12 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 37E52A6414; Mon, 9 Nov 2026 05:32: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=1794202370; b=Er6GVPZi0pujBDrzOeEL6hOb2TfPsXfwy9lrz9BsHSwoCS3jSZ4aqVBJzjYSSwNx8CLH kmiy8FjWoKajH1FSKpAxrmd4EWrzcvIUxUrY6PTSwVX3+dEd73w+l7PeDGNC+PitcGGYi MHQllYfkKb+rqGmQz7cgFXeCyT0C/Sve1EZxRuDprQM95z4g3qHrM4YNE5Cv0H+avFzH4 vGGKgptJ3rAq+GpSubstAC+Rayyn4bSSXIjw7kBq662jqRRzIXf0eSJsrFz7sv3jD9vMx 83UfrjRVw/HMeBO34G//ALU0+rZdUWn7oI0sxZL3YtG9+615geBg5HRA8tb2AqH4Gig== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794202370; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: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-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=fSsd+Jru8TwrsZ00/xFyxEW8a4AeXr5gmncXZGNMYGw=; b=gzrX8y3ZnBrW2scXu73KIJbUms6mJD8riCYihDzxc3S/zMf67g6r1ahcK+B+BtGWwP6m Rkyl+Kpi002GBcc6nzUijz8elfShQY5MZa7eCkaj7aBQQZt+sNXwAE+PExACNEQYLoI6j uuVxmoasAuqBLDEIXpgp92aK70q6Lpi+Ng92YF1EFjQynHXIzugCcDeJloe9WjTIzhgVj IynD8tazX93QWC5nGXyuqhZLxSCcShm2EWocxl5HTKRo7UCVp7mQysIpBLiFgBv+MqG3s v0mlEny0W0gmJuniFfRsKAGvczvrwRPP7tOaBcx8+4lwxsNXdR/YgWccts2CQVJCulQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=JgdmZiKz; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.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 662F6606A323; Mon, 9 Nov 2026 05:32:50 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=JgdmZiKz X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.4 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794202369; b=YjyjJ2AHWF8oDY6iIuQ4NqQ89Hx89+KLveX05d40VtgsZKSpQFJqAjOWsgEob+OZiszN 24F5ZkkSSMnsZfGBQjHbzGrT+E0sMiE1Li/tuhyPVnDo887p7o/V+WGBgk+uKaVYR/L/s nXPDXeVkqkC8Dr+JRVs7pbo5cFaT6xHl0GaB2Ru48FffAybZAuziqVermhXLt0aJYBfaG lniNe6338r+Yb8/XBMklNElmVw+tdqnYLl4cuEtzQ9ES7nqqV7IihHvcEJDd48NrDQfVk Hvz1dwbG8YQJ94jte/gBdf7Kanhd+AT6nnUoRn4gmQZQROnmd8bA7NAJ+9YYQixTiGw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794202369; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=fSsd+Jru8TwrsZ00/xFyxEW8a4AeXr5gmncXZGNMYGw=; b=UlFW2/yGHaKnftwipsy4hOclbL0C35KarGJGj30a1jEO7BjUklbvtYlDloMdyQH6CIrf ycwbAOxqLYSWaUc8GhViU01dbjAMAk/RNgwuwUs2tii3odZkclXgiHLe2MghdbCUwX5C5 kV4eBQTFeOR9408GdADqAyrkZ5NNgXfRvz+MEW61EzOl99KH5FG7O3aytxCWJKGNDQA8v 0RZvbda8LbUg1f235EhnnPaH/9gemgUPwEseAqdODjlLIjpC4Ehn9p4jt3xfdTlIdts/e KCwVhdfyQS7Q4hTuLQJ6qL2IU77CMcSOKif8oSV8xYFhZ0QbM6+1Gn5upT1Q2h2p2xg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=JgdmZiKz; arc=none smtp.remote-ip=117.135.210.4 X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 008B4606A321 for <netdev@vger.kernel.org>; Mon, 9 Nov 2026 05:32:45 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 008B4606A321 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=fS sd+Jru8TwrsZ00/xFyxEW8a4AeXr5gmncXZGNMYGw=; b=JgdmZiKzU20OyqLlS3 ZVadvUdXHIIGGV7gP8PJghYtOdg1b7j2hm1YEpJaq2AfYt4R8lt+Y9rUKjflucFl TZSfXE+RpIEAit8PMiKrYxq24tcGGGMuoIOiihud4o/A4jCmc9O+SKkM6JpZ16E2 LEU5MzS4g7Uj+xKUPAEnMGDlY= X-Received: from device-ubuntu.localdomain (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wD3v47gWvFq37XTFw--.24970S2; Mon, 09 Nov 2026 13:32:33 +0800 (CST) X-Cc: netdev@vger.kernel.org, Fang Jiabao <kaquoin@163.com> X-Mailer: git-send-email 2.43.0 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-CM-TRANSID: _____wD3v47gWvFq37XTFw--.24970S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJFWxuFW5tF4fZF1DJrWxtFb_yoW5Gr17pF ZIga98KrZ5tF4Iyay7Ga1xZ34Yyws3JFWUJFykG3yqyFs8WFySyF9Yy34YqrW8ArZ7Jw4k trsrt34UWFWDXaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pR_HUhUUUUU= X-CM-SenderInfo: 5ndt30llq6il2tof0z/xtbC9RLpXmrxWvLbpwAA3f