public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] kprobe_exceptions_notify(): fix NULL dereference
@ 2007-10-27 14:19 Adrian Bunk
  2007-10-29  5:26 ` Ananth N Mavinakayanahalli
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2007-10-27 14:19 UTC (permalink / raw)
  To: prasanna, ananth, anil.s.keshavamurthy, davem; +Cc: linux-kernel

This patch fixes later NULL dereferences spotted by the Coverity 
checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>

---

BTW: The avr32 and s390 versions of kprobe_exceptions_notify() are
     not touched since they don't contain this check.

 arch/ia64/kernel/kprobes.c    |    2 +-
 arch/powerpc/kernel/kprobes.c |    2 +-
 arch/sparc64/kernel/kprobes.c |    2 +-
 arch/x86/kernel/kprobes_32.c  |    2 +-
 arch/x86/kernel/kprobes_64.c  |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

b6f1241ee20dd22210f48b4100bc5055315f3808 
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 5fd65d8..3663dfb 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -886,11 +886,11 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
 				       unsigned long val, void *data)
 {
 	struct die_args *args = (struct die_args *)data;
 	int ret = NOTIFY_DONE;
 
-	if (args->regs && user_mode(args->regs))
+	if (args->regs || user_mode(args->regs))
 		return ret;
 
 	switch(val) {
 	case DIE_BREAK:
 		/* err is break number from ia64_bad_break() */
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 5338e48..913f9cd 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -474,11 +474,11 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
 				       unsigned long val, void *data)
 {
 	struct die_args *args = (struct die_args *)data;
 	int ret = NOTIFY_DONE;
 
-	if (args->regs && user_mode(args->regs))
+	if (args->regs || user_mode(args->regs))
 		return ret;
 
 	switch (val) {
 	case DIE_BPT:
 		if (kprobe_handler(args->regs))
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c
index d94f901..73372b2 100644
--- a/arch/sparc64/kernel/kprobes.c
+++ b/arch/sparc64/kernel/kprobes.c
@@ -391,11 +391,11 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
 				       unsigned long val, void *data)
 {
 	struct die_args *args = (struct die_args *)data;
 	int ret = NOTIFY_DONE;
 
-	if (args->regs && user_mode(args->regs))
+	if (args->regs || user_mode(args->regs))
 		return ret;
 
 	switch (val) {
 	case DIE_DEBUG:
 		if (kprobe_handler(args->regs))
diff --git a/arch/x86/kernel/kprobes_32.c b/arch/x86/kernel/kprobes_32.c
index 90f778c..fb5145e 100644
--- a/arch/x86/kernel/kprobes_32.c
+++ b/arch/x86/kernel/kprobes_32.c
@@ -658,11 +658,11 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
 				       unsigned long val, void *data)
 {
 	struct die_args *args = (struct die_args *)data;
 	int ret = NOTIFY_DONE;
 
-	if (args->regs && user_mode_vm(args->regs))
+	if (args->regs || user_mode_vm(args->regs))
 		return ret;
 
 	switch (val) {
 	case DIE_INT3:
 		if (kprobe_handler(args->regs))
diff --git a/arch/x86/kernel/kprobes_64.c b/arch/x86/kernel/kprobes_64.c
index 681b801..67b0585 100644
--- a/arch/x86/kernel/kprobes_64.c
+++ b/arch/x86/kernel/kprobes_64.c
@@ -649,11 +649,11 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
 				       unsigned long val, void *data)
 {
 	struct die_args *args = (struct die_args *)data;
 	int ret = NOTIFY_DONE;
 
-	if (args->regs && user_mode(args->regs))
+	if (args->regs || user_mode(args->regs))
 		return ret;
 
 	switch (val) {
 	case DIE_INT3:
 		if (kprobe_handler(args->regs))



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

* Re: [2.6 patch] kprobe_exceptions_notify(): fix NULL dereference
  2007-10-27 14:19 [2.6 patch] kprobe_exceptions_notify(): fix NULL dereference Adrian Bunk
@ 2007-10-29  5:26 ` Ananth N Mavinakayanahalli
  0 siblings, 0 replies; 2+ messages in thread
From: Ananth N Mavinakayanahalli @ 2007-10-29  5:26 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: prasanna, anil.s.keshavamurthy, davem, linux-kernel

On Sat, Oct 27, 2007 at 04:19:14PM +0200, Adrian Bunk wrote:
> This patch fixes later NULL dereferences spotted by the Coverity 
> checker.
> 
> Signed-off-by: Adrian Bunk <bunk@kernel.org>

NACK... see below

> ---
> 
> BTW: The avr32 and s390 versions of kprobe_exceptions_notify() are
>      not touched since they don't contain this check.
> 
>  arch/ia64/kernel/kprobes.c    |    2 +-
>  arch/powerpc/kernel/kprobes.c |    2 +-
>  arch/sparc64/kernel/kprobes.c |    2 +-
>  arch/x86/kernel/kprobes_32.c  |    2 +-
>  arch/x86/kernel/kprobes_64.c  |    2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
> 
> b6f1241ee20dd22210f48b4100bc5055315f3808 
> diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
> index 5fd65d8..3663dfb 100644
> --- a/arch/ia64/kernel/kprobes.c
> +++ b/arch/ia64/kernel/kprobes.c
> @@ -886,11 +886,11 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
>  				       unsigned long val, void *data)
>  {
>  	struct die_args *args = (struct die_args *)data;
>  	int ret = NOTIFY_DONE;
> 
> -	if (args->regs && user_mode(args->regs))
> +	if (args->regs || user_mode(args->regs))

This change is incorrect as you return if args->regs != NULL leading to
a sure system crash.

Ananth

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

end of thread, other threads:[~2007-10-29  5:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-27 14:19 [2.6 patch] kprobe_exceptions_notify(): fix NULL dereference Adrian Bunk
2007-10-29  5:26 ` Ananth N Mavinakayanahalli

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