mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] x86, AMD, NB: silence an underflow test
@ 2014-01-21  7:22 Dan Carpenter
  2014-01-21 10:02 ` Borislav Petkov
  2014-01-25 14:23 ` [tip:x86/urgent] x86/AMD/NB: Fix amd_set_subcaches() parameter type tip-bot for Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2014-01-21  7:22 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, H. Peter Anvin, x86, Borislav Petkov,
	Daniel J Blueman, linux-kernel, kernel-janitors

This is under CAP_SYS_ADMIN but Smatch complains that mask comes from
the user and the test for "mask > 0xf" can underflow.  The fix is
simple.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

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));

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

* Re: [patch] x86, AMD, NB: silence an underflow test
  2014-01-21  7:22 [patch] x86, AMD, NB: silence an underflow test Dan Carpenter
@ 2014-01-21 10:02 ` Borislav Petkov
  2014-01-25 14:23 ` [tip:x86/urgent] x86/AMD/NB: Fix amd_set_subcaches() parameter type tip-bot for Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2014-01-21 10:02 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Daniel J Blueman, linux-kernel, kernel-janitors

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.
--

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

* [tip:x86/urgent] x86/AMD/NB: Fix amd_set_subcaches() parameter type
  2014-01-21  7:22 [patch] x86, AMD, NB: silence an underflow test Dan Carpenter
  2014-01-21 10:02 ` Borislav Petkov
@ 2014-01-25 14:23 ` tip-bot for Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Dan Carpenter @ 2014-01-25 14:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, bp, tglx, bp, dan.carpenter, daniel

Commit-ID:  2993ae3305ad10b41e0d0bc2662f7754ee8e30fa
Gitweb:     http://git.kernel.org/tip/2993ae3305ad10b41e0d0bc2662f7754ee8e30fa
Author:     Dan Carpenter <dan.carpenter@oracle.com>
AuthorDate: Tue, 21 Jan 2014 10:22:09 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 25 Jan 2014 08:50:09 +0100

x86/AMD/NB: Fix amd_set_subcaches() parameter type

This is under CAP_SYS_ADMIN, but Smatch complains that mask comes
from the user and the test for "mask > 0xf" can underflow.

The fix is simple: amd_set_subcaches() should hand down not an 'int'
but an 'unsigned long' like it was originally indended to do.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Daniel J Blueman <daniel@numascale-asia.com>
Link: http://lkml.kernel.org/r/20140121072209.GA22095@elgon.mountain
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/amd_nb.h | 2 +-
 arch/x86/kernel/amd_nb.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h
index a54ee1d..aaac3b2 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 59554dc..dec8de4 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));

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

end of thread, other threads:[~2014-01-25 14:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-21  7:22 [patch] x86, AMD, NB: silence an underflow test Dan Carpenter
2014-01-21 10:02 ` Borislav Petkov
2014-01-25 14:23 ` [tip:x86/urgent] x86/AMD/NB: Fix amd_set_subcaches() parameter type tip-bot for Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome