Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp803704rwi; Wed, 19 Oct 2022 03:13:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM669FzIz7Dop/9L6oSXiCQIp/PNTmQLNMayJPGYQDE/h3PsQ0CjFdbpirCo9u6AqT6e4poR X-Received: by 2002:a17:907:b10:b0:78e:2eb4:1faa with SMTP id h16-20020a1709070b1000b0078e2eb41faamr6009850ejl.216.1666174397944; Wed, 19 Oct 2022 03:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174397; cv=none; d=google.com; s=arc-20160816; b=M9D1T2bJeBxx6pnnpSP40gYL39oT9k+eWZ7uR5UOp4MlzxGbBqLwdkjmGFo4GVCTsw 6nm9VKVwt/Y0m3c7W0liT+5BzLZ1qwoP/RUJODVh48q/0QO/vTwCBxIGBP6OZT7H+hkH /PrhUJ0kF2IRpGn8Wi26hFhSjHSslUhw8qCO/57oKgbcLTcc8Imp3Huaa6jaXy1UlClv 5jsU8jPwM5UcdYNScrTRIkKgNfgDwbgDL3N1aYRB9O9ufVXzvTt3AWIcTzk7Lu21gPBX xy/2UxPPaRcDOiP15OUh+4Slj/TwZ5Dc5r1BGjCk7ntoWZ9NbbZtkiY7w0evJNiZkMF1 NY9w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xISEV4Ml7kzp84rB1YFcw2AxqkOcBi+tuDbY9WzCrbM=; b=ZJnPnA6Vaj3JO30JIgI98oST9aK7pldEImm6Zk8hO+IY88iueSm6PF8YpuKZtZUywa N6xFvq1Eoxebyb481tvKkexYvr2D1Vik+mUpV2PKvTK56EBLNlDYHkdITDLEpc0OR738 YrDAuqrcQ7R+lSQXXHqjBJHis7L+ZLWRjI0h8izIRcBPZcWkfFsROq2h9P/jdtmv1Mi4 Gu49xq6xeVLfEVpEI2v/xZDmE0Lh6aIQJwFl7zFhulEcBktF+IU5j7/kIkeKoyrv9war NLfxmW/xJdJEuhKBeKMD2uh9QcvQLPYvCsvSdOpE2P6L8e8xfJ6ix/olZ1Lpk4dbmVvh U++g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="PJjeyq/P"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m14-20020a056402510e00b0045dc25bb7easi5758216edd.555.2022.10.19.03.12.50; Wed, 19 Oct 2022 03:13:17 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="PJjeyq/P"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234310AbiJSJpg (ORCPT + 99 others); Wed, 19 Oct 2022 05:45:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234868AbiJSJlp (ORCPT ); Wed, 19 Oct 2022 05:41:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB553559D; Wed, 19 Oct 2022 02:18:07 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id AF06561873; Wed, 19 Oct 2022 08:51:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2E0CC433C1; Wed, 19 Oct 2022 08:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169501; bh=JG8aswyTxj+PG1imCI7E1yc8Njj0+tfR7kirz+dwzUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PJjeyq/PLW6FJSe0u7ezCfDhdt1eAkZSXCVsA8WbyhneaASXZ6nxy3+EqdFlCMwKI ztdIb3Om5+tNmrwRvgFEgQuLtdTW/hac8PurlDBKZYWjj+4VvFCz9BlotQDe8CQrZE eIZyWTFY00BUJQUpBc/mObxhQ04XVRLhKz8a46tY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Liu , Weibin Kong , Andrii Nakryiko , Sasha Levin Subject: [PATCH 6.0 299/862] libbpf: Fix NULL pointer exception in API btf_dump__dump_type_data Date: Wed, 19 Oct 2022 10:26:26 +0200 Message-Id: <20221019083303.226230896@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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: Xin Liu [ Upstream commit 7620bffbf72cd66a5d18e444a143b5b5989efa87 ] We found that function btf_dump__dump_type_data can be called by the user as an API, but in this function, the `opts` parameter may be used as a null pointer.This causes `opts->indent_str` to trigger a NULL pointer exception. Fixes: 2ce8450ef5a3 ("libbpf: add bpf_object__open_{file, mem} w/ extensible opts") Signed-off-by: Xin Liu Signed-off-by: Weibin Kong Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220917084809.30770-1-liuxin350@huawei.com Signed-off-by: Sasha Levin --- tools/lib/bpf/btf_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c index 627edb5bb6de..4221f73a74d0 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -2385,7 +2385,7 @@ int btf_dump__dump_type_data(struct btf_dump *d, __u32 id, d->typed_dump->indent_lvl = OPTS_GET(opts, indent_level, 0); /* default indent string is a tab */ - if (!opts->indent_str) + if (!OPTS_GET(opts, indent_str, NULL)) d->typed_dump->indent_str[0] = '\t'; else libbpf_strlcpy(d->typed_dump->indent_str, opts->indent_str, -- 2.35.1