lkml.org 
[lkml]   [2022]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH bpf] bpf: Fix kernel BUG in purge_effective_progs
From
Date
On 8/18/22 7:26 AM, Greg KH wrote:
> On Thu, Aug 18, 2022 at 10:46:33AM +0800, Pu Lehui wrote:
>> On 2022/8/17 4:39, Andrii Nakryiko wrote:
>>> On Sat, Aug 13, 2022 at 6:11 AM Pu Lehui <pulehui@huawei.com> wrote:
[...]
>>>> Failslab injection will cause kmalloc fail and fall back to
>>>> purge_effective_progs. The problem is that cg2 have attached another prog,
>>>> so when go through cg2 layer, iteration will add pos to 1, and subsequent
>>>> operations will be skipped by the following condition, and cg will meet
>>>> NULL in the end.
>>>>
>>>> `if (pos && !(cg->bpf.flags[atype] & BPF_F_ALLOW_MULTI))`
>>>>
>>>> The NULL cg means no link or prog match, this is as expected, and it's not
>>>> a bug. So here just skip the no match situation.
>>>>
>>>> Fixes: 4c46091ee985 ("bpf: Fix KASAN use-after-free Read in compute_effective_progs")
>>>> Signed-off-by: Pu Lehui <pulehui@huawei.com>
>>>> ---
>>>> kernel/bpf/cgroup.c | 4 +++-
>>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
>>>> index 59b7eb60d5b4..4a400cd63731 100644
>>>> --- a/kernel/bpf/cgroup.c
>>>> +++ b/kernel/bpf/cgroup.c
>>>> @@ -921,8 +921,10 @@ static void purge_effective_progs(struct cgroup *cgrp, struct bpf_prog *prog,
>>>> pos++;
>>>> }
>>>> }
>>>> +
>>>> + /* no link or prog match, skip the cgroup of this layer */
>>>> + continue;
>>>> found:
>>>> - BUG_ON(!cg);
>>>
>>> I don't think it's necessary to remove this BUG_ON(), but it also
>>> feels unnecessary for purge_effective_progs, so I don't mind it.
>>>
>>> Acked-by: Andrii Nakryiko <andrii@kernel.org>
>>
>> Will this patch be accepted? I think we should CC stable.

Stable will pick this up given Fixes tag. We were pinging also original patch author,
Tadeusz, for an ACK to include in commit msg, but looks he's unresponsive ... anyway,
applied, thanks!

\
 
 \ /
  Last update: 2022-08-18 23:36    [W:0.043 / U:0.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site