]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: fix segmentation fault on gact action
authorAndrea Claudi <aclaudi@redhat.com>
Tue, 1 Oct 2019 10:32:17 +0000 (12:32 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 9 Oct 2019 03:18:51 +0000 (20:18 -0700)
tc segfaults if gact action is used without action or index:

$ ip link add type dummy
$ tc actions add action pipe index 1
$ tc filter add dev dummy0 parent ffff: protocol ip \
  pref 10 u32 match ip src 127.0.0.2 flowid 1:10 action gact
Segmentation fault

We expect tc to fail gracefully with an error message.

This happens if gact is the last argument of the incomplete
command. In this case the "gact" action is parsed, the macro
NEXT_ARG_FWD() is executed and the next matches() crashes
because of null argv pointer.

To avoid this, simply use NEXT_ARG() instead.

With this change in place:

$ ip link add type dummy
$ tc actions add action pipe index 1
$ tc filter add dev dummy0 parent ffff: protocol ip \
  pref 10 u32 match ip src 127.0.0.2 flowid 1:10 action gact
Command line is not complete. Try option "help"

Fixes: fa4958897314 ("tc: Fix binding of gact action by index.")
Reported-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/m_gact.c

index dca2a2f9692fd0bf9e993d84014482d9cffa981c..b06e8ee95818fde845fcec15c3a1841ec9ec3595 100644 (file)
@@ -87,7 +87,7 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
                return -1;
 
        if (!matches(*argv, "gact"))
-               NEXT_ARG_FWD();
+               NEXT_ARG();
        /* we're binding existing gact action to filter by index. */
        if (!matches(*argv, "index"))
                goto skip_args;