From: majianpeng Date: Thu, 8 Nov 2012 00:56:27 +0000 (+0800) Subject: md: Avoid write invalid address if read_seqretry returned true. X-Git-Tag: v3.2.35~24 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a97aecfa37e29252cf2946937a1ea00e4dfd21da;p=karo-tx-linux.git 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 Signed-off-by: NeilBrown Signed-off-by: Ben Hutchings --- diff --git a/drivers/md/md.c b/drivers/md/md.c index b4ce8919ae9b..145e378edbfa 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1801,10 +1801,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))