All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/ras: Two more for 4.9
@ 2016-09-26  8:31 Borislav Petkov
  2016-09-26  8:31 ` [PATCH 1/2] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index i Borislav Petkov
  2016-09-26  8:31 ` [PATCH 2/2] x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit Borislav Petkov
  0 siblings, 2 replies; 5+ messages in thread
From: Borislav Petkov @ 2016-09-26  8:31 UTC (permalink / raw)
  To: X86 ML; +Cc: LKML

From: Borislav Petkov <bp@suse.de>

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

-- 
2.10.0

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

* [PATCH 1/2] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index i
  2016-09-26  8:31 [PATCH 0/2] x86/ras: Two more for 4.9 Borislav Petkov
@ 2016-09-26  8:31 ` Borislav Petkov
  2016-09-26 16:31   ` [tip:ras/core] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index 'i' tip-bot for Colin Ian King
  2016-09-26  8:31 ` [PATCH 2/2] x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit Borislav Petkov
  1 sibling, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2016-09-26  8:31 UTC (permalink / raw)
  To: X86 ML; +Cc: LKML

From: Colin Ian King <colin.king@canonical.com>

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.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: Yazen Ghannam <Yazen.Ghannam@amd.com>
Cc: x86-ml <x86@kernel.org>
Link: http://lkml.kernel.org/r/20160917101750.6436-1-colin.king@canonical.com
Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/ras/mce_amd_inj.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/ras/mce_amd_inj.c b/arch/x86/ras/mce_amd_inj.c
index cd318d93099e..20b227f63407 100644
--- a/arch/x86/ras/mce_amd_inj.c
+++ b/arch/x86/ras/mce_amd_inj.c
@@ -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)
-- 
2.10.0

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

* [PATCH 2/2] x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit
  2016-09-26  8:31 [PATCH 0/2] x86/ras: Two more for 4.9 Borislav Petkov
  2016-09-26  8:31 ` [PATCH 1/2] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index i Borislav Petkov
@ 2016-09-26  8:31 ` Borislav Petkov
  2016-09-26 16:32   ` [tip:ras/core] " tip-bot for Borislav Petkov
  1 sibling, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2016-09-26  8:31 UTC (permalink / raw)
  To: X86 ML; +Cc: LKML

From: Borislav Petkov <bp@suse.de>

Simplify exit_mce_inject() by using debugfs_remove_recursive() and do
away with the noodling over the dentry elements.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/ras/mce_amd_inj.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/ras/mce_amd_inj.c b/arch/x86/ras/mce_amd_inj.c
index 20b227f63407..1ac76479c266 100644
--- a/arch/x86/ras/mce_amd_inj.c
+++ b/arch/x86/ras/mce_amd_inj.c
@@ -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);
-- 
2.10.0

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

* [tip:ras/core] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index 'i'
  2016-09-26  8:31 ` [PATCH 1/2] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index i Borislav Petkov
@ 2016-09-26 16:31   ` tip-bot for Colin Ian King
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Colin Ian King @ 2016-09-26 16:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Yazen.Ghannam, bp, torvalds, hpa, colin.king, peterz,
	linux-kernel, tglx, mingo

Commit-ID:  8b44f00f8c952ab6eb658090383571b2ec7d253f
Gitweb:     http://git.kernel.org/tip/8b44f00f8c952ab6eb658090383571b2ec7d253f
Author:     Colin Ian King <colin.king@canonical.com>
AuthorDate: Mon, 26 Sep 2016 10:31:51 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yazen Ghannam <Yazen.Ghannam@amd.com>
Link: http://lkml.kernel.org/r/20160926083152.30848-2-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/ras/mce_amd_inj.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/ras/mce_amd_inj.c b/arch/x86/ras/mce_amd_inj.c
index cd318d9..20b227f 100644
--- a/arch/x86/ras/mce_amd_inj.c
+++ b/arch/x86/ras/mce_amd_inj.c
@@ -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)

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

* [tip:ras/core] x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit
  2016-09-26  8:31 ` [PATCH 2/2] x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit Borislav Petkov
@ 2016-09-26 16:32   ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Borislav Petkov @ 2016-09-26 16:32 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: mingo, linux-kernel, torvalds, bp, hpa, tglx, peterz

Commit-ID:  b199ac6c4943aa0db246163bf6b483e2bb53431b
Gitweb:     http://git.kernel.org/tip/b199ac6c4943aa0db246163bf6b483e2bb53431b
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Mon, 26 Sep 2016 10:31:52 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160926083152.30848-3-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/ras/mce_amd_inj.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/ras/mce_amd_inj.c b/arch/x86/ras/mce_amd_inj.c
index 20b227f..1ac7647 100644
--- a/arch/x86/ras/mce_amd_inj.c
+++ b/arch/x86/ras/mce_amd_inj.c
@@ -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);

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

end of thread, other threads:[~2016-09-26 16:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-26  8:31 [PATCH 0/2] x86/ras: Two more for 4.9 Borislav Petkov
2016-09-26  8:31 ` [PATCH 1/2] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index i Borislav Petkov
2016-09-26 16:31   ` [tip:ras/core] x86/RAS/mce_amd_inj: Fix signed wrap around when decrementing index 'i' tip-bot for Colin Ian King
2016-09-26  8:31 ` [PATCH 2/2] x86/RAS/mce_amd_inj: Remove debugfs dir recursively on exit Borislav Petkov
2016-09-26 16:32   ` [tip:ras/core] " tip-bot for Borislav Petkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.