Revert "bpf: avoid false sharing of map refcount with max_entries"
authorYves-Alexis Perez <corsac@debian.org>
Fri, 2 Feb 2018 09:40:47 +0000 (10:40 +0100)
committerYves-Alexis Perez <corsac@debian.org>
Fri, 9 Feb 2018 12:58:52 +0000 (12:58 +0000)
This reverts commit 5cb917aa1f1e03df9a4c29b363e3900d73508fa8 which is commit
be95a845cc4402272994ce290e3ad928aff06cb9 upstream. This commit heavily
modifies the bpf_map structure to split it on two cachelines and prevent
sharing reference counter with other, read-only fields in order to mitigate
Spectre attacks. This modification changes the ABI, so revert the mitigation
for now since the infrastructure is not yet complete for Spectre mitigation
anyway.

Gbp-Pq: Topic debian
Gbp-Pq: Name revert-bpf-avoid-false-sharing-of-map-refcount-with-.patch

include/linux/bpf.h

index 7995940d41877e3f718635914d89dbcce672c374..75ffd3b2149e9531392c1681f7776c034b79b90e 100644 (file)
@@ -36,10 +36,7 @@ struct bpf_map_ops {
 };
 
 struct bpf_map {
-       /* 1st cacheline with read-mostly members of which some
-        * are also accessed in fast-path (e.g. ops, max_entries).
-        */
-       const struct bpf_map_ops *ops ____cacheline_aligned;
+       atomic_t refcnt;
        enum bpf_map_type map_type;
        u32 key_size;
        u32 value_size;
@@ -47,15 +44,10 @@ struct bpf_map {
        u32 map_flags;
        u32 pages;
        bool unpriv_array;
-       /* 7 bytes hole */
-
-       /* 2nd cacheline with misc members to avoid false sharing
-        * particularly with refcounting.
-        */
-       struct user_struct *user ____cacheline_aligned;
-       atomic_t refcnt;
-       atomic_t usercnt;
+       struct user_struct *user;
+       const struct bpf_map_ops *ops;
        struct work_struct work;
+       atomic_t usercnt;
 };
 
 struct bpf_map_type_list {