]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - include/net/inet_hashtables.h
tcp/dccp: fix possible race __inet_lookup_established()
[mirror_ubuntu-bionic-kernel.git] / include / net / inet_hashtables.h
index 2dbbbff5e1e3aa58434bbafa691d44005b3e2450..573ab110c9ec8920a5c94e596b905a9e9aadaa99 100644 (file)
@@ -106,12 +106,18 @@ struct inet_bind_hashbucket {
        struct hlist_head       chain;
 };
 
-/*
- * Sockets can be hashed in established or listening table
+/* Sockets can be hashed in established or listening table.
+ * We must use different 'nulls' end-of-chain value for all hash buckets :
+ * A socket might transition from ESTABLISH to LISTEN state without
+ * RCU grace period. A lookup in ehash table needs to handle this case.
  */
+#define LISTENING_NULLS_BASE (1U << 29)
 struct inet_listen_hashbucket {
        spinlock_t              lock;
-       struct hlist_head       head;
+       union {
+               struct hlist_head       head;
+               struct hlist_nulls_head nulls_head;
+       };
 };
 
 /* This is for listening sockets, thus all sockets which possess wildcards. */