From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: [PATCH net] bpf: enforce correct alignment for instructions Date: Wed, 20 Jun 2018 17:24:09 -0700 Message-ID: <20180621002409.63136-1-edumazet@google.com> Cc: netdev , Eric Dumazet , Eric Dumazet , Daniel Borkmann , Martin KaFai Lau , Alexei Starovoitov To: "David S . Miller" Return-path: Received: from mail-pf0-f181.google.com ([209.85.192.181]:39479 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932450AbeFUAYT (ORCPT ); Wed, 20 Jun 2018 20:24:19 -0400 Received: by mail-pf0-f181.google.com with SMTP id r11-v6so590788pfl.6 for ; Wed, 20 Jun 2018 17:24:19 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: After commit 9facc336876f ("bpf: reject any prog that failed read-only lock") offsetof(struct bpf_binary_header, image) became 3 instead of 4, breaking powerpc BPF badly, since instructions need to be word aligned. Fixes: 9facc336876f ("bpf: reject any prog that failed read-only lock") Signed-off-by: Eric Dumazet Cc: Daniel Borkmann Cc: Martin KaFai Lau Cc: Alexei Starovoitov --- include/linux/filter.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index b615df57b7d5b2ccb468c411c3a2aae103cd2aea..20f2659dd829256d7fef206087ab3262e1e291f5 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -472,7 +472,9 @@ struct sock_fprog_kern { struct bpf_binary_header { u16 pages; u16 locked:1; - u8 image[]; + + /* Some arches need word alignment for their instructions */ + u8 image[] __aligned(4); }; struct bpf_prog { -- 2.18.0.rc1.244.gcf134e6275-goog