Merge branch 'ifa_list-RCU'
authorDavid S. Miller <davem@davemloft.net>
Mon, 3 Jun 2019 01:08:47 +0000 (18:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Jun 2019 01:08:47 +0000 (18:08 -0700)
commitfeb3cf2e5ecc5840e27f328e0ce666a0f728f1a3
tree84264a6f50aaedfac6854bef3d5972926d321c10
parentb9f88982750d5c28b3c55ab8b802ecfa62a0bbd2
parent2638eb8b50cfc16240e0bb080b9afbf541a9b39d
Merge branch 'ifa_list-RCU'

Florian Westphal says:

====================
net: add rcu annotations for ifa_list

v3: fix typo in patch1 commit message
    All other patches are unchanged.
v2: remove ifa_list iteration in afs instead of conversion

Eric Dumazet reported following problem:

  It looks that unless RTNL is held, accessing ifa_list needs proper RCU
  protection.  indev->ifa_list can be changed under us by another cpu
  (which owns RTNL) [..]

  A proper rcu_dereference() with an happy sparse support would require
  adding __rcu attribute.

This patch series does that: add __rcu to the ifa_list pointers.
That makes sparse complain, so the series also adds the required
rcu_assign_pointer/dereference helpers where needed.

All patches except the last one are preparation work.
Two new macros are introduced for in_ifaddr walks.

Last patch adds the __rcu annotations and the assign_pointer/dereference
helper calls.

This patch is a bit large, but I found no better way -- other
approaches (annotate-first or add helpers-first) all result in
mid-series sparse warnings.

This series is submitted vs. net-next rather than net for several
reasons:

1. Its (mostly) compile-tested only
2. 3rd patch changes behaviour wrt. secondary addresses
   (see changelog)
3. The problem exists for a very long time (2004), so it doesn't
   seem to be urgent to fix this -- rcu use to free ifa_list
   predates the git era.
====================

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