From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932507AbcHDHMg (ORCPT ); Thu, 4 Aug 2016 03:12:36 -0400 Received: from mail-it0-f45.google.com ([209.85.214.45]:36436 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932102AbcHDHMc (ORCPT ); Thu, 4 Aug 2016 03:12:32 -0400 Date: Thu, 4 Aug 2016 00:12:29 -0700 From: Sargun Dhillon To: linux-kernel@vger.kernel.org Cc: alexei.starovoitov@gmail.com, daniel@iogearbox.net, linux-security-module@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC 4/4] bpf: Restrict Checmate bpf programs to current kernel ABI Message-ID: <20160804071227.GA19135@ircssh.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I think it makes sense to restrict Checmate to loading programs that have been compiled with the current kernel ABI. We can further stabilize the ABI, and perhaps lift this restriction later. Signed-off-by: Sargun Dhillon --- kernel/bpf/syscall.c | 2 +- samples/bpf/checmate1_kern.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 228f962..2a37b4d 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -741,7 +741,7 @@ static int bpf_prog_load(union bpf_attr *attr) if (attr->insn_cnt >= BPF_MAXINSNS) return -EINVAL; - if (type == BPF_PROG_TYPE_KPROBE && + if ((type & (BPF_PROG_TYPE_KPROBE | BPF_PROG_TYPE_CHECMATE)) && attr->kern_version != LINUX_VERSION_CODE) return -EINVAL; diff --git a/samples/bpf/checmate1_kern.c b/samples/bpf/checmate1_kern.c index f78b66b..d4ec1fa 100644 --- a/samples/bpf/checmate1_kern.c +++ b/samples/bpf/checmate1_kern.c @@ -3,6 +3,7 @@ #include #include #include "bpf_helpers.h" +#include SEC("checmate") int prog(struct checmate_ctx *ctx) @@ -24,4 +25,4 @@ int prog(struct checmate_ctx *ctx) } char _license[] SEC("license") = "GPL"; - +u32 _version SEC("version") = LINUX_VERSION_CODE; -- 2.7.4