From e341e9364b90355d0d60bf9cbc5ef5912727d909 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 4 May 2008 07:13:37 +0000 Subject: [PATCH] Add workaround for AppArmor rule that blocks use of low memory addresses. This is causing trouble on Ubuntu 8.04. --- v7/src/microcode/ux.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/v7/src/microcode/ux.c b/v7/src/microcode/ux.c index 9f0b23cec..b7488584a 100644 --- a/v7/src/microcode/ux.c +++ b/v7/src/microcode/ux.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ux.c,v 1.35 2008/01/30 20:02:21 cph Exp $ +$Id: ux.c,v 1.36 2008/05/04 07:13:37 cph Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -677,6 +677,22 @@ mmap_heap_malloc (unsigned long requested_length) request = (((requested_length + (ps - 1)) / ps) * ps); } +#ifdef __linux__ + /* AppArmor can specify a minimum usable address. In that case we + need to detect it and compensate. */ + { + FILE * s = (fopen ("/proc/sys/vm/mmap_min_addr", "r")); + if (s != 0) + { + unsigned long new_min_result; + int rc = (fscanf (s, "%lu", (&new_min_result))); + fclose (s); + if ((rc == 1) && (new_min_result > min_result)) + min_result = new_min_result; + } + } +#endif + result = (mmap_heap_malloc_search (request, min_result, max_result)); if (result != 0) -- 2.25.1