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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y+ANVTMT7jgV0i0l@DEN-LT-70577>
Date:   Sun, 5 Feb 2023 20:11:02 +0000
From:   <Daniel.Machon@...rochip.com>
To:     <simon.horman@...igine.com>
CC:     <netdev@...r.kernel.org>, <davem@...emloft.net>,
        <edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>,
        <Lars.Povlsen@...rochip.com>, <Steen.Hegelund@...rochip.com>,
        <UNGLinuxDriver@...rochip.com>, <joe@...ches.com>,
        <richardcochran@...il.com>, <casper.casan@...il.com>,
        <Horatiu.Vultur@...rochip.com>, <shangxiaojing@...wei.com>,
        <rmk+kernel@...linux.org.uk>, <nhuck@...gle.com>,
        <error27@...il.com>, <linux-kernel@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH net-next 03/10] net: microchip: sparx5: add support for
 Service Dual Leacky Buckets

Hi Simon,

Thanks for reviewing my patches, appreciate it!

> > +static u32 sparx5_sdlb_group_get_last(struct sparx5 *sparx5, u32 group)
> > +{
> > +     u32 itr, next;
> > +
> > +     itr = sparx5_sdlb_group_get_first(sparx5, group);
> > +
> > +     for (;;) {
> 
> Unbounded loops like this give me some apprehension.
> Will they always terminate?

Yes, it will always terminate - unless the add() del() functions are
buggy to begin with.

The end of the leak chain is marked by an index pointing to itself, and
this is the exit condition I am looking for in the unbounded loop.

> 
> > +             next = sparx5_sdlb_group_get_next(sparx5, group, itr);
> > +             if (itr == next)
> > +                     return itr;
> > +
> > +             itr = next;
> > +     }
> > +}
> 
> ...
> 
> > +static int sparx5_sdlb_group_get_adjacent(struct sparx5 *sparx5, u32 group,
> > +                                       u32 idx, u32 *prev, u32 *next,
> > +                                       u32 *first)
> > +{
> > +     u32 itr;
> > +
> > +     *first = sparx5_sdlb_group_get_first(sparx5, group);
> > +     *prev = *first;
> > +     *next = *first;
> > +     itr = *first;
> > +
> > +     for (;;) {
> > +             *next = sparx5_sdlb_group_get_next(sparx5, group, itr);
> > +
> > +             if (itr == idx)
> > +                     return 0; /* Found it */
> > +
> > +             if (itr == *next)
> > +                     return -EINVAL; /* Was not found */
> > +
> > +             *prev = itr;
> > +             itr = *next;
> > +     }
> > +}
> > +
> > +static int sparx5_sdlb_group_get_count(struct sparx5 *sparx5, u32 group)
> > +{
> > +     u32 itr, next;
> > +     int count = 0;
> > +
> > +     itr = sparx5_sdlb_group_get_first(sparx5, group);
> > +
> > +     for (;;) {
> > +             next = sparx5_sdlb_group_get_next(sparx5, group, itr);
> > +             if (itr == next)
> > +                     return count;
> > +
> > +             itr = next;
> > +             count++;
> > +     }
> > +}
> 
> ...
> 
> > +int sparx5_sdlb_group_get_by_index(struct sparx5 *sparx5, u32 idx, u32 *group)
> > +{
> > +     u32 itr, next;
> > +     int i;
> > +
> > +     for (i = 0; i < SPX5_SDLB_GROUP_CNT; i++) {
> > +             if (sparx5_sdlb_group_is_empty(sparx5, i))
> > +                     continue;
> > +
> > +             itr = sparx5_sdlb_group_get_first(sparx5, i);
> > +
> > +             for (;;) {
> > +                     next = sparx5_sdlb_group_get_next(sparx5, i, itr);
> > +
> > +                     if (itr == idx) {
> > +                             *group = i;
> > +                             return 0; /* Found it */
> > +                     }
> > +                     if (itr == next)
> > +                             break; /* Was not found */
> > +
> > +                     itr = next;
> > +             }
> > +     }
> > +
> > +     return -EINVAL;
> > +}
> 
> ...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ