lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzazQgrPVqKOGP8z=MPZhjZHCZDdcWQB0xBuudXbxXwaXg@mail.gmail.com>
Date:   Wed, 5 May 2021 11:45:17 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Jiri Olsa <jolsa@...nel.org>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andriin@...com>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>
Subject: Re: [PATCH] bpf: Forbid trampoline attach for functions with variable arguments

On Wed, May 5, 2021 at 6:42 AM Jiri Olsa <jolsa@...nel.org> wrote:
>
> We can't currently allow to attach functions with variable arguments.
> The problem is that we should save all the registers for arguments,
> which is probably doable, but if caller uses more than 6 arguments,
> we need stack data, which will be wrong, because of the extra stack
> frame we do in bpf trampoline, so we could crash.
>
> Also currently there's malformed trampoline code generated for such
> functions at the moment as described in:
>   https://lore.kernel.org/bpf/20210429212834.82621-1-jolsa@kernel.org/
>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---

LGTM.

Acked-by: Andrii Nakryiko <andrii@...nel.org>

>  kernel/bpf/btf.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 0600ed325fa0..161511bb3e51 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -5206,6 +5206,13 @@ int btf_distill_func_proto(struct bpf_verifier_log *log,
>         m->ret_size = ret;
>
>         for (i = 0; i < nargs; i++) {
> +               if (i == nargs - 1 && args[i].type == 0) {
> +                       bpf_log(log,
> +                               "The function %s with variable args is unsupported.\n",
> +                               tname);
> +                       return -EINVAL;
> +
> +               }
>                 ret = __get_type_size(btf, args[i].type, &t);
>                 if (ret < 0) {
>                         bpf_log(log,
> @@ -5213,6 +5220,12 @@ int btf_distill_func_proto(struct bpf_verifier_log *log,
>                                 tname, i, btf_kind_str[BTF_INFO_KIND(t->info)]);
>                         return -EINVAL;
>                 }
> +               if (ret == 0) {
> +                       bpf_log(log,
> +                               "The function %s has malformed void argument.\n",
> +                               tname);
> +                       return -EINVAL;
> +               }
>                 m->arg_size[i] = ret;
>         }
>         m->nr_args = nargs;
> --
> 2.30.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ