From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Ilya Dryomov <idryomov@gmail.com>, "Yan, Zheng" <zyan@redhat.com>,
Sage Weil <sage@redhat.com>,
"David S. Miller" <davem@davemloft.net>
Cc: ceph-devel@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Subject: [PATCH] libceph: use 64-bit arithmetic instead of 32-bit
Date: Tue, 30 Jan 2018 23:29:48 -0600 [thread overview]
Message-ID: <20180131052948.GA16419@embeddedgus> (raw)
Cast objsetno to u64 in order to give the compiler complete
information about the proper arithmetic to use. Notice
that this variable is used in a context that expects an
expression of type u64 (64 bits, unsigned).
The expression objsetno * sc + stripepos is currently
being evaluated using 32-bit arithmetic.
In general, the use of incorrect arithmetic has security
implications.
Addresses-Coverity-ID: 200686
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
net/ceph/osdmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 0da27c6..58dc965 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -2183,7 +2183,7 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
stripepos = bl % sc;
objsetno = stripeno / su_per_object;
- *ono = objsetno * sc + stripepos;
+ *ono = (u64)objsetno * sc + stripepos;
dout("objset %u * sc %u = ono %u\n", objsetno, sc, (unsigned int)*ono);
/* *oxoff = *off % layout->fl_stripe_unit; # offset in su */
--
2.7.4
next reply other threads:[~2018-01-31 5:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 5:29 Gustavo A. R. Silva [this message]
2018-01-31 9:39 ` [PATCH] libceph: use 64-bit arithmetic instead of 32-bit Ilya Dryomov
2018-01-31 12:02 ` Gustavo A. R. Silva
2018-01-31 12:02 ` Gustavo A. R. Silva
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=20180131052948.GA16419@embeddedgus \
--to=gustavo@embeddedor.com \
--cc=ceph-devel@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=garsilva@embeddedor.com \
--cc=idryomov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sage@redhat.com \
--cc=zyan@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.