diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp index 490e07071b..6cf7239476 100644 --- a/bpf/loader/NetBpfLoad.cpp +++ b/bpf/loader/NetBpfLoad.cpp @@ -120,7 +120,7 @@ void validatePinDir(const char s[BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE]) { if (!strncmp(s, "netd_shared/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return; if (!strncmp(s, "loader/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return; } - ALOGE("unrecognized pin_subdir '%-32s'", s); + ALOGE("unrecognized pin_subdir '%-*s'", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE, s); // Note: we *can* just abort() here as we only load bpf .o files shipped // in the same mainline module / apex as NetBpfLoad itself. abort(); diff --git a/bpf/progs/include/bpf_map_def.h b/bpf/progs/include/bpf_map_def.h index 635dee5f92..9185478308 100644 --- a/bpf/progs/include/bpf_map_def.h +++ b/bpf/progs/include/bpf_map_def.h @@ -105,7 +105,7 @@ struct optional_bool { bool optional; }; // Length of strings (incl. selinux_context and pin_subdir) // in the bpf_map_def and bpf_prog_def structs. -#define BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE 32 +#define BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE 66 // must be even for alignment sanity /* * Map structure to be used by Android eBPF C programs. The Android eBPF loader @@ -152,7 +152,7 @@ struct bpf_map_def { // This needs to be updated whenever the above structure definition is expanded. // These asserts are here to make sure we have cross-6-arch consistency. -_Static_assert(sizeof(struct bpf_map_def) == 112, "sizeof struct bpf_map_def != 112"); +_Static_assert(sizeof(struct bpf_map_def) == 48 + 2 * BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE, "wrong sizeof struct bpf_map_def"); _Static_assert(__alignof__(struct bpf_map_def) == 4, "__alignof__ struct bpf_map_def != 4"); _Static_assert(_Alignof(struct bpf_map_def) == 4, "_Alignof struct bpf_map_def != 4"); @@ -177,6 +177,6 @@ struct bpf_prog_def { // This needs to be updated whenever the above structure definition is expanded. // These asserts are here to make sure we have cross-6-arch consistency. -_Static_assert(sizeof(struct bpf_prog_def) == 92, "sizeof struct bpf_prog_def != 92"); +_Static_assert(sizeof(struct bpf_prog_def) == 28 + 2 * BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE, "wrong sizeof struct bpf_prog_def"); _Static_assert(__alignof__(struct bpf_prog_def) == 4, "__alignof__ struct bpf_prog_def != 4"); _Static_assert(_Alignof(struct bpf_prog_def) == 4, "_Alignof struct bpf_prog_def != 4");