kernel_optimize_test/net
Liping Zhang 64b87639c9 netfilter: conntrack: fix race between nf_conntrack proc read and hash resize
When we do "cat /proc/net/nf_conntrack", and meanwhile resize the conntrack
hash table via /sys/module/nf_conntrack/parameters/hashsize, race will
happen, because reader can observe a newly allocated hash but the old size
(or vice versa). So oops will happen like follows:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000017
  IP: [<ffffffffa0418e21>] seq_print_acct+0x11/0x50 [nf_conntrack]
  Call Trace:
  [<ffffffffa0412f4e>] ? ct_seq_show+0x14e/0x340 [nf_conntrack]
  [<ffffffff81261a1c>] seq_read+0x2cc/0x390
  [<ffffffff812a8d62>] proc_reg_read+0x42/0x70
  [<ffffffff8123bee7>] __vfs_read+0x37/0x130
  [<ffffffff81347980>] ? security_file_permission+0xa0/0xc0
  [<ffffffff8123cf75>] vfs_read+0x95/0x140
  [<ffffffff8123e475>] SyS_read+0x55/0xc0
  [<ffffffff817c2572>] entry_SYSCALL_64_fastpath+0x1a/0xa4

It is very easy to reproduce this kernel crash.
1. open one shell and input the following cmds:
  while : ; do
    echo $RANDOM > /sys/module/nf_conntrack/parameters/hashsize
  done
2. open more shells and input the following cmds:
  while : ; do
    cat /proc/net/nf_conntrack
  done
3. just wait a monent, oops will happen soon.

The solution in this patch is based on Florian's Commit 5e3c61f981
("netfilter: conntrack: fix lookup race during hash resize"). And
add a wrapper function nf_conntrack_get_ht to get hash and hsize
suggested by Florian Westphal.

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2016-07-11 11:38:57 +02:00
..
6lowpan 6lowpan: add support for 802.15.4 short addr handling 2016-06-15 20:41:24 -07:00
9p
802
8021q net: introduce default neigh_construct/destroy ndo calls for L2 upper devices 2016-07-05 09:06:28 -07:00
appletalk
atm net: add dev arg to ndo_neigh_construct/destroy 2016-07-05 09:06:28 -07:00
ax25 AX.25: Close socket connection on session completion 2016-06-18 20:55:34 -07:00
batman-adv This feature patchset includes the following changes: 2016-07-04 23:33:59 -07:00
bluetooth net: add netdev_lockdep_set_classes() helper 2016-06-09 13:28:37 -07:00
bridge Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-06 10:35:22 -07:00
caif caif: Remove unneeded header file 2016-06-28 05:26:14 -04:00
can can: only call can_stat_update with procfs 2016-06-23 11:23:49 +02:00
ceph
core Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-06 10:35:22 -07:00
dcb
dccp
decnet net: fix decnet rtnexthop parsing 2016-07-05 14:08:47 -07:00
dns_resolver
dsa net: dsa: Initialize CPU port ethtool ops per tree 2016-06-08 11:23:42 -07:00
ethernet
hsr
ieee802154 net: add dev arg to ndo_neigh_construct/destroy 2016-07-05 09:06:28 -07:00
ipv4 netfilter: conntrack: fix race between nf_conntrack proc read and hash resize 2016-07-11 11:38:57 +02:00
ipv6 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-06 10:35:22 -07:00
ipx
irda
iucv af_iucv: use paged SKBs for big inbound messages 2016-06-15 12:21:05 -07:00
kcm bpf: refactor bpf_prog_get and type check into helper 2016-07-01 16:00:47 -04:00
key
l2tp ipv6: use TOS marks from sockets for routing decision 2016-06-11 15:33:26 -07:00
l3mdev net: vrf: Implement get_saddr for IPv6 2016-06-17 21:25:29 -07:00
lapb
llc
mac80211 cfg80211: Add mesh peer AID setting API 2016-07-06 15:04:52 +02:00
mac802154
mpls mpls: allow routes on ipgre devices 2016-06-16 17:12:07 -07:00
netfilter netfilter: conntrack: fix race between nf_conntrack proc read and hash resize 2016-07-11 11:38:57 +02:00
netlabel
netlink net/netlink/af_netlink.h: Remove unused structure. 2016-06-09 22:26:24 -07:00
netrom
nfc
openvswitch Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-06-30 05:03:36 -04:00
packet Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-06 10:35:22 -07:00
phonet
qrtr
rds Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-06 10:35:22 -07:00
rfkill
rose
rxrpc rxrpc: Kill off the rxrpc_transport struct 2016-06-22 14:00:23 +01:00
sched Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-06 10:35:22 -07:00
sctp Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-06-30 05:03:36 -04:00
sunrpc rpc: share one xps between all backchannels 2016-06-15 10:32:25 -04:00
switchdev
tipc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-06 10:35:22 -07:00
unix Merge branch 'overlayfs-af_unix-fix' into overlayfs-linus 2016-06-12 12:05:21 +02:00
vmw_vsock vsock: make listener child lock ordering explicit 2016-06-27 10:44:46 -04:00
wimax
wireless cfg80211: Add mesh peer AID setting API 2016-07-06 15:04:52 +02:00
x25
xfrm
compat.c packet: compat support for sock_fprog 2016-06-09 23:41:03 -07:00
Kconfig
Makefile
socket.c
sysctl_net.c