]> granicus.if.org Git - strace/commitdiff
bpf_attr.h: add ATTRIBUTE_ALIGNED(8) to all fields of type uint64_t
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 1 Jun 2018 19:43:35 +0000 (19:43 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 2 Jun 2018 16:32:10 +0000 (16:32 +0000)
Our policy is that all fields of type uint64_t in this header file
must have this attribute.

This shouldn't cause any contradictions with <linux/bpf.h>
unless the latter is buggy.

By word "buggy" I mean containing such changes as Linux kernel commit
v4.16-rc1~123^2~109^2~5^2~4.

* bpf_attr.h (struct BPF_MAP_UPDATE_ELEM_struct): Add
ATTRIBUTE_ALIGNED(8) to "flags" field.
(struct bpf_prog_info_struct): Add ATTRIBUTE_ALIGNED(8) to "load_time"
field.

bpf_attr.h

index f598b09f8c3a593417016856c69669216b72a3f3..45bb30a751e170de66e6cc9c94506a268a113eb4 100644 (file)
 #ifndef STRACE_BPF_ATTR_H
 #define STRACE_BPF_ATTR_H
 
+/*
+ * The policy is that all fields of type uint64_t in this header file
+ * must have ATTRIBUTE_ALIGNED(8).
+ *
+ * This should not cause any contradictions with <linux/bpf.h>
+ * unless the latter is buggy.
+ *
+ * By word "buggy" I mean containing such changes as Linux kernel commit
+ * v4.16-rc1~123^2~109^2~5^2~4.
+ */
+
 #ifndef BPF_OBJ_NAME_LEN
 # define BPF_OBJ_NAME_LEN 16U
 #else
@@ -74,7 +85,7 @@ struct BPF_MAP_UPDATE_ELEM_struct {
        uint32_t map_fd;
        uint64_t ATTRIBUTE_ALIGNED(8) key;
        uint64_t ATTRIBUTE_ALIGNED(8) value;
-       uint64_t flags;
+       uint64_t ATTRIBUTE_ALIGNED(8) flags;
 };
 
 #define BPF_MAP_UPDATE_ELEM_struct_size \
@@ -242,8 +253,12 @@ struct bpf_map_info_struct {
        uint32_t map_flags;
        char     name[BPF_OBJ_NAME_LEN];
        uint32_t ifindex;
-       uint64_t ATTRIBUTE_ALIGNED(8) netns_dev; /* kernel UAPI is buggy, skip check */
-       uint64_t ATTRIBUTE_ALIGNED(8) netns_ino; /* kernel UAPI is buggy, skip check */
+       /*
+        * The kernel UAPI is broken by Linux commit
+        * v4.16-rc1~123^2~109^2~5^2~4 .
+        */
+       uint64_t ATTRIBUTE_ALIGNED(8) netns_dev; /* skip check */
+       uint64_t ATTRIBUTE_ALIGNED(8) netns_ino; /* skip check */
 };
 
 #define bpf_map_info_struct_size \
@@ -258,14 +273,18 @@ struct bpf_prog_info_struct {
        uint32_t xlated_prog_len;
        uint64_t ATTRIBUTE_ALIGNED(8) jited_prog_insns;
        uint64_t ATTRIBUTE_ALIGNED(8) xlated_prog_insns;
-       uint64_t load_time;
+       uint64_t ATTRIBUTE_ALIGNED(8) load_time;
        uint32_t created_by_uid;
        uint32_t nr_map_ids;
        uint64_t ATTRIBUTE_ALIGNED(8) map_ids;
        char     name[BPF_OBJ_NAME_LEN];
        uint32_t ifindex;
-       uint64_t ATTRIBUTE_ALIGNED(8) netns_dev; /* kernel UAPI is buggy, skip check */
-       uint64_t ATTRIBUTE_ALIGNED(8) netns_ino; /* kernel UAPI is buggy, skip check */
+       /*
+        * The kernel UAPI is broken by Linux commit
+        * v4.16-rc1~123^2~227^2~5^2~2 .
+        */
+       uint64_t ATTRIBUTE_ALIGNED(8) netns_dev; /* skip check */
+       uint64_t ATTRIBUTE_ALIGNED(8) netns_ino; /* skip check */
 };
 
 #define bpf_prog_info_struct_size \