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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 23 Sep 2020 10:25:34 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Toke Høiland-Jørgensen <toke@...hat.com>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>,
        John Fastabend <john.fastabend@...il.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Eelco Chaudron <echaudro@...hat.com>,
        KP Singh <kpsingh@...omium.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next v8 01/11] bpf: disallow attaching modify_return
 tracing functions to other BPF programs

On Tue, Sep 22, 2020 at 11:39 AM Toke Høiland-Jørgensen <toke@...hat.com> wrote:
>
> From: Toke Høiland-Jørgensen <toke@...hat.com>
>
> From the checks and commit messages for modify_return, it seems it was
> never the intention that it should be possible to attach a tracing program
> with expected_attach_type == BPF_MODIFY_RETURN to another BPF program.
> However, check_attach_modify_return() will only look at the function name,
> so if the target function starts with "security_", the attach will be
> allowed even for bpf2bpf attachment.
>
> Fix this oversight by also blocking the modification if a target program is
> supplied.
>
> Fixes: 18644cec714a ("bpf: Fix use-after-free in fmod_ret check")
> Fixes: 6ba43b761c41 ("bpf: Attachment verification for BPF_MODIFY_RETURN")
> Signed-off-by: Toke Høiland-Jørgensen <toke@...hat.com>
> ---

Acked-by: Andrii Nakryiko <andriin@...com>

>  kernel/bpf/verifier.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 15ab889b0a3f..797e2b0d8bc2 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -11471,6 +11471,11 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
>                                 verbose(env, "%s is not sleepable\n",
>                                         prog->aux->attach_func_name);
>                 } else if (prog->expected_attach_type == BPF_MODIFY_RETURN) {
> +                       if (tgt_prog) {
> +                               verbose(env, "can't modify return codes of BPF programs\n");
> +                               ret = -EINVAL;
> +                               goto out;
> +                       }
>                         ret = check_attach_modify_return(prog, addr);
>                         if (ret)
>                                 verbose(env, "%s() is not modifiable\n",
>

Powered by blists - more mailing lists