Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-18 Thread Cong Wang
On Wed, Apr 17, 2019 at 2:15 PM Luck, Tony wrote: > > On Tue, Apr 16, 2019 at 07:37:41PM -0700, Cong Wang wrote: > > On Tue, Apr 16, 2019 at 7:31 PM Cong Wang wrote: > > > Yes it is, I have a stacktrace in production which clearly shows > > > del_elem.isra.1+0x34/0x40, unlike the one I triggered

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-17 Thread Luck, Tony
On Tue, Apr 16, 2019 at 07:37:41PM -0700, Cong Wang wrote: > On Tue, Apr 16, 2019 at 7:31 PM Cong Wang wrote: > > Yes it is, I have a stacktrace in production which clearly shows > > del_elem.isra.1+0x34/0x40, unlike the one I triggered via fake > > PFN's. I can show you if you want, it is on 4.14

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Cong Wang
On Tue, Apr 16, 2019 at 7:31 PM Cong Wang wrote: > Yes it is, I have a stacktrace in production which clearly shows > del_elem.isra.1+0x34/0x40, unlike the one I triggered via fake > PFN's. I can show you if you want, it is on 4.14, so very unlikely > it is interesting to anyone here. Correct mys

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Cong Wang
On Tue, Apr 16, 2019 at 6:53 PM Luck, Tony wrote: > > On Tue, Apr 16, 2019 at 04:47:55PM -0700, Cong Wang wrote: > > 229 static void del_elem(struct ce_array *ca, int idx) > > 230 { > > 231 /* Save us a function call when deleting the last element. */ > > 232 if (ca->n - (idx + 1))

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Luck, Tony
On Tue, Apr 16, 2019 at 04:47:55PM -0700, Cong Wang wrote: > 229 static void del_elem(struct ce_array *ca, int idx) > 230 { > 231 /* Save us a function call when deleting the last element. */ > 232 if (ca->n - (idx + 1)) > 233 memmove((void *)&ca->array[idx], > 234

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Cong Wang
On Tue, Apr 16, 2019 at 4:28 PM Luck, Tony wrote: > > On Tue, Apr 16, 2019 at 04:18:57PM -0700, Cong Wang wrote: > > > The problem case occurs when we've seen enough distinct > > > errors that we have filled every entry, then we try to > > > look up a pfn that is larger that any seen before. > > >

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Luck, Tony
On Tue, Apr 16, 2019 at 04:18:57PM -0700, Cong Wang wrote: > > The problem case occurs when we've seen enough distinct > > errors that we have filled every entry, then we try to > > look up a pfn that is larger that any seen before. > > > > The loop: > > > > while (min < max) { > >

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Cong Wang
On Tue, Apr 16, 2019 at 3:18 PM Luck, Tony wrote: > > On Tue, Apr 16, 2019 at 11:07:26AM +0200, Borislav Petkov wrote: > > On Mon, Apr 15, 2019 at 06:20:00PM -0700, Cong Wang wrote: > > > ce_arr.array[] is always within the range [0, ce_arr.n-1]. > > > However, the binary search code in __find_ele

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Luck, Tony
On Tue, Apr 16, 2019 at 11:07:26AM +0200, Borislav Petkov wrote: > On Mon, Apr 15, 2019 at 06:20:00PM -0700, Cong Wang wrote: > > 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

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Cong Wang
On Tue, Apr 16, 2019 at 2:07 AM Borislav Petkov wrote: > > On Mon, Apr 15, 2019 at 06:20:00PM -0700, Cong Wang wrote: > > 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 o

Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-16 Thread Borislav Petkov
On Mon, Apr 15, 2019 at 06:20:00PM -0700, Cong Wang wrote: > 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

[PATCH 1/2] ras: fix an off-by-one error in __find_elem()

2019-04-15 Thread Cong Wang
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 calle