From: Mike Snitzer <snitzer@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Heinz Mauelshagen <heinzm@redhat.com>,
kernel-janitors@vger.kernel.org, linux-raid@vger.kernel.org,
dm-devel@redhat.com, Alasdair Kergon <agk@redhat.com>
Subject: Re: dm raid: pointer math issue in super_sync()
Date: Tue, 21 Oct 2014 09:25:19 -0400 [thread overview]
Message-ID: <20141021132519.GD20625@redhat.com> (raw)
In-Reply-To: <20141021125729.GC26918@mwanda>
On Tue, Oct 21 2014 at 8:57am -0400,
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Oct 21, 2014 at 08:48:26AM -0400, Mike Snitzer wrote:
> > > - memset(sb + sizeof(*sb), 0, rdev->sb_size - sizeof(*sb));
> > > + memset(sb + 1, 0, rdev->sb_size - sizeof(*sb));
> > >
> > > sb->magic = cpu_to_le32(DM_RAID_MAGIC);
> > > sb->features = cpu_to_le32(0); /* No features yet */
> >
> > Not following... sizeof(*sb) != sizeof(sb). So I'm not seeing a
> > problem.
> >
> > Nor am I seeing how you think sb + 1 is equivalent to what Heinz
> > intended (zero the memory following the sizeof(struct dm_raid_superblock)).
>
> It's pointer math.
Yes, I see that now..
> sizeof(*sb) is 512.
>
> "sb + sizeof(*sb)" is the same as (void *)sb + 512 * 512.
> "sb + 1" is the same as (void *)sb + 512.
Actually, Heinz removed the 452 bytes of padding from struct
dm_raid_superblock, so it is more like:
sizeof(*sb) == sizeof(struct dm_raid_super_block) == 60
"sb + sizeof(*sb)" is the same as (void *)sb + 60 * 60
"sb + 1" is the same as (void *)sb + 60.
But regardless, your broader point on the math stands. I'll get this
fixed up, thanks!
Mike
WARNING: multiple messages have this Message-ID (diff)
From: Mike Snitzer <snitzer@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Heinz Mauelshagen <heinzm@redhat.com>,
kernel-janitors@vger.kernel.org, linux-raid@vger.kernel.org,
dm-devel@redhat.com, Alasdair Kergon <agk@redhat.com>
Subject: Re: dm raid: pointer math issue in super_sync()
Date: Tue, 21 Oct 2014 13:25:19 +0000 [thread overview]
Message-ID: <20141021132519.GD20625@redhat.com> (raw)
In-Reply-To: <20141021125729.GC26918@mwanda>
On Tue, Oct 21 2014 at 8:57am -0400,
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Oct 21, 2014 at 08:48:26AM -0400, Mike Snitzer wrote:
> > > - memset(sb + sizeof(*sb), 0, rdev->sb_size - sizeof(*sb));
> > > + memset(sb + 1, 0, rdev->sb_size - sizeof(*sb));
> > >
> > > sb->magic = cpu_to_le32(DM_RAID_MAGIC);
> > > sb->features = cpu_to_le32(0); /* No features yet */
> >
> > Not following... sizeof(*sb) != sizeof(sb). So I'm not seeing a
> > problem.
> >
> > Nor am I seeing how you think sb + 1 is equivalent to what Heinz
> > intended (zero the memory following the sizeof(struct dm_raid_superblock)).
>
> It's pointer math.
Yes, I see that now..
> sizeof(*sb) is 512.
>
> "sb + sizeof(*sb)" is the same as (void *)sb + 512 * 512.
> "sb + 1" is the same as (void *)sb + 512.
Actually, Heinz removed the 452 bytes of padding from struct
dm_raid_superblock, so it is more like:
sizeof(*sb) = sizeof(struct dm_raid_super_block) = 60
"sb + sizeof(*sb)" is the same as (void *)sb + 60 * 60
"sb + 1" is the same as (void *)sb + 60.
But regardless, your broader point on the math stands. I'll get this
fixed up, thanks!
Mike
next prev parent reply other threads:[~2014-10-21 13:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 12:43 [patch] dm raid: pointer math issue in super_sync() Dan Carpenter
2014-10-21 12:43 ` Dan Carpenter
2014-10-21 12:48 ` Mike Snitzer
2014-10-21 12:48 ` Mike Snitzer
2014-10-21 12:57 ` Dan Carpenter
2014-10-21 12:57 ` Dan Carpenter
2014-10-21 13:25 ` Mike Snitzer [this message]
2014-10-21 13:25 ` Mike Snitzer
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=20141021132519.GD20625@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=dm-devel@redhat.com \
--cc=heinzm@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
/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.