Skip to contentSkip to conversation

c/r: prctl: Return -EFAULT instead of -EINVAL in case if underlied VMA is not found

PATCH In review Cyrill Gorcunov 5 participants 5 messages Apr 24, 2012 – Apr 25, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 c/r: prctl: Return -EFAULT instead of -EINVAL in case if underlied VMA is not found

In case if underlied VMA is not found prctl_set_mm will return -EINVAL, but Michael proposed to return -EFAULT and Kosaki seconded. Make it so.

Cc KOSAKI Motohiro <[email protected]>
Cc Pavel Emelyanov <[email protected]>,
Cc Tejun Heo <[email protected]>
Cc Kees Cook <[email protected]>
Cc Serge Hallyn <[email protected]>
Cc KAMEZAWA Hiroyuki <[email protected]>
Cc Andrew Morton <[email protected]>
---
 kernel/sys.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/sys.c +3 -1
Index: linux-2.6.git/kernel/sys.c
===================================================================
@@ -1838,8 +1838,10 @@ static int prctl_set_mm(int opt, unsigne
 	case PR_SET_MM_ARG_END:
 	case PR_SET_MM_ENV_START:
 	case PR_SET_MM_ENV_END:
-		if (!vma)
+		if (!vma) {
+			error = -EFAULT;
 			goto out;
+		}
 #ifdef CONFIG_STACK_GROWSUP
 		if (vma_flags_mismatch(vma, VM_READ | VM_WRITE | VM_GROWSUP, 0))
 #else
#3 lore raw
Quoted 6 lines · KOSAKI Motohiro
Quoted 5 lines · Kees Cook
Quoted 4 lines · Cyrill Gorcunov

In case if underlied VMA is not found prctl_set_mm will return -EINVAL, but Michael proposed to return -EFAULT and Kosaki seconded. Make it so.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
Acked-by on v1 1/1
#4 lore raw
In reply to Cyrill Gorcunov
Quoted 4 lines · Cyrill Gorcunov

In case if underlied VMA is not found prctl_set_mm will return -EINVAL, but Michael proposed to return -EFAULT and Kosaki seconded. Make it so.

Quoted 9 lines
Cc KOSAKI Motohiro <[email protected]>
Cc Pavel Emelyanov <[email protected]>,
Cc Tejun Heo <[email protected]>
Cc Kees Cook <[email protected]>
Cc Serge Hallyn <[email protected]>
Cc KAMEZAWA Hiroyuki <[email protected]>
Cc Andrew Morton <[email protected]>