Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2] seg6local: fix crash when next-csid ends the command
@ 2026-11-24  5:55 Dave Seddon
  2026-11-24  7:56 ` Frank Dressler
       [not found] ` <a5b77684-1041-49ed-8fd6-567e68964476@dressler.pro>
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Seddon @ 2026-11-24  5:55 UTC (permalink / raw)
  To: netdev; +Cc: Dave Seddon, Stephen Hemminger, David Ahern, Paolo Lungaroni

ip crashes when "flavors next-csid" ends the command, with or without
"lblen N":

  ip -6 route add 2001:db8:2::/64 dev lo encap seg6local action End \
    flavors next-csid

seg6local_parse_flavors() steps past the last argument and passes the
NULL terminator to strcmp(). Check argc first.

Fixes: 04a6b456bf74 ("seg6: add support for flavors in SRv6 End* behaviors")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Dave Seddon <dave.seddon.ca@gmail.com>
---
 ip/iproute_lwtunnel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 9a1e747c..53004b5f 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -1434,7 +1434,7 @@ static int seg6local_parse_flavors(struct rtattr *rta, size_t len,
 
 	if (flavors & (1 << SEG6_LOCAL_FLV_OP_NEXT_CSID)) {
 		NEXT_ARG_FWD();
-		if (strcmp(*argv, "lblen") == 0){
+		if (argc > 0 && strcmp(*argv, "lblen") == 0) {
 			NEXT_ARG();
 			if (lbl_ok++)
 				duparg2("lblen", *argv);
@@ -1444,7 +1444,7 @@ static int seg6local_parse_flavors(struct rtattr *rta, size_t len,
 			NEXT_ARG_FWD();
 		}
 
-		if (strcmp(*argv, "nflen") == 0){
+		if (argc > 0 && strcmp(*argv, "nflen") == 0) {
 			NEXT_ARG();
 			if (nfl_ok++)
 				duparg2("nflen", *argv);
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-24 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  5:55 [PATCH iproute2] seg6local: fix crash when next-csid ends the command Dave Seddon
2026-11-24  7:56 ` Frank Dressler
     [not found] ` <a5b77684-1041-49ed-8fd6-567e68964476@dressler.pro>
2026-11-24 15:57   ` Dave Seddon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox