summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormajianpeng <majianpeng@gmail.com>2012-11-08 08:56:27 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-12-03 11:37:59 -0800
commitfd7cb90238cf1ca0cb9b40364892607331be4acd (patch)
tree779ddc479e7d5dc7d3738faea3c1b984e65757a7
parentea95b5107c1cdc7774e986d1db421b4b22e979f9 (diff)
md: Avoid write invalid address if read_seqretry returned true.
commit 35f9ac2dcec8f79d7059ce174fd7b7ee3290d620 upstream. 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 Signed-off-by: Jianpeng Ma <majianpeng@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/md/md.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 83ad2f8d1631..c7b000fd8d35 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1832,10 +1832,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))