All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ras: fix an off-by-one error in __find_elem()
@ 2019-04-16  1:20 ` Cong Wang
  0 siblings, 0 replies; 36+ messages in thread
From: Cong Wang @ 2019-04-16  1:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-edac, Cong Wang, Tony Luck, Borislav Petkov, Thomas Gleixner

ce_arr.array[] is always within the range [0, ce_arr.n-1].
However, the binary search code in __find_elem() uses ce_arr.n
as the maximum index, which could lead to an off-by-one
out-of-bound access when the element after the last is exactly
the one just got deleted, that is, 'min' returned to caller as
'ce_arr.n'.

Fixes: 011d82611172 ("RAS: Add a Corrected Errors Collector")
Cc: Tony Luck <tony.luck@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 drivers/ras/cec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 2d9ec378a8bc..61332c9aab5a 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -184,7 +184,7 @@ static void cec_timer_fn(struct timer_list *unused)
 static int __find_elem(struct ce_array *ca, u64 pfn, unsigned int *to)
 {
 	u64 this_pfn;
-	int min = 0, max = ca->n;
+	int min = 0, max = ca->n - 1;
 
 	while (min < max) {
 		int tmp = (max + min) >> 1;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2019-04-18 22:54 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16  1:20 [PATCH 1/2] ras: fix an off-by-one error in __find_elem() Cong Wang
2019-04-16  1:20 ` [1/2] " Cong Wang
2019-04-16  1:20 ` [PATCH 2/2] ras: close the race condition with timer Cong Wang
2019-04-16  1:20   ` [2/2] " Cong Wang
2019-04-16  9:58   ` [PATCH 2/2] " Borislav Petkov
2019-04-16  9:58     ` [2/2] " Borislav Petkov
2019-04-16 17:09     ` [PATCH 2/2] " Cong Wang
2019-04-16 17:09       ` [2/2] " Cong Wang
2019-04-16 17:42       ` [PATCH 2/2] " Borislav Petkov
2019-04-16 17:42         ` [2/2] " Borislav Petkov
2019-04-16 18:00         ` [PATCH 2/2] " Cong Wang
2019-04-16 18:00           ` [2/2] " Cong Wang
2019-04-16 18:06           ` [PATCH 2/2] " Cong Wang
2019-04-16 18:06             ` [2/2] " Cong Wang
2019-04-16  9:07 ` [PATCH 1/2] ras: fix an off-by-one error in __find_elem() Borislav Petkov
2019-04-16  9:07   ` [1/2] " Borislav Petkov
2019-04-16 17:01   ` [PATCH 1/2] " Cong Wang
2019-04-16 17:01     ` [1/2] " Cong Wang
2019-04-16 22:18   ` [PATCH 1/2] " Luck, Tony
2019-04-16 22:18     ` [1/2] " Luck, Tony
2019-04-16 23:18     ` [PATCH 1/2] " Cong Wang
2019-04-16 23:18       ` [1/2] " Cong Wang
2019-04-16 23:28       ` [PATCH 1/2] " Luck, Tony
2019-04-16 23:28         ` [1/2] " Luck, Tony
2019-04-16 23:47         ` [PATCH 1/2] " Cong Wang
2019-04-16 23:47           ` [1/2] " Cong Wang
2019-04-17  1:53           ` [PATCH 1/2] " Luck, Tony
2019-04-17  1:53             ` [1/2] " Luck, Tony
2019-04-17  2:31             ` [PATCH 1/2] " Cong Wang
2019-04-17  2:31               ` [1/2] " Cong Wang
2019-04-17  2:37               ` [PATCH 1/2] " Cong Wang
2019-04-17  2:37                 ` [1/2] " Cong Wang
2019-04-17 21:15                 ` [PATCH 1/2] " Luck, Tony
2019-04-17 21:15                   ` [1/2] " Luck, Tony
2019-04-18 22:54                   ` [PATCH 1/2] " Cong Wang
2019-04-18 22:54                     ` [1/2] " Cong Wang

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.