[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230605033449.239123-1-liuxin350@huawei.com>
Date: Mon, 5 Jun 2023 11:34:49 +0800
From: Xin Liu <liuxin350@...wei.com>
To: <daniel@...earbox.net>
CC: <andrii@...nel.org>, <ast@...nel.org>, <bpf@...r.kernel.org>,
<davem@...emloft.net>, <edumazet@...gle.com>, <hsinweih@....edu>,
<jakub@...udflare.com>, <john.fastabend@...il.com>, <kuba@...nel.org>,
<linux-kernel@...r.kernel.org>, <liuxin350@...wei.com>,
<netdev@...r.kernel.org>, <pabeni@...hat.com>,
<syzbot+49f6cef45247ff249498@...kaller.appspotmail.com>,
<syzkaller-bugs@...glegroups.com>, <yanan@...wei.com>,
<wuchangye@...wei.com>, <xiesongyang@...wei.com>, <kongweibin2@...wei.com>,
<zhangmingyi5@...wei.com>
Subject: [PATCH] libbpf:fix use empty function pointers in ringbuf_poll
From: zhangmingyi <zhangmingyi5@...wei.com>
The sample_cb of the ring_buffer__new interface can transfer NULL. However,
the system does not check whether sample_cb is NULL during
ring_buffer__poll, null pointer is used.
Signed-off-by: zhangmingyi <zhangmingyi5@...wei.com>
---
tools/lib/bpf/ringbuf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c
index 02199364db13..3661338a1d2e 100644
--- a/tools/lib/bpf/ringbuf.c
+++ b/tools/lib/bpf/ringbuf.c
@@ -248,7 +248,7 @@ static int64_t ringbuf_process_ring(struct ring *r)
got_new_data = true;
cons_pos += roundup_len(len);
- if ((len & BPF_RINGBUF_DISCARD_BIT) == 0) {
+ if (r->sample_cb && ((len & BPF_RINGBUF_DISCARD_BIT) == 0)) {
sample = (void *)len_ptr + BPF_RINGBUF_HDR_SZ;
err = r->sample_cb(r->ctx, sample, len);
if (err < 0) {
--
2.33.0
Powered by blists - more mailing lists