Skip to contentSkip to conversation

kernel BUG at mm/mmap.c:1990

parisc-linux Jeff Bailey 3 participants 3 messages Dec 12, 2006 – Dec 13, 2006 2 messages not in the archive PA-RISC architecture

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 7 lines · Helge Deller

Maybe someone has an idea ?

The "adjtimex02" test from the Linux Test Project (http://ltp.sf.net) seems to pass all test, but triggers a kernel BUG in mm/mmap.c:1990 when exiting. strace is attached below.

kernel BUG at mm/mmap.c:1990!

8< (snip)

I posted a reduced testcase to trigger this several months ago, if that would be useful to you. I don't have it handy, though.

Signature · 1 line
Jeff Bailey - http://www.raspberryginger.com/jbailey/
#2 lore raw
In reply to a message not in the archive
Quoted 5 lines · Helge Deller

Maybe someone has an idea ?

The "adjtimex02" test from the Linux Test Project (http://ltp.sf.net) seems to pass all test, but triggers a kernel BUG in mm/mmap.c:1990 when exiting. strace is attached below.

iirc this only bites on 32bit kernels.

This is what Jeff is referring to:

/*
* Testcase reduced from ltp, adjtimex02
*
* 1) adjtimex(2) fails with errno set to EFAULT if buf does
* not point to writable memory
*/

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/timex.h>

int
main()

{
	int x;
	struct timex *buffp = (struct timex *) -1;

	/* Check whether we are root */
	if (geteuid() != 0) {
		fprintf(stderr, "This needs to run as root.\n");
		return(-1);
	}
	
	/* Call adjtimex(2) */
	x = adjtimex(buffp);

	return x;
}

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#4 lore raw

Re: [parisc-linux] kernel BUG at mm/mmap.c:1990 [PATCH attached]

Quoted 8 lines · Kyle McMartin
Quoted 4 lines · Helge Deller

Maybe someone has an idea ?

The "adjtimex02" test from the Linux Test Project (http://ltp.sf.net) seems to pass all test, but triggers a kernel BUG in mm/mmap.c:1990 when exiting. strace is attached below.

iirc this only bites on 32bit kernels.

Quoted 8 lines

This is what Jeff is referring to:
/*
* Testcase reduced from ltp, adjtimex02
*
* 1) adjtimex(2) fails with errno set to EFAULT if buf does
* not point to writable memory
*/
[...]

The following patch is a first draft which fixes the LTP crashes. It still includes debugging info... I assume the main problem is, that get_user() and put_user() does not do any memory region checking at all. I think this is wrong (although the fault handler may have catched most of the wrong ones).

I know my implementation of the function access_ok() is wrong.
I tried and looked at the other arch implementations, but I didn't found an easy one. But I'm sure there is one, and hopefully someone here can point me to a better/correct implementation...?

Comments ?

Helge

arch/parisc/lib/memcpy.c +16 -6
index 5575e41..cd8b657 100644
@@ -488,20 +488,30 @@ handle_store_error:
 #ifdef __KERNEL__
 unsigned long copy_to_user(void __user *dst, const void *src, unsigned long len)
 {
-	mtsp(get_kernel_space(), 1);
-	mtsp(get_user_space(), 2);
-	return pa_memcpy((void __force *)dst, src, len);
+	BUG_ON((long) len < 0);
+	if (access_ok(VERIFY_WRITE, dst, len)) {
+		mtsp(get_kernel_space(), 1);
+		mtsp(get_user_space(), 2);
+		len = pa_memcpy((void __force *)dst, src, len);
+	};
+	return len;
 }
 
 unsigned long copy_from_user(void *dst, const void __user *src, unsigned long len)
 {
-	mtsp(get_user_space(), 1);
-	mtsp(get_kernel_space(), 2);
-	return pa_memcpy(dst, (void __force *)src, len);
+	BUG_ON((long) len < 0);
+	if (access_ok(VERIFY_READ, src, len)) {
+		mtsp(get_user_space(), 1);
+		mtsp(get_kernel_space(), 2);
+		len = pa_memcpy(dst, (void __force *)src, len);
+	} else
+		memset(dst, 0, len);
+	return len;
 }
 
 unsigned long copy_in_user(void __user *dst, const void __user *src, unsigned long len)
 {
+	BUG_ON((long) len < 0);
 	mtsp(get_user_space(), 1);
 	mtsp(get_user_space(), 2);
 	return pa_memcpy((void __force *)dst, (void __force *)src, len);
include/asm-parisc/uaccess.h +46 -56

170 lines not on this page · raw message

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux