Skip to contentSkip to conversation

sh: ptrace: remove a bogus check

PATCH New Dan Carpenter 1 participant 1 message Feb 22, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh: ptrace: remove a bogus check

We made "addr" unsigned back in 2010 in commit 9b05a69e0534 ("ptrace:
change signature of arch_ptrace()"). The check for negatives was always just a basic sanity check that duplicated other stricter checks, but now it causes static checker warnings so we should remove it.

Here is the Smatch warning for reference:

arch/sh/kernel/ptrace_64.c:399 arch_ptrace()
warn: unsigned 'addr' is never less than zero.

arch/sh/kernel/ptrace_64.c +2 -2
index 1e0656d9e7af..b38d53be168a 100644
@@ -396,7 +396,7 @@ long arch_ptrace(struct task_struct *child, long request,
 		unsigned long tmp;
 
 		ret = -EIO;
-		if ((addr & 3) || addr < 0)
+		if (addr & 3)
 			break;
 
 		if (addr < sizeof(struct pt_regs))
@@ -424,7 +424,7 @@ long arch_ptrace(struct task_struct *child, long request,
                    this could crash the kernel or result in a security
                    loophole. */
 		ret = -EIO;
-		if ((addr & 3) || addr < 0)
+		if (addr & 3)
 			break;
 
 		if (addr < sizeof(struct pt_regs)) {