[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220914123423.24368-1-liuxin350@huawei.com>
Date: Wed, 14 Sep 2022 20:34:23 +0800
From: Xin Liu <liuxin350@...wei.com>
To: <ast@...nel.org>, <daniel@...earbox.net>, <andrii@...nel.org>,
<martin.lau@...ux.dev>, <song@...nel.org>, <yhs@...com>,
<john.fastabend@...il.com>, <kpsingh@...nel.org>, <sdf@...gle.com>,
<haoluo@...gle.com>, <jolsa@...nel.org>
CC: <bpf@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<yanan@...wei.com>, <wuchangye@...wei.com>,
<xiesongyang@...wei.com>, <zhudi2@...wei.com>,
<kongweibin2@...wei.com>, <liuxin350@...wei.com>
Subject: [PATCH] libbpf: adjust OPTS_VALID logic, so that it can be used correctly
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, because OPTS_VALID can't properly prevent opts used as null
pointers during verification. Therefore, we fix this problem through this
modification.
This modification has no impact on other places where OPTS_VALID has been
used.
Fixes: 2ce8450ef5a3 ("libbpf: add bpf_object__open_{file, mem} w/ extensible opts")
Signed-off-by: Xin Liu <liuxin350@...wei.com>
---
tools/lib/bpf/libbpf_internal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index 377642ff51fc..29d3267ba56a 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -294,7 +294,7 @@ static inline bool libbpf_validate_opts(const char *opts,
}
#define OPTS_VALID(opts, type) \
- (!(opts) || libbpf_validate_opts((const char *)opts, \
+ ((opts) && libbpf_validate_opts((const char *)opts, \
offsetofend(struct type, \
type##__last_field), \
(opts)->sz, #type))
--
2.33.0
Powered by blists - more mailing lists