lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7b9198260805201242p1adf4651kb4c434d73884b6c1@mail.gmail.com>
Date:	Tue, 20 May 2008 20:42:54 +0100
From:	"Tom Spink" <tspink@...il.com>
To:	"Jeff Dike" <jdike@...toit.com>
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: Re: UML fails to locate address space

2008/5/20 Jeff Dike <jdike@...toit.com>:
> On Tue, May 20, 2008 at 07:01:02PM +0100, Tom Spink wrote:
>> I'm a hardy.  I bet it's 893f802872c3.
>>
>> http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-hardy.git;a=commitdiff;h=893f802872c3e3c6e4bb40c3be4845784b81b934
>
> Looks right, and mmap_min_addr is in mainline, just with a value of
> zero.  So, it looks like the right thing to do is read the value of
> /proc/sys/vm/mmap_min_addr and start bottom there.
>
>                        Jeff
>
> --
> Work email - jdike at linux dot intel dot com
>

Wuhoo.

tom@...ly:~$ cat /proc/sys/vm/mmap_min_addr
65536

And this is what I did:

diff --git a/arch/um/os-Linux/sys-i386/task_size.c
b/arch/um/os-Linux/sys-i386/task_size.c
index ccb49b0..f5ece4b 100644
--- a/arch/um/os-Linux/sys-i386/task_size.c
+++ b/arch/um/os-Linux/sys-i386/task_size.c
@@ -1,10 +1,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <fcntl.h>
+#include <unistd.h>
 #include <sys/mman.h>
 #include "longjmp.h"
 #include "kern_constants.h"

+#define PROC_MMAP_MIN_ADDR "/proc/sys/vm/mmap_min_addr"
+
 static jmp_buf buf;

 static void segfault(int sig)
@@ -63,10 +67,34 @@ static int page_ok(unsigned long page)
 	return ok;
 }

+static unsigned long get_mmap_min_addr(void)
+{
+	unsigned long ret = 0;
+	char mmap_min_addr[8];
+	int fd;
+	struct stat s;
+	
+	/* Determine the minimum mmap address. */
+	if (stat(PROC_MMAP_MIN_ADDR, &s) == 0) {
+		/* Open the proc file, and read in the value. */
+		fd = open(PROC_MMAP_MIN_ADDR, O_RDONLY);
+		if (fd < 0)
+			return ret;
+			
+		read(fd, mmap_min_addr, sizeof(mmap_min_addr));
+		close(fd);
+
+		/* Determine the address. */
+		ret = strtoul(mmap_min_addr, NULL, 0) >> UM_KERN_PAGE_SHIFT;
+	}
+
+	return ret;
+}
+
 unsigned long os_get_task_size(void)
 {
 	struct sigaction sa, old;
-	unsigned long bottom = 0;
+	unsigned long bottom;
 	/*
 	 * A 32-bit UML on a 64-bit host gets confused about the VDSO at
 	 * 0xffffe000.  It is mapped, is readable, can be reprotected writeable
@@ -78,6 +106,10 @@ unsigned long os_get_task_size(void)
 	unsigned long top = 0xffffd000 >> UM_KERN_PAGE_SHIFT;
 	unsigned long test;

+	printf("Determining the bottom of the address space ... ");
+	bottom = get_mmap_min_addr();
+	printf("0x%x\n", bottom);
+
 	printf("Locating the top of the address space ... ");
 	fflush(stdout);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ