summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2021-06-23 22:37:54 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-19 08:53:13 +0200
commit3fbae80e24d65866e86edbb33a46efdd40501897 (patch)
treef313b2840084bf9319f7e96ba2bc79aae14fe7ed
parent1127eb86b23dda88f6201a1c14082f13251e10bf (diff)
downloadlinux-stable-3fbae80e24d65866e86edbb33a46efdd40501897.tar.gz
linux-stable-3fbae80e24d65866e86edbb33a46efdd40501897.tar.bz2
linux-stable-3fbae80e24d65866e86edbb33a46efdd40501897.zip
media, bpf: Do not copy more entries than user space requested
[ Upstream commit 647d446d66e493d23ca1047fa8492b0269674530 ] The syscall bpf(BPF_PROG_QUERY, &attr) should use the prog_cnt field to see how many entries user space provided and return ENOSPC if there are more programs than that. Before this patch, this is not checked and ENOSPC is never returned. Note that one lirc device is limited to 64 bpf programs, and user space I'm aware of -- ir-keytable -- always gives enough space for 64 entries already. However, we should not copy program ids than are requested. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210623213754.632-1-sean@mess.org Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/media/rc/bpf-lirc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/rc/bpf-lirc.c b/drivers/media/rc/bpf-lirc.c
index 0a0ce620e4a2..d5f839fdcde7 100644
--- a/drivers/media/rc/bpf-lirc.c
+++ b/drivers/media/rc/bpf-lirc.c
@@ -329,7 +329,8 @@ int lirc_prog_query(const union bpf_attr *attr, union bpf_attr __user *uattr)
}
if (attr->query.prog_cnt != 0 && prog_ids && cnt)
- ret = bpf_prog_array_copy_to_user(progs, prog_ids, cnt);
+ ret = bpf_prog_array_copy_to_user(progs, prog_ids,
+ attr->query.prog_cnt);
unlock:
mutex_unlock(&ir_raw_handler_lock);