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]
Date:   Tue, 5 Dec 2017 11:52:32 -0500
From:   Jon Mason <jdmason@...zu.us>
To:     Serge Semin <fancer.lancer@...il.com>
Cc:     Dave Jiang <dave.jiang@...el.com>,
        "Hubbe, Allen" <Allen.Hubbe@....com>,
        "S-k, Shyam-sundar" <Shyam-sundar.S-k@....com>,
        "Yu, Xiangliang" <Xiangliang.Yu@....com>,
        Gary R Hook <gary.hook@....com>, Sergey.Semin@...latforms.ru,
        linux-ntb <linux-ntb@...glegroups.com>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 03/15] NTB: Fix UB/bug in ntb_mw_get_align()

On Sun, Dec 3, 2017 at 2:17 PM, Serge Semin <fancer.lancer@...il.com> wrote:
> Simple (1 << pidx) operation causes undefined behaviour when
> pidx >= 32. It must be casted to u64 to match the actual return
> value of ntb_link_is_up() method, so to have all the possible
> peer indexes covered and to get rid of undefined behaviour.
> Additionally there are special macros in "linux/bitops.h" to perform
> the bit-set-shift operations, so it's recommended to have them used
> for proper bit setting.

This looks good to me, but also seems like a bug fix.  Please comment
on if this is not noticed.

Thanks,
Jon

>
> Signed-off-by: Serge Semin <fancer.lancer@...il.com>
> Reviewed-by: Logan Gunthorpe <logang@...tatee.com>
> ---
>  include/linux/ntb.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/ntb.h b/include/linux/ntb.h
> index c1646f2c6344..488e586fb76c 100644
> --- a/include/linux/ntb.h
> +++ b/include/linux/ntb.h
> @@ -764,7 +764,7 @@ static inline int ntb_mw_get_align(struct ntb_dev *ntb, int pidx, int widx,
>                                    resource_size_t *size_align,
>                                    resource_size_t *size_max)
>  {
> -       if (!(ntb_link_is_up(ntb, NULL, NULL) & (1 << pidx)))
> +       if (!(ntb_link_is_up(ntb, NULL, NULL) & BIT_ULL(pidx)))
>                 return -ENOTCONN;
>
>         return ntb->ops->mw_get_align(ntb, pidx, widx, addr_align, size_align,
> --
> 2.12.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ