ipv6: do not leave garbage in rt->fib6_metrics
Subsystems (3)
PATCH 1/1 ipv6: do not leave garbage in rt->fib6_metrics
In case ip_fib_metrics_init() returns an error, we better rewrite rt->fib6_metrics with &dst_default_metrics so that we do not crash later in ip_fib_metrics_put()
--- net/ipv6/route.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/route.c +2 -0
@@ -2976,6 +2976,8 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, rt->fib6_metrics =ip_fib_metrics_init (net, cfg->fc_mx, cfg->fc_mx_len);if (IS_ERR (rt->fib6_metrics)) { err =PTR_ERR (rt->fib6_metrics); +/* Do not leave garbage there. */ + rt->fib6_metrics = (struct dst_metrics *)&dst_default_metrics; goto out; }
Signature · 1 line
2.19.0.605.g01d371f741-goog
Quoted 7 lines · Eric Dumazet
In case
ip_fib_metrics_init()returns an error, we better rewritert->fib6_metricswith&dst_default_metricsso that we do not crash later inip_fib_metrics_put()Fixes 767a2217533f ("net: common metrics init helper for FIB entries")Signed-off-by Eric Dumazet <[email protected]>Reported-by syzbot <[email protected]>
Where is syzbot sending the reports? I don't see it on netdev. I would like to understand how it triggered the failure of a 68-byte malloc.
Quoted 10 lines
--- net/ipv6/route.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv6/route.c +0
-0
net/ipv6/route.c static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, · line 2983
Quoted 8 lines
net/ipv6/route.c +2
-0@@ -2976,6 +2976,8 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, rt->fib6_metrics =ip_fib_metrics_init (net, cfg->fc_mx, cfg->fc_mx_len);if (IS_ERR (rt->fib6_metrics)) { err =PTR_ERR (rt->fib6_metrics); +/* Do not leave garbage there. */ + rt->fib6_metrics = (struct dst_metrics *)&dst_default_metrics; goto out; }
Thanks, Eric.
Quoted 6 lines · David Ahern
Quoted 4 lines · Eric Dumazet
In case
ip_fib_metrics_init()returns an error, we better rewritert->fib6_metricswith&dst_default_metricsso that we do not crash later inip_fib_metrics_put()
Quoted 7 lines
Quoted 3 lines
Fixes 767a2217533f ("net: common metrics init helper for FIB entries")Signed-off-by Eric Dumazet <[email protected]>Reported-by syzbot <[email protected]>Where is syzbot sending the reports? I don't see it on netdev. I would like to understand how it triggered the failure of a 68-byte malloc.
Not a public syzbot instance.
And this is not a 68-byte malloc error, simply a ip_metrics_convert() being cautious with user provided attributes.
You can trivially trigger this with ip command
Quoted 23 lines
Quoted 11 lines
--- net/ipv6/route.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv6/route.c +0
-0net/ipv6/route.c static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, · line 2983
Quoted 8 lines
net/ipv6/route.c +2
-0@@ -2976,6 +2976,8 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, rt->fib6_metrics =ip_fib_metrics_init (net, cfg->fc_mx, cfg->fc_mx_len);if (IS_ERR (rt->fib6_metrics)) { err =PTR_ERR (rt->fib6_metrics); +/* Do not leave garbage there. */ + rt->fib6_metrics = (struct dst_metrics *)&dst_default_metrics; goto out; }Reviewed-by David Ahern <[email protected]>Thanks, Eric.
From: Eric Dumazet <[email protected]>
Date: Fri, 5 Oct 2018 09:17:50 -0700
Quoted 7 lines
In case
ip_fib_metrics_init()returns an error, we better rewritert->fib6_metricswith&dst_default_metricsso that we do not crash later inip_fib_metrics_put()Fixes 767a2217533f ("net: common metrics init helper for FIB entries")Signed-off-by Eric Dumazet <[email protected]>Reported-by syzbot <[email protected]>
Applied to net-next, thanks Eric.
Subject should have said net-next instead of net btw.
Quoted 3 lines · David Miller
Applied to net-next, thanks Eric.
Subject should have said net-next instead of net btw.
Oops, sorry for that, I used the wrong script.
Thanks.