lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20121023133709.21e9cb72.akpm@linux-foundation.org>
Date:	Tue, 23 Oct 2012 13:37:09 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Borislav Petkov <bp@...64.org>
Cc:	Denis Kirjanov <kirjanov@...il.com>, linux-edac@...r.kernel.org,
	linux-kernel@...r.kernel.org, stable@...r.kernel.org,
	Doug Thompson <dougthompson@...ssion.com>,
	Borislav Petkov <borislav.petkov@....com>
Subject: Re: [PATCH] edac: fix buffer overrun if no suitable bandwidth found

On Tue, 23 Oct 2012 22:26:12 +0200
Borislav Petkov <bp@...64.org> wrote:

> From: Denis Kirjanov <kirjanov@...il.com>
> Date: Mon, 22 Oct 2012 19:30:58 +0400
> Subject: [PATCH] amd64_edac: Fix hypothetical out-of-bounds access
> 
> Make sure we stay within scrubrates' array bounds.
> 
> Boris: this is a correctness fix only because the loop terminates
> earlier due to us capping scrubbing bandwidth to 0.
> 
> Signed-off-by: Denis Kirjanov <kirjanov@...il.com>
> Signed-off-by: Borislav Petkov <borislav.petkov@....com>
> ---
>  drivers/edac/amd64_edac.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index 501bfb938f26..73d9108d6200 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -181,14 +181,16 @@ static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
>  
>  		if (scrubrates[i].bandwidth <= new_bw)
>  			break;
> -
> -		/*
> -		 * if no suitable bandwidth found, turn off DRAM scrubbing
> -		 * entirely by falling back to the last element in the
> -		 * scrubrates array.
> -		 */
>  	}
>  
> +	/*
> +	 * if no suitable bandwidth found, turn off DRAM scrubbing
> +	 * entirely by falling back to the last element in the scrubrates
> +	 * array.
> +	 */
> +	if (i == ARRAY_SIZE(scrubrates))
> +		i--;
> +
>  	scrubval = scrubrates[i].scrubval;
>  
>  	pci_write_bits32(ctl, SCRCTRL, scrubval, 0x001F);

This is still strange.  What's the point in having the initial loop
even consider the last element in the array if we know we'll be using
it anyway?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ