Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1456196 > unrolled thread
| Started by | Sargun Dhillon <sargun@sargun.me> |
|---|---|
| First post | 2016-08-04 09:20 +0200 |
| Last post | 2016-08-04 13:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[RFC 4/4] bpf: Restrict Checmate bpf programs to current kernel ABI Sargun Dhillon <sargun@sargun.me> - 2016-08-04 09:20 +0200
Re: [RFC 4/4] bpf: Restrict Checmate bpf programs to current kernel ABI Daniel Borkmann <daniel@iogearbox.net> - 2016-08-04 13:00 +0200
Re: [RFC 4/4] bpf: Restrict Checmate bpf programs to current kernel ABI Daniel Borkmann <daniel@iogearbox.net> - 2016-08-04 13:00 +0200
| From | Sargun Dhillon <sargun@sargun.me> |
|---|---|
| Date | 2016-08-04 09:20 +0200 |
| Subject | [RFC 4/4] bpf: Restrict Checmate bpf programs to current kernel ABI |
| Message-ID | <s2l6F-5K2-15@gated-at.bofh.it> |
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 <sargun@sargun.me>
---
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 <linux/in.h>
#include <linux/checmate.h>
#include "bpf_helpers.h"
+#include <linux/version.h>
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
[toc] | [next] | [standalone]
| From | Daniel Borkmann <daniel@iogearbox.net> |
|---|---|
| Date | 2016-08-04 13:00 +0200 |
| Subject | Re: [RFC 4/4] bpf: Restrict Checmate bpf programs to current kernel ABI |
| Message-ID | <s2oxA-7OH-5@gated-at.bofh.it> |
| In reply to | #1456196 |
On 08/04/2016 09:12 AM, Sargun Dhillon wrote:
> 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 <sargun@sargun.me>
> ---
> 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)
Btw, this check is correct, program types are not masks.
BPF_PROG_TYPE_KPROBE (== 2) and BPF_PROG_TYPE_CHECMATE (== 7) will now
require every type to have a 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 <linux/in.h>
> #include <linux/checmate.h>
> #include "bpf_helpers.h"
> +#include <linux/version.h>
>
> 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;
>
[toc] | [prev] | [next] | [standalone]
| From | Daniel Borkmann <daniel@iogearbox.net> |
|---|---|
| Date | 2016-08-04 13:00 +0200 |
| Subject | Re: [RFC 4/4] bpf: Restrict Checmate bpf programs to current kernel ABI |
| Message-ID | <s2oxA-7OH-25@gated-at.bofh.it> |
| In reply to | #1456333 |
On 08/04/2016 11:52 AM, Daniel Borkmann wrote: > On 08/04/2016 09:12 AM, Sargun Dhillon wrote: >> 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 <sargun@sargun.me> >> --- >> 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) > > Btw, this check is correct, program types are not masks. Sorry, I meant to write *not* correct, which was hopefully inferable from the rest. > BPF_PROG_TYPE_KPROBE (== 2) and BPF_PROG_TYPE_CHECMATE (== 7) will now > require every type to have a version code ... > >> return -EINVAL; >>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web