lkml.org 
[lkml]   [2014]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] x86, AMD, NB: silence an underflow test
On Tue, Jan 21, 2014 at 10:22:09AM +0300, Dan Carpenter wrote:
> This is under CAP_SYS_ADMIN but Smatch complains that mask comes from

"Smatch complains..." - you sound just like a politician - something
inanimate and abstract complains that something's wrong - I'm not to
blame, I'm innocent!

Not "amd_set_subcaches should hand down an unsigned long like it was
originally indended but then bugged into an int..."

:-) :-) :-)

> the user and the test for "mask > 0xf" can underflow. The fix is
> simple.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

In any case:

Acked-by: Borislav Petkov <bp@suse.de>

Thanks!

> diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h
> index a54ee1d054d9..0c4e3e47d462 100644
> --- a/arch/x86/include/asm/amd_nb.h
> +++ b/arch/x86/include/asm/amd_nb.h
> @@ -19,7 +19,7 @@ extern int amd_cache_northbridges(void);
> extern void amd_flush_garts(void);
> extern int amd_numa_init(void);
> extern int amd_get_subcaches(int);
> -extern int amd_set_subcaches(int, int);
> +extern int amd_set_subcaches(int, unsigned long);
>
> struct amd_l3_cache {
> unsigned indices;
> diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
> index 59554dca96ec..d9fceb697322 100644
> --- a/arch/x86/kernel/amd_nb.c
> +++ b/arch/x86/kernel/amd_nb.c
> @@ -179,7 +179,7 @@ int amd_get_subcaches(int cpu)
> return (mask >> (4 * cuid)) & 0xf;
> }
>
> -int amd_set_subcaches(int cpu, int mask)
> +int amd_set_subcaches(int cpu, unsigned long mask)
> {
> static unsigned int reset, ban;
> struct amd_northbridge *nb = node_to_amd_nb(amd_get_nb_id(cpu));
>

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--


\
 
 \ /
  Last update: 2014-01-21 13:01    [W:0.049 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site