net: ipv4: remove erroneous advancement of list pointer
authorFlorian Westphal <fw@strlen.de>
Mon, 17 Jun 2019 14:02:27 +0000 (16:02 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Jun 2019 23:27:42 +0000 (16:27 -0700)
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: 2638eb8b50cf ("net: ipv4: provide __rcu annotation for ifa_list")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/devinet.c

index 925dffa915cb8f6d3d4131c525d665fa18831f3f..914ccc7f192aee28df175b433a7fe001f2cf8f60 100644 (file)
@@ -745,8 +745,7 @@ static void check_lifetime(struct work_struct *work)
                                ifap = &ifa->ifa_dev->ifa_list;
                                tmp = rtnl_dereference(*ifap);
                                while (tmp) {
-                                       tmp = rtnl_dereference(tmp->ifa_next);
-                                       if (rtnl_dereference(*ifap) == ifa) {
+                                       if (tmp == ifa) {
                                                inet_del_ifa(ifa->ifa_dev,
                                                             ifap, 1);
                                                break;