From: Logan Gunthorpe <logang@deltatee.com>
To: Serge Semin <fancer.lancer@gmail.com>,
jdmason@kudzu.us, dave.jiang@intel.com, Allen.Hubbe@emc.com,
Shyam-sundar.S-k@amd.com, Xiangliang.Yu@amd.com
Cc: Sergey.Semin@t-platforms.ru, linux-ntb@googlegroups.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] NTB: Fix UB/bug in ntb_mw_get_align()
Date: Thu, 30 Nov 2017 15:07:52 -0700 [thread overview]
Message-ID: <903ec475-1163-efd8-13ea-6b531210b928@deltatee.com> (raw)
In-Reply-To: <20171130213941.21114-1-fancer.lancer@gmail.com>
On 30/11/17 02:39 PM, Serge Semin 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.
>
> Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.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,
>
prev parent reply other threads:[~2017-11-30 22:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 21:39 Serge Semin
2017-11-30 22:07 ` Logan Gunthorpe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=903ec475-1163-efd8-13ea-6b531210b928@deltatee.com \
--to=logang@deltatee.com \
--cc=Allen.Hubbe@emc.com \
--cc=Sergey.Semin@t-platforms.ru \
--cc=Shyam-sundar.S-k@amd.com \
--cc=Xiangliang.Yu@amd.com \
--cc=dave.jiang@intel.com \
--cc=fancer.lancer@gmail.com \
--cc=jdmason@kudzu.us \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ntb@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®