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. Florian Westphal (7): afs: do not send list of client addresses net: inetdevice: provide replacement iterators for in_ifaddr walk devinet: use in_dev_for_each_ifa_rcu in more places netfilter: use in_dev_for_each_ifa_rcu net: use new in_dev_ifa iterators drivers: use in_dev_for_each_ifa_rtnl/rcu net: ipv4: provide __rcu annotation for ifa_list drivers/infiniband/core/roce_gid_mgmt.c | 5 drivers/infiniband/hw/cxgb4/cm.c | 9 - drivers/infiniband/hw/i40iw/i40iw_cm.c | 7 drivers/infiniband/hw/i40iw/i40iw_main.c | 6 drivers/infiniband/hw/i40iw/i40iw_utils.c | 12 - drivers/infiniband/hw/nes/nes.c | 8 drivers/infiniband/hw/usnic/usnic_ib_main.c | 15 + drivers/isdn/hysdn/hysdn_net.c | 6 drivers/isdn/i4l/isdn_net.c | 20 +- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 8 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 5 drivers/net/ethernet/via/via-velocity.h | 2 drivers/net/plip/plip.c | 4 drivers/net/vmxnet3/vmxnet3_drv.c | 19 +- drivers/net/wan/hdlc_cisco.c | 11 - drivers/net/wireless/ath/ath6kl/cfg80211.c | 4 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 fs/afs/Makefile | 1 fs/afs/cmservice.c | 24 -- fs/afs/internal.h | 15 - fs/afs/netdevices.c | 48 ----- include/linux/inetdevice.h | 19 +- net/core/netpoll.c | 10 - net/core/pktgen.c | 8 net/ipv4/devinet.c | 146 ++++++++++------- net/ipv4/fib_frontend.c | 24 +- net/ipv4/igmp.c | 5 net/ipv4/netfilter/nf_tproxy_ipv4.c | 9 - net/ipv6/addrconf.c | 4 net/mac80211/main.c | 4 net/netfilter/nf_conntrack_broadcast.c | 9 - net/netfilter/nf_nat_redirect.c | 12 - net/netfilter/nfnetlink_osf.c | 5 net/sctp/protocol.c | 2 net/smc/smc_clc.c | 11 - 35 files changed, 266 insertions(+), 233 deletions(-)