BPF List
 help / color / mirror / Atom feed
* [PATCH bpf] bpf: Check size of the signature buffer
@ 2025-11-02 11:37 KP Singh
  2025-11-03 12:36 ` James Bottomley
  0 siblings, 1 reply; 3+ messages in thread
From: KP Singh @ 2025-11-02 11:37 UTC (permalink / raw)
  To: bpf; +Cc: ast, daniel, clm, KP Singh

Accept only a SHA256 sized buffer.

Fixes: 349271568303 ("bpf: Implement signature verification for BPF programs")
Reported-by: Chris Mason <clm@meta.com>
Signed-off-by: KP Singh <kpsingh@kernel.org>
---
 kernel/bpf/syscall.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 8a129746bd6c..cc5bce20ec86 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2826,6 +2826,9 @@ static int bpf_prog_verify_signature(struct bpf_prog *prog, union bpf_attr *attr
 	void *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
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-04 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-02 11:37 [PATCH bpf] bpf: Check size of the signature buffer KP Singh
2025-11-03 12:36 ` James Bottomley
2025-11-04 10:17   ` KP Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox