x86/ras: Two more for 4.9
Borislav Petkov
maintainercover x86/ras: Two more for 4.9
From: Borislav Petkov <[email protected]>
Hi guys,
here are two more for tip:ras/core fixing/cleaning up stuff in the error injector. Please queue for 4.9.
Thanks.
Borislav Petkov (1):
x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit
Colin Ian King (1):
x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index i
arch/x86/ras/mce_amd_inj.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
Signature · 1 line
2.10.0
Borislav Petkov
maintainerPATCH 1/2 x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index i
From: Colin Ian King <[email protected]>
Change predecrement compare to post decrement compare to avoid an unsigned integer wrap-around comparisomn when decrementing in the while loop.
For example, if the debugfs_create_file() fails when i is zero, the current situation will predecrement i in the while loop, wrapping i to the maximum signed integer and cause multiple out of bounds reads on dfs_fls[i].d as the loop interates to zero.
Also, as Borislav Petkov suggested, return -ENODEV rather than -ENOMEM on the error condition.
--- arch/x86/ras/mce_amd_inj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/ras/mce_amd_inj.c +2 -2
@@ -464,13 +464,13 @@ static int __init init_mce_inject(void)return 0 ; err_dfs_add: -while (--i >=0 ) +while (i-- >0 )debugfs_remove (dfs_fls[i].d);debugfs_remove (dfs_inj); dfs_inj =NULL ; -return -ENOMEM ; +return -ENODEV ; } static void __exit exit_mce_inject(void)
Signature · 1 line
2.10.0
tip-bot for Colin Ian King
merge bot[tip:ras/core] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index 'i'
x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index 'i'
Commit-ID: 8b44f00f8c952ab6eb658090383571b2ec7d253f Gitweb: http://git.kernel.org/tip/8b44f00f8c952ab6eb658090383571b2ec7d253f Author: Colin Ian King <[email protected]> AuthorDate: Mon, 26 Sep 2016 10:31:51 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 26 Sep 2016 11:13:17 +0200
x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index 'i'
Change predecrement compare to post decrement compare to avoid an unsigned integer wrap-around comparisomn when decrementing in the while loop.
For example, if the debugfs_create_file() fails when 'i' is zero, the current situation will predecrement 'i' in the while loop, wrapping 'i' to the maximum signed integer and cause multiple out of bounds reads on dfs_fls[i].d as the loop interates to zero.
Also, as Borislav Petkov suggested, return -ENODEV rather than -ENOMEM on the error condition.
--- arch/x86/ras/mce_amd_inj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/ras/mce_amd_inj.c +2 -2
@@ -464,13 +464,13 @@ static int __init init_mce_inject(void)return 0 ; err_dfs_add: -while (--i >=0 ) +while (i-- >0 )debugfs_remove (dfs_fls[i].d);debugfs_remove (dfs_inj); dfs_inj =NULL ; -return -ENOMEM ; +return -ENODEV ; } static void __exit exit_mce_inject(void)
Borislav Petkov
maintainerPATCH 2/2 x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Simplify exit_mce_inject() by using debugfs_remove_recursive() and do away with the noodling over the dentry elements.
--- arch/x86/ras/mce_amd_inj.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/ras/mce_amd_inj.c +2 -6
@@ -475,15 +475,11 @@ err_dfs_add: static void __exit exit_mce_inject(void) { -int i; -for (i =0 ; i <ARRAY_SIZE (dfs_fls); i++) -debugfs_remove (dfs_fls[i].d); +debugfs_remove_recursive (dfs_inj); + dfs_inj =NULL ;memset (&dfs_fls,0 ,sizeof (dfs_fls)); - -debugfs_remove (dfs_inj); - dfs_inj =NULL ; }module_init (init_mce_inject);module_exit (exit_mce_inject);
Signature · 1 line
2.10.0
tip-bot for Borislav Petkov
merge bot[tip:ras/core] x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit
x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit
Commit-ID: b199ac6c4943aa0db246163bf6b483e2bb53431b Gitweb: http://git.kernel.org/tip/b199ac6c4943aa0db246163bf6b483e2bb53431b Author: Borislav Petkov <[email protected]> AuthorDate: Mon, 26 Sep 2016 10:31:52 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 26 Sep 2016 11:13:17 +0200
x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit
Simplify exit_mce_inject() by using debugfs_remove_recursive() and do away with the noodling over the dentry elements.
--- arch/x86/ras/mce_amd_inj.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/ras/mce_amd_inj.c +2 -6
@@ -475,15 +475,11 @@ err_dfs_add: static void __exit exit_mce_inject(void) { -int i; -for (i =0 ; i <ARRAY_SIZE (dfs_fls); i++) -debugfs_remove (dfs_fls[i].d); +debugfs_remove_recursive (dfs_inj); + dfs_inj =NULL ;memset (&dfs_fls,0 ,sizeof (dfs_fls)); - -debugfs_remove (dfs_inj); - dfs_inj =NULL ; }module_init (init_mce_inject);module_exit (exit_mce_inject);