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] [day] [month] [year] [list]
Date:   Tue, 3 May 2022 20:33:11 +0900
From:   Juhee Kang <claudiajkang@...il.com>
To:     Taehee Yoo <ap420073@...il.com>
Cc:     Joe Perches <joe@...ches.com>, Paolo Abeni <pabeni@...hat.com>,
        davem@...emloft.net, Jakub Kicinski <kuba@...nel.org>,
        Networking <netdev@...r.kernel.org>
Subject: Re: [net-next PATCH] amt: Use BIT macros instead of open codes

Hello Paolo and Joe,

Thanks for the reviews!


On Tue, May 3, 2022 at 6:28 PM Taehee Yoo <ap420073@...il.com> wrote:
>
> 2022. 5. 3. 오전 2:19에 Joe Perches 이(가) 쓴 글:
>  > On Mon, 2022-05-02 at 12:11 +0200, Paolo Abeni wrote:
>
> Hi Paolo and Joe,
> Thanks a lot for the reviews!
>
>  >> On Sat, 2022-04-30 at 13:56 +0000, Juhee Kang wrote:
>  >>> Replace open code related to bit operation with BIT macros, which
> kernel
>  >>> provided. This patch provides no functional change.
>  > []
>  >>> diff --git a/drivers/net/amt.c b/drivers/net/amt.c
>  > []
>  >>> @@ -959,7 +959,7 @@ static void amt_req_work(struct work_struct *work)
>  >>>    amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true);
>  >>>    spin_lock_bh(&amt->lock);
>  >>>   out:
>  >>> -  exp = min_t(u32, (1 * (1 << amt->req_cnt)), AMT_MAX_REQ_TIMEOUT);
>  >>> +  exp = min_t(u32, (1 * BIT(amt->req_cnt)), AMT_MAX_REQ_TIMEOUT);
>  >>>    mod_delayed_work(amt_wq, &amt->req_wq, msecs_to_jiffies(exp *
> 1000));
>  >>>    spin_unlock_bh(&amt->lock);
>  >>>   }
>  >>> diff --git a/include/net/amt.h b/include/net/amt.h
>  > []
>  >>> @@ -354,7 +354,7 @@ struct amt_dev {
>  >>>   #define AMT_MAX_GROUP            32
>  >>>   #define AMT_MAX_SOURCE           128
>  >>>   #define AMT_HSIZE_SHIFT          8
>  >>> -#define AMT_HSIZE         (1 << AMT_HSIZE_SHIFT)
>  >>> +#define AMT_HSIZE         BIT(AMT_HSIZE_SHIFT)
>  >>>
>  >>>   #define AMT_DISCOVERY_TIMEOUT    5000
>  >>>   #define AMT_INIT_REQ_TIMEOUT     1
>  >>
>  >> Even if the 2 replaced statements use shift operations, they do not
>  >> look like bit manipulation: the first one is an exponential timeout,
>  >> the 2nd one is an (hash) size. I think using the BIT() macro here will
>  >> be confusing.
>  >
>  > I agree.
>  >
>  > I also believe one of the uses of amt->req_cnt is error prone.
>  >
>  >      drivers/net/amt.c:946:  if (amt->req_cnt++ > AMT_MAX_REQ_COUNT) {
>  >
>  > Combining a test and post increment is not a great style IMO.
>  > Is this really the intended behavior?
>
> I agree that it would be better to avoid that style.
> I will send a patch for that after some bugfix.
>
> Thanks a lot,
> Taehee Yoo
>
>  >
>  >



-- 

Best regards,
Juhee Kang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ