net: cls_flower: Remove filter from mask before freeing it
commitf4016379d01c17ea09dbdaac4c485139376ec734
authorPetr Machata <petrm@mellanox.com>
Mon, 4 Feb 2019 14:50:38 +0000 (4 14:50 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 19:02:34 +0000 (12 20:02 +0100)
treee9a7a4e1ab3c0dd43febf26f9af1e1a76a0861d0
parent62c2a5b857f2f250d561a81f941dacf896688c4d
net: cls_flower: Remove filter from mask before freeing it

[ Upstream commit c1f7e02979edd7a3a3e69fe04be60b1d650dc8a7 ]

In fl_change(), when adding a new rule (i.e. fold == NULL), a driver may
reject the new rule, for example due to resource exhaustion. By that
point, the new rule was already assigned a mask, and it was added to
that mask's hash table. The clean-up path that's invoked as a result of
the rejection however neglects to undo the hash table addition, and
proceeds to free the new rule, thus leaving a dangling pointer in the
hash table.

Fix by removing fnew from the mask's hash table before it is freed.

Fixes: 35cc3cefc4de ("net/sched: cls_flower: Reject duplicated rules also under skip_sw")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sched/cls_flower.c