• Florian Westphal's avatar
    net: ipv4: remove erroneous advancement of list pointer · 40008e92
    Florian Westphal authored
    Causes crash when lifetime expires on an adress as garbage is
    dereferenced soon after.
    
    This used to look like this:
    
     for (ifap = &ifa->ifa_dev->ifa_list;
          *ifap != NULL; ifap = &(*ifap)->ifa_next) {
              if (*ifap == ifa) ...
    
    but this was changed to:
    
    struct in_ifaddr *tmp;
    
    ifap = &ifa->ifa_dev->ifa_list;
    tmp = rtnl_dereference(*ifap);
    while (tmp) {
       tmp = rtnl_dereference(tmp->ifa_next); // Bogus
       if (rtnl_dereference(*ifap) == ifa) {
         ...
       ifap = &tmp->ifa_next;		// Can be NULL
       tmp = rtnl_dereference(*ifap);	// Dereference
       }
    }
    
    Remove the bogus assigment/list entry skip.
    
    Fixes: 2638eb8b ("net: ipv4: provide __rcu annotation for ifa_list")
    Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    40008e92
devinet.c 67.6 KB