From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BE3DC4332F for ; Sun, 18 Dec 2022 16:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232623AbiLRQms (ORCPT ); Sun, 18 Dec 2022 11:42:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232178AbiLRQlW (ORCPT ); Sun, 18 Dec 2022 11:41:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC4EBC0A; Sun, 18 Dec 2022 08:14:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CF503B80B43; Sun, 18 Dec 2022 16:14:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CB5DC433F0; Sun, 18 Dec 2022 16:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671380093; bh=Bjp1jxD3DELJl90QpM4hSVLxyl4yYLKc/TpVZaE/S5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oBrHrVkkyPg+PsIUqVTEmtZj3whRyhB/jdnmz+ieZItJZdfiDF7WqLxwE0OOd0/WI l9g6WYDlz6rUalNDg+HEsj4LtpyHIJG8FvcmKguMoljvDEom+D6mhuA69GH1EKrCYs 0YHauaTZaRlkWHU0by2Qm99S/nPvQQnAZRMc9dtyFplNfTzJGDRqpEDdzejS+1EC4H NgzFrcvji+UjcinCd3AzxaAdCayGQs4rDUTI70/kRZnzg8bz3OgR8FF2WT4UoiPuNQ K7goeL7xqlLxX+g/EqPLqbGYAcrN76iO1SZrh6fy+9OkjlfhPBgsxxx7PUIVEIwU1J DwKICWgjQPrCg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stanislav Fomichev , syzbot+8dd0551dda6020944c5d@syzkaller.appspotmail.com, Daniel Borkmann , Yonghong Song , Sasha Levin , martin.lau@linux.dev, ast@kernel.org, andrii@kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 32/46] bpf: Prevent decl_tag from being referenced in func_proto arg Date: Sun, 18 Dec 2022 11:12:30 -0500 Message-Id: <20221218161244.930785-32-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221218161244.930785-1-sashal@kernel.org> References: <20221218161244.930785-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stanislav Fomichev [ Upstream commit f17472d4599697d701aa239b4c475a506bccfd19 ] Syzkaller managed to hit another decl_tag issue: btf_func_proto_check kernel/bpf/btf.c:4506 [inline] btf_check_all_types kernel/bpf/btf.c:4734 [inline] btf_parse_type_sec+0x1175/0x1980 kernel/bpf/btf.c:4763 btf_parse kernel/bpf/btf.c:5042 [inline] btf_new_fd+0x65a/0xb00 kernel/bpf/btf.c:6709 bpf_btf_load+0x6f/0x90 kernel/bpf/syscall.c:4342 __sys_bpf+0x50a/0x6c0 kernel/bpf/syscall.c:5034 __do_sys_bpf kernel/bpf/syscall.c:5093 [inline] __se_sys_bpf kernel/bpf/syscall.c:5091 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5091 do_syscall_64+0x54/0x70 arch/x86/entry/common.c:48 This seems similar to commit ea68376c8bed ("bpf: prevent decl_tag from being referenced in func_proto") but for the argument. Reported-by: syzbot+8dd0551dda6020944c5d@syzkaller.appspotmail.com Signed-off-by: Stanislav Fomichev Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20221123035422.872531-2-sdf@google.com Signed-off-by: Sasha Levin --- kernel/bpf/btf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 7cb13b9f69a6..0c2fa93bd8d2 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -3864,6 +3864,11 @@ static int btf_func_proto_check(struct btf_verifier_env *env, break; } + if (btf_type_is_resolve_source_only(arg_type)) { + btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1); + return -EINVAL; + } + if (args[i].name_off && (!btf_name_offset_valid(btf, args[i].name_off) || !btf_name_valid_identifier(btf, args[i].name_off))) { -- 2.35.1