Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "net/ipv6: fix metrics leak"

This reverts commit df18b50448fab1dff093731dfd0e25e77e1afcd1.

This change causes other problems and use-after-free situations as
found by syzbot.

Signed-off-by: David S. Miller <davem@davemloft.net>

+4 -14
+4 -14
net/ipv6/ip6_fib.c
··· 167 167 return f6i; 168 168 } 169 169 170 - static void fib6_metrics_release(struct fib6_info *f6i) 171 - { 172 - struct dst_metrics *m; 173 - 174 - if (!f6i) 175 - return; 176 - 177 - m = f6i->fib6_metrics; 178 - if (m != &dst_default_metrics && refcount_dec_and_test(&m->refcnt)) 179 - kfree(m); 180 - } 181 - 182 170 void fib6_info_destroy_rcu(struct rcu_head *head) 183 171 { 184 172 struct fib6_info *f6i = container_of(head, struct fib6_info, rcu); 185 173 struct rt6_exception_bucket *bucket; 174 + struct dst_metrics *m; 186 175 187 176 WARN_ON(f6i->fib6_node); 188 177 ··· 201 212 if (f6i->fib6_nh.nh_dev) 202 213 dev_put(f6i->fib6_nh.nh_dev); 203 214 204 - fib6_metrics_release(f6i); 215 + m = f6i->fib6_metrics; 216 + if (m != &dst_default_metrics && refcount_dec_and_test(&m->refcnt)) 217 + kfree(m); 205 218 206 219 kfree(f6i); 207 220 } ··· 887 896 888 897 from = rcu_dereference_protected(pcpu_rt->from, 889 898 lockdep_is_held(&table->tb6_lock)); 890 - fib6_metrics_release(from); 891 899 rcu_assign_pointer(pcpu_rt->from, NULL); 892 900 fib6_info_release(from); 893 901 }