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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210913110246.2955737-1-mudongliangabcd@gmail.com>
Date:   Mon, 13 Sep 2021 19:02:46 +0800
From:   Dongliang Mu <mudongliangabcd@...il.com>
To:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>, Willy Tarreau <w@....eu>
Cc:     Dongliang Mu <mudongliangabcd@...il.com>,
        syzbot+f3e749d4c662818ae439@...kaller.appspotmail.com,
        netdev@...r.kernel.org, bpf@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] bpf: fix kmalloc bug in bpf_check

Since 7661809d493b ("mm: don't allow oversized kvmalloc() calls
") does not allow oversized kvmalloc, it triggers a kmalloc bug warning
at bpf_check.

Fix it by adding a sanity check in th check_btf_line.

Reported-by: syzbot+f3e749d4c662818ae439@...kaller.appspotmail.com
Fixes: 7661809d493b ("mm: don't allow oversized kvmalloc() calls")
Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
---
 kernel/bpf/verifier.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 047ac4b4703b..3c5a79f78bc5 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -9913,6 +9913,9 @@ static int check_btf_line(struct bpf_verifier_env *env,
 	if (!nr_linfo)
 		return 0;
 
+	if (nr_linfo > INT_MAX/sizeof(struct bpf_line_info))
+		return -EINVAL;
+
 	rec_size = attr->line_info_rec_size;
 	if (rec_size < MIN_BPF_LINEINFO_SIZE ||
 	    rec_size > MAX_LINEINFO_REC_SIZE ||
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ