This is a note to let you know that I've just added the patch titled bpf: Fix a buffer out-of-bound access when filling raw_tp link_info to the 5.8-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: bpf-fix-a-buffer-out-of-bound-access-when-filling-ra.patch and it can be found in the queue-5.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 48fbc9d120ef44db4e87cee6fad5f884ec3b83b9 Author: Yonghong Song <yhs@xxxxxx> Date: Fri Aug 21 12:10:54 2020 -0700 bpf: Fix a buffer out-of-bound access when filling raw_tp link_info [ Upstream commit b474959d5afda6e341a02c85f9595d85d39189ae ] Commit f2e10bff16a0 ("bpf: Add support for BPF_OBJ_GET_INFO_BY_FD for bpf_link") added link query for raw_tp. One of fields in link_info is to fill a user buffer with tp_name. The Scurrent checking only declares "ulen && !ubuf" as invalid. So "!ulen && ubuf" will be valid. Later on, we do "copy_to_user(ubuf, tp_name, ulen - 1)" which may overwrite user memory incorrectly. This patch fixed the problem by disallowing "!ulen && ubuf" case as well. Fixes: f2e10bff16a0 ("bpf: Add support for BPF_OBJ_GET_INFO_BY_FD for bpf_link") Signed-off-by: Yonghong Song <yhs@xxxxxx> Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> Acked-by: Andrii Nakryiko <andriin@xxxxxx> Link: https://lore.kernel.org/bpf/20200821191054.714731-1-yhs@xxxxxx Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 0fd80ac81f705..72e943b3bd656 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -2629,7 +2629,7 @@ static int bpf_raw_tp_link_fill_link_info(const struct bpf_link *link, u32 ulen = info->raw_tracepoint.tp_name_len; size_t tp_len = strlen(tp_name); - if (ulen && !ubuf) + if (!ulen ^ !ubuf) return -EINVAL; info->raw_tracepoint.tp_name_len = tp_len + 1;