From patchwork Wed Oct 19 08:26:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp228609wrs; Wed, 19 Oct 2022 02:52:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM45T+Ag2x8mp3UtpgZQwUbmmXeXZSaC8CjyckGYV7YSRWrdrPjhhuxZ/S5whapoHnI1UsO9 X-Received: by 2002:a17:907:2c5b:b0:78d:3f8a:19d0 with SMTP id hf27-20020a1709072c5b00b0078d3f8a19d0mr5875096ejc.369.1666173168416; Wed, 19 Oct 2022 02:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666173168; cv=none; d=google.com; s=arc-20160816; b=XK6ZBrs8pnbT2X7Lrepqj2NJfVG6b2yXll/TBFyQoPtvHPNRrmndtdnsuiaALMDNie sHBhGUzfRl+n9XXFKgPqTB51dR8P1pQQJ/bS9INA5qEkabqNhCtRFkYI7gQfIjFYHp8X u1kWsk2V63T9bH8JmoZzQMO0WQvp+pqEJmHqSyHqsldJbEAhY/qlG5woSnY7mb9XMASk m0IVZQsZWl6dtMMIK/GTQ+6h5NDzHUJyD+M0H9kcdRVqbvMEQxDEQs7Eul/fRZb8qGqF WriYjE5dBTPSU7tofUxIpAqeFa8ahOh6ntCvjR3P2+8Y62KyQi2k6tKnGtTQsqdJQxaa racA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go37-20020a1709070da500b0078df79d698dsi14295501ejc.810.2022.10.19.02.52.23; Wed, 19 Oct 2022 02:52:48 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747109196420776303?= X-GMAIL-MSGID: =?utf-8?q?1747109196420776303?= 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,