From: Yonghong Song <yhs@meta.com>
To: WritePaper <clangllvm@126.com>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, song@kernel.org, yhs@fb.com
Cc: john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com,
haoluo@google.com, jolsa@kernel.org, rostedt@goodmis.org,
mhiramat@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] bpf: security enhancement by limiting the offensive eBPF helpers
Date: Tue, 17 Jan 2023 09:24:56 -0800 [thread overview]
Message-ID: <f539bfef-c098-5ff0-51ef-bfa8fd0c4661@meta.com> (raw)
In-Reply-To: <20230117151256.605977-1-clangllvm@126.com>
On 1/17/23 7:12 AM, WritePaper wrote:
> The bpf_send_singal and bpf_override_return is similar to
> bpf_write_user and can affect userspace processes. Thus, these two
> helpers should also be constraint by security lockdown.
>
> Signed-off-by: WritePaper <clangllvm@126.com>
> ---
> include/linux/security.h | 3 +++
> kernel/trace/bpf_trace.c | 6 ++++--
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/security.h b/include/linux/security.h
> index 5b67f208f..cb90b2860 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -123,6 +123,9 @@ enum lockdown_reason {
> LOCKDOWN_DEBUGFS,
> LOCKDOWN_XMON_WR,
> LOCKDOWN_BPF_WRITE_USER,
> + LOCKDOWN_BPF_SEND_SIGNAL,
> + LOCKDOWN_BPF_OVERRIDE_RETURN,
> + LOCKDOWN_OFFENSIVE_BPF_MAX,
LOCKDOWN_OFFENSIVE_BPF_MAX is not used.
> LOCKDOWN_DBG_WRITE_KERNEL,
> LOCKDOWN_RTAS_ERROR_INJECTION,
> LOCKDOWN_INTEGRITY_MAX,
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 3bbd3f0c8..3a80f4b6f 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -1463,7 +1463,8 @@ bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
> return &bpf_cgrp_storage_delete_proto;
> #endif
> case BPF_FUNC_send_signal:
> - return &bpf_send_signal_proto;
> + return security_locked_down(LOCKDOWN_BPF_SEND_SIGNAL) < 0 ?
> + NULL : &bpf_send_signal_proto;
You should add the same security_locked_down(LOCKDOWN_BPF_SEND_SIGNAL)
check with below bpf_send_signal_thread() helper.
> case BPF_FUNC_send_signal_thread:
> return &bpf_send_signal_thread_proto;
> case BPF_FUNC_perf_event_read_value:
> @@ -1531,7 +1532,8 @@ kprobe_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
> return &bpf_get_stack_proto;
> #ifdef CONFIG_BPF_KPROBE_OVERRIDE
> case BPF_FUNC_override_return:
> - return &bpf_override_return_proto;
> + return security_locked_down(LOCKDOWN_BPF_OVERRIDE_RETURN) < 0 ?
> + NULL : &bpf_override_return_proto;
> #endif
> case BPF_FUNC_get_func_ip:
> return prog->expected_attach_type == BPF_TRACE_KPROBE_MULTI ?
next prev parent reply other threads:[~2023-01-17 17:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 15:12 WritePaper
2023-01-17 16:16 ` Greg KH
2023-01-17 17:24 ` Yonghong Song [this message]
2023-01-18 0:54 ` [PATCH V2] " Yi He
2023-01-18 5:25 ` Yonghong Song
2023-01-18 9:49 ` Daniel Borkmann
2023-01-18 11:18 ` Yi He
2023-01-18 15:36 ` Djalal Harouni
2023-01-19 4:22 ` Yi He
2023-01-20 0:26 ` KP Singh
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=f539bfef-c098-5ff0-51ef-bfa8fd0c4661@meta.com \
--to=yhs@meta.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clangllvm@126.com \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yhs@fb.com \
/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
all inboxes | Powered by JetHome®