Re: [PATCH] edac: fix buffer overrun if no suitable bandwidth found

From: Borislav Petkov
Date: Tue Oct 23 2012 - 16:26:10 EST


On Tue, Oct 23, 2012 at 12:10:05PM -0700, Andrew Morton wrote:
> That's pretty strange code in there.
>
> If the comment is to be believed, isn't this a suitable fix?
>
> --- a/drivers/edac/amd64_edac.c~a
> +++ a/drivers/edac/amd64_edac.c
> @@ -171,7 +171,7 @@ static int __amd64_set_scrub_rate(struct
> * bandwidth entry that is greater or equal than the setting requested
> * and program that. If at last entry, turn off DRAM scrubbing.
> */
> - for (i = 0; i < ARRAY_SIZE(scrubrates); i++) {
> + for (i = 0; i < ARRAY_SIZE(scrubrates) - 1; i++) {
> /*
> * skip scrub rates which aren't recommended
> * (see F10 BKDG, F3x58)
> _
>
> Also, I don't think "buffer overrun" is an appropriate description here
> - to me, "buffer overrun" implies writing to memory outside the buffer.
> I'd call this "array overindexing" or similar.
>
> Finally, when fixing a bug, please always describe the user-visible
> impact of that bug. You have cc'ed stable on this patch (using the
> incorrect email address, btw) which implies that the effects are serious,
> but people will want to know specific details about those effects when
> considering the patch.

Right, I took it for correctness' sake but after a heavy massaging. And
this is only a hypothetical case since we're always falling back to the
last element of scrubrates array which turns off scrubbing, based on the
supplied bandwidth. Thus no need for stable, IMO.

Let me know if this is what you had in mind.

[ And yes, maybe I should rewrite this to de-awkwardize it :) ]

--