Message ID | 20180611141212.26371-1-dsahern@kernel.org |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
Series | [net] net/ipv6: Ensure cfg is properly initialized in ipv6_create_tempaddr | expand |
From: dsahern@kernel.org Date: Mon, 11 Jun 2018 07:12:12 -0700 > From: David Ahern <dsahern@gmail.com> > > Valdis reported a BUG in ipv6_add_addr: ... > Looking at the code I found 1 element (peer_pfx) of the newly introduced > ifa6_config struct that is not initialized. Use a memset rather than hard > coding an init for each struct element. > > Reported-by: Valdis Kletnieks <valdis.kletnieks@vt.edu> > Fixes: e6464b8c63619 ("net/ipv6: Convert ipv6_add_addr to struct ifa6_config") > Signed-off-by: David Ahern <dsahern@gmail.com> Applied, thanks David.
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 89019bf59f46..c134286d6a41 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1324,6 +1324,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, } } + memset(&cfg, 0, sizeof(cfg)); cfg.valid_lft = min_t(__u32, ifp->valid_lft, idev->cnf.temp_valid_lft + age); cfg.preferred_lft = cnf_temp_preferred_lft + age - idev->desync_factor; @@ -1357,7 +1358,6 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, cfg.pfx = &addr; cfg.scope = ipv6_addr_scope(cfg.pfx); - cfg.rt_priority = 0; ift = ipv6_add_addr(idev, &cfg, block, NULL); if (IS_ERR(ift)) {