065-inet_fix_NULL_pointer.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 673498b8ed4c4d4b7221c5309d891c5eac2b7528 Mon Sep 17 00:00:00 2001
  2. From: Stefan Tomanek <[email protected]>
  3. Date: Tue, 10 Dec 2013 23:21:25 +0100
  4. Subject: [PATCH] inet: fix NULL pointer Oops in fib(6)_rule_suppress
  5. This changes ensures that the routing entry investigated by the suppress
  6. function actually does point to a device struct before following that pointer,
  7. fixing a possible kernel oops situation when verifying the interface group
  8. associated with a routing table entry.
  9. According to Daniel Golle, this Oops can be triggered by a user process trying
  10. to establish an outgoing IPv6 connection while having no real IPv6 connectivity
  11. set up (only autoassigned link-local addresses).
  12. Fixes: 6ef94cfafba15 ("fib_rules: add route suppression based on ifgroup")
  13. Reported-by: Daniel Golle <[email protected]>
  14. Tested-by: Daniel Golle <[email protected]>
  15. Signed-off-by: Stefan Tomanek <[email protected]>
  16. Signed-off-by: David S. Miller <[email protected]>
  17. ---
  18. net/ipv4/fib_rules.c | 5 ++++-
  19. net/ipv6/fib6_rules.c | 6 +++++-
  20. 2 files changed, 9 insertions(+), 2 deletions(-)
  21. --- a/net/ipv4/fib_rules.c
  22. +++ b/net/ipv4/fib_rules.c
  23. @@ -104,7 +104,10 @@ errout:
  24. static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg)
  25. {
  26. struct fib_result *result = (struct fib_result *) arg->result;
  27. - struct net_device *dev = result->fi->fib_dev;
  28. + struct net_device *dev = NULL;
  29. +
  30. + if (result->fi)
  31. + dev = result->fi->fib_dev;
  32. /* do not accept result if the route does
  33. * not meet the required prefix length
  34. --- a/net/ipv6/fib6_rules.c
  35. +++ b/net/ipv6/fib6_rules.c
  36. @@ -122,7 +122,11 @@ out:
  37. static bool fib6_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg)
  38. {
  39. struct rt6_info *rt = (struct rt6_info *) arg->result;
  40. - struct net_device *dev = rt->rt6i_idev->dev;
  41. + struct net_device *dev = NULL;
  42. +
  43. + if (rt->rt6i_idev)
  44. + dev = rt->rt6i_idev->dev;
  45. +
  46. /* do not accept result if the route does
  47. * not meet the required prefix length
  48. */