x86, AMD, NB: silence an underflow test
Subsystems (2)
PATCH 1/1 x86, AMD, NB: silence an underflow test
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.
arch/x86/include/asm/amd_nb.h +1 -1
@@ -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;
arch/x86/kernel/amd_nb.c +1 -1
@@ -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));
Quoted 1 line · Dan Carpenter
This is under
CAP_SYS_ADMINbut 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..."
:-) :-) :-)
Quoted 4 lines
the user and the test for "mask >
0xf" can underflow. The fix is simple.Signed-off-by Dan Carpenter <[email protected]>
In any case:
Thanks!
Quoted 27 lines
arch/x86/include/asm/amd_nb.h +1
-1@@ -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;arch/x86/kernel/amd_nb.c +1
-1@@ -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));
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--tip-bot for Dan Carpenter
merge bot[tip:x86/urgent] x86/AMD/NB: Fix amd_set_subcaches() parameter type
In reply to Dan Carpenterx86/AMD/NB: Fix amd_set_subcaches() parameter type
Commit-ID: 2993ae3305ad10b41e0d0bc2662f7754ee8e30fa Gitweb: http://git.kernel.org/tip/2993ae3305ad10b41e0d0bc2662f7754ee8e30fa Author: Dan Carpenter <[email protected]> AuthorDate: Tue, 21 Jan 2014 10:22:09 +0300 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/include/asm/amd_nb.h | 2 +- arch/x86/kernel/amd_nb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/amd_nb.h +1 -1
@@ -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;
arch/x86/kernel/amd_nb.c +1 -1
@@ -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));