[PATCH] net: sched: fix a use-after-free error on chain on the error exit path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Colin Ian King <colin.king@xxxxxxxxxxxxx>

Set chain to null after the call to tcf_chain_destroy so that we don't
call tcf_chain_put on the error exit path, thus avoiding a use-after-free
error.

Detected by CoverityScan, CID#1436357 ("Use after free")

Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
---
 net/sched/cls_api.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 4020b8d932a1..82ebdc3fcb2e 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -511,6 +511,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
 	if (n->nlmsg_type == RTM_DELTFILTER && prio == 0) {
 		tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
 		tcf_chain_destroy(chain);
+		chain = NULL;
 		err = 0;
 		goto errout;
 	}
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux