]> git.baikalelectronics.ru Git - kernel.git/commit
net: sched: ensure opts_len <= IP_TUNNEL_OPTS_MAX in act_tunnel_key
authorXin Long <lucien.xin@gmail.com>
Mon, 18 Nov 2019 09:39:34 +0000 (17:39 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 19 Nov 2019 01:17:07 +0000 (17:17 -0800)
commit9b6cf77df608af9885bb35d2cda3acf93235701f
tree55478381e28ee3f86e099e4af0edaa64753a5b84
parentcabd16ea43cfa8061ffcfa533ec7070c35ef0d4e
net: sched: ensure opts_len <= IP_TUNNEL_OPTS_MAX in act_tunnel_key

info->options_len is 'u8' type, and when opts_len with a value >
IP_TUNNEL_OPTS_MAX, 'info->options_len = opts_len' will cast int
to u8 and set a wrong value to info->options_len.

Kernel crashed in my test when doing:

  # opts="0102:80:00800022"
  # for i in {1..99}; do opts="$opts,0102:80:00800022"; done
  # ip link add name geneve0 type geneve dstport 0 external
  # tc qdisc add dev eth0 ingress
  # tc filter add dev eth0 protocol ip parent ffff: \
       flower indev eth0 ip_proto udp action tunnel_key \
       set src_ip 10.0.99.192 dst_ip 10.0.99.193 \
       dst_port 6081 id 11 geneve_opts $opts \
       action mirred egress redirect dev geneve0

So we should do the similar check as cls_flower does, return error
when opts_len > IP_TUNNEL_OPTS_MAX in tunnel_key_copy_opts().

Fixes: fa0e9dd4f9a7 ("net/sched: add tunnel option support to act_tunnel_key")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_tunnel_key.c