net: sched: fix possible refcount leak in tc_new_tfilter()
Subsystems (3)
PATCH 1/1 net: sched: fix possible refcount leak in tc_new_tfilter()
tfilter_put need to be called to put the refount got by tp->ops->get to avoid possible refcount leak when chain->tmplt_ops == NULL or chain->tmplt_ops != tp->ops.
--- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)
net/sched/cls_api.c +1 -0
@@ -2137,6 +2137,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, }if (chain->tmplt_ops && chain->tmplt_ops != tp->ops) { +tfilter_put (tp, fh);NL_SET_ERR_MSG (extack,"Chain template is set to a different filter kind" ); err = -EINVAL ; goto errout;
Signature · 1 line
2.34.1
Quoted 7 lines · Hangyu Hua
tfilter_putneed to be called to put the refount got bytp->ops->getto avoid possible refcount leak whenchain->tmplt_ops== NULL orchain->tmplt_ops!=tp->ops.Fixes 7d5509fa0d3d ("net: sched: extend proto ops with 'put' callback")Signed-off-by Hangyu Hua <[email protected]>---
Thanks for fixing this!
Quoted 15 lines
net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)net/sched/cls_api.c +1
-0@@ -2137,6 +2137,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, }if (chain->tmplt_ops && chain->tmplt_ops != tp->ops) { +tfilter_put (tp, fh);NL_SET_ERR_MSG (extack,"Chain template is set to a different filter kind" ); err = -EINVAL ; goto errout;
Jakub Kicinski
maintainerQuoted 1 line · On Thu, 15 Sep 2022 16:58:04 +0800 Hangyu Hua wrote:
tfilter_putneed to be called to put the refount got bytp->ops->getto
s/refount/refcount/
Quoted 2 lines
avoid possible refcount leak when
chain->tmplt_ops== NULL orchain->tmplt_ops!=tp->ops.
This should say:
when cain->tmplt_ops != NULL and ...
otherwise the commit message does not match the code.
Quoted 18 lines
Fixes 7d5509fa0d3d ("net: sched: extend proto ops with 'put' callback")Signed-off-by Hangyu Hua <[email protected]>--- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)net/sched/cls_api.c +1
-0@@ -2137,6 +2137,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, }if (chain->tmplt_ops && chain->tmplt_ops != tp->ops) { +tfilter_put (tp, fh);NL_SET_ERR_MSG (extack,"Chain template is set to a different filter kind" ); err = -EINVAL ; goto errout;
Quoted 5 lines · Jakub Kicinski
Quoted 1 line · On Thu, 15 Sep 2022 16:58:04 +0800 Hangyu Hua wrote:
tfilter_putneed to be called to put the refount got bytp->ops->gettos/refount/refcount/
Quoted 9 lines
Quoted 2 lines
avoid possible refcount leak when
chain->tmplt_ops== NULL orchain->tmplt_ops!=tp->ops.This should say:
when cain->tmplt_ops != NULL and ...otherwise the commit message does not match the code.
My bad. I will submit a v2.
Thanks,
Hangyu
Quoted 19 lines
Quoted 18 lines
Fixes 7d5509fa0d3d ("net: sched: extend proto ops with 'put' callback")Signed-off-by Hangyu Hua <[email protected]>--- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)net/sched/cls_api.c +1
-0@@ -2137,6 +2137,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, }if (chain->tmplt_ops && chain->tmplt_ops != tp->ops) { +tfilter_put (tp, fh);NL_SET_ERR_MSG (extack,"Chain template is set to a different filter kind" ); err = -EINVAL ; goto errout;