From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org
Subject: Re: [PATCH] media: bpf: do not copy more entries than user space requested
Date: Thu, 24 Jun 2021 10:21:40 +0100 [thread overview]
Message-ID: <20210624092140.GA8011@gofer.mess.org> (raw)
In-Reply-To: <20210623213754.632-1-sean@mess.org>
On Wed, Jun 23, 2021 at 10:37:54PM +0100, Sean Young wrote:
> The syscall bpf(BPF_PROG_QUERY, &attr) should the prog_cnt field to see
s/should the/should use the/
> 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>
> ---
> drivers/media/rc/bpf-lirc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/rc/bpf-lirc.c b/drivers/media/rc/bpf-lirc.c
> index 3fe3edd80876..afae0afe3f81 100644
> --- a/drivers/media/rc/bpf-lirc.c
> +++ b/drivers/media/rc/bpf-lirc.c
> @@ -326,7 +326,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);
> --
> 2.31.1
next prev parent reply other threads:[~2021-06-24 9:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 21:37 [PATCH] media: bpf: do not copy more entries than user space requested Sean Young
2021-06-24 9:21 ` Sean Young [this message]
2021-06-24 13:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210624092140.GA8011@gofer.mess.org \
--to=sean@mess.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).