linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: majianpeng <majianpeng@gmail.com>
Cc: linux-raid <linux-raid@vger.kernel.org>,
	zhuwenfeng <zhuwenfeng@kedacom.com>
Subject: Re: [PATCH 1/2 V1] md:Avoid write invalid address if read_seqretry returned true.
Date: Mon, 19 Nov 2012 12:31:45 +1100	[thread overview]
Message-ID: <20121119123145.2d9c0fc1@notabene.brown> (raw)
In-Reply-To: <201211080856156202401@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1496 bytes --]

On Thu, 8 Nov 2012 08:56:27 +0800 majianpeng <majianpeng@gmail.com> wrote:

> Hi Neil,
> 	I updated this patch.There are two place to changed
> 1:The previous patch omit the parameter 'p'
> 2:Using p[i] instead of *p++; bbp[i] instead *bbp++.It make the code looks better.
> After rewriting ,i tested and it looked good.
> 
> 
> If read_seqretry returned true and bbp was changed, it will write
> invalid address which can cause some serious problem.
> 
> This bug was introduced by commit v3.0-rc7-130-g2699b67.
> So fix is suitable for 3.0.y thru 3.6.y.
> 
> Reported-by: zhuwenfeng@kedacom.com
> Tested-by: zhuwenfeng@kedacom.com
> Cc: stable@vger.kernel.org
> Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
> ---
>  drivers/md/md.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 9ab768a..1f86c48 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -1817,10 +1817,10 @@ retry:
>  			memset(bbp, 0xff, PAGE_SIZE);
>  
>  			for (i = 0 ; i < bb->count ; i++) {
> -				u64 internal_bb = *p++;
> +				u64 internal_bb = p[i];
>  				u64 store_bb = ((BB_OFFSET(internal_bb) << 10)
>  						| BB_LEN(internal_bb));
> -				*bbp++ = cpu_to_le64(store_bb);
> +				bbp[i] = cpu_to_le64(store_bb);
>  			}
>  			bb->changed = 0;
>  			if (read_seqretry(&bb->lock, seq))

Yes, that does look cleaner.  Thanks.

Applied in place of the previous version.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

      reply	other threads:[~2012-11-19  1:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-08  0:56 [PATCH 1/2 V1] md:Avoid write invalid address if read_seqretry returned true majianpeng
2012-11-19  1:31 ` NeilBrown [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=20121119123145.2d9c0fc1@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-raid@vger.kernel.org \
    --cc=majianpeng@gmail.com \
    --cc=zhuwenfeng@kedacom.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).