bpf: Check size of the signature buffer
PATCH 1/1 bpf: Check size of the signature buffer
Accept only a SHA256 sized buffer.
--- kernel/bpf/syscall.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/bpf/syscall.c +3 -0
@@ -2826,6 +2826,9 @@ static int bpf_prog_verify_signature(struct bpf_prog *prog, union bpf_attr *attrvoid *sig;int err =0 ; +if (attr->signature_size !=SHA256_DIGEST_SIZE ) +return -EINVAL ; +if (system_keyring_id_check (attr->keyring_id) ==0 ) key =bpf_lookup_system_key (attr->keyring_id);else
Signature · 1 line
2.43.0
Quoted 19 lines · KP Singh
Accept only a SHA256 sized buffer.
Fixes 349271568303 ("bpf: Implement signature verification for BPFprograms")
Reported-by Chris Mason <[email protected]>Signed-off-by KP Singh <[email protected]>---
kernel/bpf/syscall.c | 3 +++1 file changed, 3 insertions(+)kernel/bpf/syscall.c +0
-0@@ -2826,6 +2826,9 @@ static int bpf_prog_verify_signature(struct
bpf_prog*prog, unionbpf_attr*attr
void *sig;
int err = 0;
kernel/bpf/syscall.c static int bpf_prog_verify_signature(struct bpf_prog *prog, union bpf_attr *attr · line 2831
Quoted 3 lines
kernel/bpf/syscall.c +3
-0+if (attr->signature_size !=SHA256_DIGEST_SIZE ) +return -EINVAL ; +
That's not going to work unless something really strange is going on: a pkcs7 signature is way bigger than a simple hash. I believe Chris was thinking we should do something like modules do: check to see that the signature is not bigger than the total size of the passed in file data size less the program data before doing the vmalloc.
Regards,
James
Quoted 21 lines · James Bottomley
Quoted 19 lines · KP Singh
Accept only a SHA256 sized buffer.
Fixes 349271568303 ("bpf: Implement signature verification for BPFprograms")
Reported-by Chris Mason <[email protected]>Signed-off-by KP Singh <[email protected]>--- kernel/bpf/syscall.c | 3 +++ 1 file changed, 3 insertions(+)kernel/bpf/syscall.c +0
-0@@ -2826,6 +2826,9 @@ static int bpf_prog_verify_signature(struct
bpf_prog*prog, unionbpf_attr*attrvoid *sig; int err = 0;
Quoted 9 lines
kernel/bpf/syscall.c static int bpf_prog_verify_signature(struct bpf_prog *prog, union bpf_attr *attr · line 2831
Quoted 3 lines
kernel/bpf/syscall.c +3
-0+if (attr->signature_size !=SHA256_DIGEST_SIZE ) +return -EINVAL ; +That's not going to work unless something really strange is going on: a pkcs7 signature is way bigger than a simple hash. I believe Chris was thinking we should do something like modules do: check to see that the signature is not bigger than the total size of the passed in file data size less the program data before doing the vmalloc.
Ah, duh, yes. Apologies.
Will respin.
- KP
Quoted 7 lines
Regards,
James