* [Qemu-devel] [PATCH] linux-user: use default mmap_min_addr 65536 when /proc/sys/vm/mmap_min_addr cannot be read
@ 2010-05-13 13:17 Martin Jansa
2010-05-13 16:59 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Martin Jansa @ 2010-05-13 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Martin Jansa
* 65536 is default at least for ubuntu and fedora.
* after http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0e1a6ef2dea88101b056b6d9984f3325c5efced3
it's not readable by normal user on many systems
* there is patch to enable read-only access again
http://git.kernel.org/?p=linux/kernel/git/jmorris/security-testing-2.6.git;a=commitdiff;h=822cceec7248013821d655545ea45d1c6a9d15b3
but that's not applied in many distributions
* please consider this workaround
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
linux-user/main.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 18b52c0..94b6465 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2891,6 +2891,7 @@ int main(int argc, char **argv, char **envp)
* When loading the ELF image to determine whether guest_base
* is needed. It is also used in mmap_find_vma.
*/
+#define MMAP_MIN_ADDR_DEFAULT 65536
{
FILE *fp;
@@ -2899,8 +2900,14 @@ int main(int argc, char **argv, char **envp)
if (fscanf(fp, "%lu", &tmp) == 1) {
mmap_min_addr = tmp;
qemu_log("host mmap_min_addr=0x%lx\n", mmap_min_addr);
+ } else {
+ qemu_log("cannot read value from /proc/sys/vm/mmap_min_addr, assuming %d\n", MMAP_MIN_ADDR_DEFAULT);
+ mmap_min_addr = MMAP_MIN_ADDR_DEFAULT;
}
fclose(fp);
+ } else {
+ qemu_log("cannot open /proc/sys/vm/mmap_min_addr for reading, assuming %d\n", MMAP_MIN_ADDR_DEFAULT);
+ mmap_min_addr = MMAP_MIN_ADDR_DEFAULT;
}
}
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: use default mmap_min_addr 65536 when /proc/sys/vm/mmap_min_addr cannot be read
2010-05-13 13:17 [Qemu-devel] [PATCH] linux-user: use default mmap_min_addr 65536 when /proc/sys/vm/mmap_min_addr cannot be read Martin Jansa
@ 2010-05-13 16:59 ` Richard Henderson
2010-05-13 19:26 ` Martin Jansa
0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2010-05-13 16:59 UTC (permalink / raw)
To: Martin Jansa; +Cc: qemu-devel
On 05/13/2010 06:17 AM, Martin Jansa wrote:
> @@ -2899,8 +2900,14 @@ int main(int argc, char **argv, char **envp)
> if (fscanf(fp, "%lu", &tmp) == 1) {
> mmap_min_addr = tmp;
> qemu_log("host mmap_min_addr=0x%lx\n", mmap_min_addr);
> + } else {
> + qemu_log("cannot read value from /proc/sys/vm/mmap_min_addr, assuming %d\n", MMAP_MIN_ADDR_DEFAULT);
> + mmap_min_addr = MMAP_MIN_ADDR_DEFAULT;
> }
> fclose(fp);
> + } else {
> + qemu_log("cannot open /proc/sys/vm/mmap_min_addr for reading, assuming %d\n", MMAP_MIN_ADDR_DEFAULT);
> + mmap_min_addr = MMAP_MIN_ADDR_DEFAULT;
> }
> }
Perhaps you can combine these two else clauses?
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: use default mmap_min_addr 65536 when /proc/sys/vm/mmap_min_addr cannot be read
2010-05-13 16:59 ` Richard Henderson
@ 2010-05-13 19:26 ` Martin Jansa
2010-05-14 13:11 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Martin Jansa @ 2010-05-13 19:26 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel
On Thu, May 13, 2010 at 09:59:24AM -0700, Richard Henderson wrote:
> On 05/13/2010 06:17 AM, Martin Jansa wrote:
> > @@ -2899,8 +2900,14 @@ int main(int argc, char **argv, char **envp)
> > if (fscanf(fp, "%lu", &tmp) == 1) {
> > mmap_min_addr = tmp;
> > qemu_log("host mmap_min_addr=0x%lx\n", mmap_min_addr);
> > + } else {
> > + qemu_log("cannot read value from /proc/sys/vm/mmap_min_addr, assuming %d\n", MMAP_MIN_ADDR_DEFAULT);
> > + mmap_min_addr = MMAP_MIN_ADDR_DEFAULT;
> > }
> > fclose(fp);
> > + } else {
> > + qemu_log("cannot open /proc/sys/vm/mmap_min_addr for reading, assuming %d\n", MMAP_MIN_ADDR_DEFAULT);
> > + mmap_min_addr = MMAP_MIN_ADDR_DEFAULT;
> > }
> > }
>
> Perhaps you can combine these two else clauses?
Sure it would be possible, but while trying to find why qemu doesn't
work on someone box but works on mine I wanted to distinguish between
cannot open and cannot read.
Also if I combine it in test ie initialize mmap_min_addr with -1, and
then check if it changed after read (because 0 is also valid value),
or moving fopen and fscanf to one condition, then it gets IMHO as
complicated as those 2 else clauses.
BTW: I noticed that qemu-arm works ok when mmap_min_addr is low enough
(and doesn't have to be zero).
my box had mmap_min_addr 4096 and qemu-arm worked fine even without
reading it
and the other boxes had mmap_min_addr = 64K and failed later to mmap.
Regards,
--
uin:136542059 jid:Martin.Jansa@gmail.com
Jansa Martin sip:jamasip@voip.wengo.fr
JaMa
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: use default mmap_min_addr 65536 when /proc/sys/vm/mmap_min_addr cannot be read
2010-05-13 19:26 ` Martin Jansa
@ 2010-05-14 13:11 ` Richard Henderson
0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2010-05-14 13:11 UTC (permalink / raw)
To: Martin Jansa; +Cc: qemu-devel
On 05/13/2010 12:26 PM, Martin Jansa wrote:
> BTW: I noticed that qemu-arm works ok when mmap_min_addr is low enough
> (and doesn't have to be zero).
>
> my box had mmap_min_addr 4096 and qemu-arm worked fine even without
> reading it
Paul Brook's c581deda322080e8beb88b2e468d4af54454e4b3 had the side
effect of working around mmap_min_addr without having to read it.
Of course, if we *can* read mmap_min_addr, his patch will do less work.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-14 13:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-13 13:17 [Qemu-devel] [PATCH] linux-user: use default mmap_min_addr 65536 when /proc/sys/vm/mmap_min_addr cannot be read Martin Jansa
2010-05-13 16:59 ` Richard Henderson
2010-05-13 19:26 ` Martin Jansa
2010-05-14 13:11 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).