lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAKH8qBt_8mEA_2Bn=z9o-rntov8nPa=sH93R8-+zM99u+qP6Fg@mail.gmail.com>
Date:   Sat, 10 Sep 2022 13:29:47 -0700
From:   Stanislav Fomichev <sdf@...gle.com>
To:     eadavis@...a.com
Cc:     syzbot+5d1da78b375c3b5e6c2b@...kaller.appspotmail.com,
        andrii@...nel.org, ast@...nel.org, bpf@...r.kernel.org,
        daniel@...earbox.net, haoluo@...gle.com, john.fastabend@...il.com,
        jolsa@...nel.org, kpsingh@...nel.org, linux-kernel@...r.kernel.org,
        martin.lau@...ux.dev, netdev@...r.kernel.org, song@...nel.org,
        syzkaller-bugs@...glegroups.com, yhs@...com,
        eadivs <eadivs@...a.com>
Subject: Re: [PATCH] kernel/bpf: htab_map_alloc() exit by free_map_locked
 logic issue

On Fri, Sep 9, 2022 at 7:07 PM <eadavis@...a.com> wrote:
>
> From: eadivs <eadivs@...a.com>
>
> syzbot is reporting WARNING: ODEBUG bug in htab_map_alloc(), the
> loop exits without reaching length HASHTAB_MAP_LOCK_COUNT, and
> the loop continues HASHTAB_MAP_LOCK_COUNT times in label
> free_map_locked.

Please use [PATCH bpf] vs [PATCH bpf-next] in subject to indicate
which tree you're targeting.
Also, it seems your email hasn't reached the mailing list for some reason.

Are you sure that the issue is due to HASHTAB_MAP_LOCK_COUNT? The code
seems fine as is; unconditionally calling free on NULL shouldn't be an
issue.

 htab_map_alloc+0xc76/0x1620 kernel/bpf/hashtab.c:632

Which, if I'm looking at the function is:
bpf_map_area_free(htab);

?

> Link: https://syzkaller.appspot.com/bug?extid=5d1da78b375c3b5e6c2b
> Reported-by: syzbot+5d1da78b375c3b5e6c2b@...kaller.appspotmail.com
> Signed-off-by: eadivs <eadivs@...a.com>
> ---
>  kernel/bpf/hashtab.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
> index 65877967f414..f5381e1c00a6 100644
> --- a/kernel/bpf/hashtab.c
> +++ b/kernel/bpf/hashtab.c
> @@ -473,7 +473,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
>         bool percpu_lru = (attr->map_flags & BPF_F_NO_COMMON_LRU);
>         bool prealloc = !(attr->map_flags & BPF_F_NO_PREALLOC);
>         struct bpf_htab *htab;
> -       int err, i;
> +       int err, i, j = HASHTAB_MAP_LOCK_COUNT;
>
>         htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT);
>         if (!htab)
> @@ -523,8 +523,10 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
>                                                            sizeof(int),
>                                                            sizeof(int),
>                                                            GFP_USER);
> -               if (!htab->map_locked[i])
> +               if (!htab->map_locked[i]) {
> +                       j = i;
>                         goto free_map_locked;
> +               }
>         }
>
>         if (htab->map.map_flags & BPF_F_ZERO_SEED)
> @@ -554,7 +556,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
>  free_prealloc:
>         prealloc_destroy(htab);
>  free_map_locked:
> -       for (i = 0; i < HASHTAB_MAP_LOCK_COUNT; i++)
> +       for (i = 0; i < j; i++)
>                 free_percpu(htab->map_locked[i]);
>         bpf_map_area_free(htab->buckets);
>  free_htab:
> --
> 2.37.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ