From: David Laight <David.Laight@ACULAB.COM>
To: 'Colin King' <colin.king@canonical.com>,
Steve Wise <swise@chelsio.com>,
Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Cc: "kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] RDMA/cxgb3: Fix unintended sign extension
Date: Thu, 25 Oct 2018 16:03:35 +0000 [thread overview]
Message-ID: <25e5b2a5255b42ca92add0177fa4832d@AcuMS.aculab.com> (raw)
In-Reply-To: <20181025143131.4048-1-colin.king@canonical.com>
From: Colin King
> Sent: 25 October 2018 15:32
>
> From: Colin Ian King <colin.king@canonical.com>
>
> In the expression "utx_len << 28", utx_len starts as u8, but is promoted
> to a signed int, then sign-extended to u64. If utx_len is 0xf8 or greater
> then the sign extension will set all the upper bits of utx_cmd which is
> probably not what was intended. Cast to utx_len to u64 to avoid the sign
> extension.
RTFC...
utx_len is only ever 1, 2 or 3.
The 'problem' would arise if utx_len << 28 set the high bit.
This can only happen if utx_len is more than 7 (NFI where 0xf8 came from).
In any case the best fix is to use 'unsigned int' for wr_len and utx_len.
There is no point making local variable (or functions parameters/results)
smaller that 'int' unless you explicitly want the arithmetic to wrap.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2018-10-25 16:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 14:31 [PATCH] RDMA/cxgb3: Fix unintended sign extension Colin King
2018-10-25 15:26 ` Steve Wise
2018-10-25 16:03 ` David Laight [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=25e5b2a5255b42ca92add0177fa4832d@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=colin.king@canonical.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=swise@chelsio.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;
as well as URLs for NNTP newsgroup(s).