All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: sage@inktank.com
Cc: ceph-devel@vger.kernel.org
Subject: re: ceph: fix fallocate division
Date: Thu, 23 Oct 2014 14:35:49 +0300	[thread overview]
Message-ID: <20141023113549.GA13250@mwanda> (raw)

Hello Sage Weil,

The patch b314a90d8f3f: "ceph: fix fallocate division" from Aug 27,
2013, leads to the following static checker warning:

	fs/ceph/file.c:1145 ceph_zero_objects()
	warn: [initializer] should 'object_size * stripe_count' be a 64 bit type?

fs/ceph/file.c
  1138  static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length)
  1139  {
  1140          int ret = 0;
  1141          struct ceph_inode_info *ci = ceph_inode(inode);
  1142          s32 stripe_unit = ceph_file_layout_su(ci->i_layout);
  1143          s32 stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
  1144          s32 object_size = ceph_file_layout_object_size(ci->i_layout);
  1145          u64 object_set_size = object_size * stripe_count;
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
This is a new Smatch check I'm working on.  Obviously integer overflows
are a fairly common bug.  We often see code like this:

	a = b * c;

It's too much to warn every time when the types don't make sense because
a lot of times people use u64 by reflexive and don't actually care about
the upper bits.  My new check only warns if the overflow happens inside
an initializer.

This one is puzzling to me because prior to b314a90d8f3f then there was
a cast that fixed the integer overflow problem.  It's not clear if
removing it was intentional or accidental.

  1146          u64 nearly, t;
  1147  
  1148          /* round offset up to next period boundary */
  1149          nearly = offset + object_set_size - 1;
  1150          t = nearly;
  1151          nearly -= do_div(t, object_set_size);
  1152  

regards,
dan carpenter

                 reply	other threads:[~2014-10-23 11:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20141023113549.GA13250@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=sage@inktank.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.