Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1473426rwj; Sun, 18 Dec 2022 08:53:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf59IFF834MIT17ArRdWbKlkp0Eg/KJ3Lha29w4vCR8mI77kmsKLObG6omDQA8JalzlxxzMQ X-Received: by 2002:aa7:c712:0:b0:46b:1715:e64 with SMTP id i18-20020aa7c712000000b0046b17150e64mr33203190edq.18.1671382385461; Sun, 18 Dec 2022 08:53:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671382385; cv=none; d=google.com; s=arc-20160816; b=brNJMGRkivHYIPSwGEQ3RJFHLvgUYKdGrFWTC2EjCRMMCO7bq6+ck+M0MS8gskV4yY FgUqCnlkPajqthjzFDM7AyJhIfaIMPRG2gtH2wRxIHqQRoCAebV/v3T+0vsN5ADB0/ka PSME//rX0NcbleBF2uTza/xJ1i6VBIgO6YZFa3pAR/RHmXOKgiCsY1t6gdzpnMVn5unz 4zuedgfo+T31VSRMuFq8AzICgjEWgL5IHVsIiW/HInrphaleQ6e5E0LXg1lwt3tjWCB9 pr5aD5KtbjqcHyZZW7h5ujbRG7Pw+6N5HfrRi4SRVPEe8xBIyP57a9Ch24qcyE/VV46g Vrwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ht+Om8Rfd7wE32iv5GbadBcMfRUHfZEqe0yDBONVSyE=; b=A0Tf6KpHB0d2DI3ohgGSIEugsJ3T8KVAZLNmRTPyAzVEWZTN2eR3+pYQdIPdIFqlT9 Q0fV9yJQvmJNpF7sxOyMrI975wRhMQlPLRgZpKek8q+BWQesRpZQkfBj+UZ/FZVdPovC 7O4jyY6pNgbQMDt3NNzCfzabUS/wprdFJHKVW5KEKaakL7w/F8R4KVPxpaCfWmgUIOb7 Darhwds8qVUEqVYno7yw+cizjf4+gNIRAxONcXkKQkt7xDKEUD5KGCmsoB4jMQ6oFqW0 28sZurNXQwoF6si/0YT40Khsf5N5DFxSmK6WNptTKsTKE4FYa/v4QObdD2+RRrOrqukB w3vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oBrHrVkk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020aa7d350000000b0045e00384e8asi6422660edr.380.2022.12.18.08.52.48; Sun, 18 Dec 2022 08:53:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oBrHrVkk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232597AbiLRQmr (ORCPT + 70 others); Sun, 18 Dec 2022 11:42:47 -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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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