[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c0b02b51-dba3-43f3-8d21-c3183c0342d8@linux.dev>
Date: Tue, 9 Jul 2024 11:24:57 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: syzbot <syzbot+608a2acde8c5a101d07d@...kaller.appspotmail.com>,
netdev@...r.kernel.org, bpf@...r.kernel.org, andrii@...nel.org,
ast@...nel.org, daniel@...earbox.net, davem@...emloft.net,
dsahern@...nel.org, eddyz87@...il.com, edumazet@...gle.com,
haoluo@...gle.com, john.fastabend@...il.com, jolsa@...nel.org,
kpsingh@...nel.org, kuba@...nel.org, pabeni@...hat.com, sdf@...ichev.me,
sdf@...gle.com, song@...nel.org, syzkaller-bugs@...glegroups.com,
yonghong.song@...ux.dev, Thomas Gleixner <tglx@...utronix.de>,
Mathieu Xhonneux <m.xhonneux@...il.com>, David Lebrun <dlebrun@...gle.com>
Subject: Re: [PATCH bpf-next] seg6: Ensure that seg6_bpf_srh_states can only
be accessed from input_action_end_bpf()
On 7/8/24 10:18 PM, Sebastian Andrzej Siewior wrote:
> On 2024-07-08 17:03:58 [-0700], Martin KaFai Lau wrote:
>>> diff --git a/net/core/filter.c b/net/core/filter.c
>>> index 403d23faf22e1..ea5bc4a4a6a23 100644
>>> --- a/net/core/filter.c
>>> +++ b/net/core/filter.c
>>> @@ -6459,6 +6459,8 @@ BPF_CALL_4(bpf_lwt_seg6_store_bytes, struct sk_buff *, skb, u32, offset,
>>> void *srh_tlvs, *srh_end, *ptr;
>>> int srhoff = 0;
>>> + if (!bpf_net_ctx_seg6_state_avail())
>>> + return -EINVAL;
>>
>> The syzbot stack shows that the seg6local bpf_prog can be run by test_run
>> like: bpf_prog_test_run_skb() => bpf_test_run(). "return -EINVAL;" will
>> reject and break the existing bpf prog doing test with test_run.
>
> But wouldn't this be the case anyway because seg6_bpf_srh_states::srh
> isn't assigned?
Good point.
I don't think the test_run for BPF_PROG_TYPE_LWT_SEG6LOCAL ever works. It seems
no test_run selftest was ever added to exercise this code path since the
lwt_seg6local_prog_ops was added in commit 004d4b274e2a ("ipv6: sr: Add
seg6local action End.BPF").
I think the right thing to do here is to remove the test_run code path for
BPF_PROG_TYPE_LWT_SEG6LOCAL instead of further patching it. A separate patch for
proper test_run support is needed (cc: Mathieu Xhonneux).
To remove test_run for BPF_PROG_TYPE_LWT_SEG6LOCAL, this should do:
diff --git i/net/core/filter.c w/net/core/filter.c
index 403d23faf22e..db5e59f62b35 100644
--- i/net/core/filter.c
+++ w/net/core/filter.c
@@ -11053,7 +11053,6 @@ const struct bpf_verifier_ops lwt_seg6local_verifier_ops = {
};
const struct bpf_prog_ops lwt_seg6local_prog_ops = {
- .test_run = bpf_prog_test_run_skb,
};
const struct bpf_verifier_ops cg_sock_verifier_ops = {
Then the bpf_lwt_seg6_* helpers should stay in the input_action_end_bpf() code
path only.
Powered by blists - more mailing lists