Skip to contentSkip to conversation

sanity.bbclass: Reading /proc/sys/vm/mmap_min_addr is not permitted with 2.6.33+ on host

PATCH In review Martin Jansa 4 participants 7 messages Jan 2, 2010 – Jan 15, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sanity.bbclass: Reading /proc/sys/vm/mmap_min_addr is not permitted with 2.6.33+ on host

* With 2.6.33-rc2-00252-ge9e5521 on my host I noticed that "cat /proc/sys/vm/mmap_min_addr" returns now
"cat: /proc/sys/vm/mmap_min_addr: Operation not permitted" Its probably becuse of
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0e1a6ef2dea88101b056b6d9984f3325c5efced3
But I'm not sure if checking CAP_SYS_RAWIO even for reading this value is intentional or just bug which should be fixed in kernel.

* This patch prints notice about need to check that value yourself (as root) instead of failing with "ERROR: IO Error: [Errno 1] Operation not permitted"

* Its not optimal, because this notice is shown every time you run bitbake (even after checking/setting 0 to mmap_min_addr if you have kernel not allowing to read it

---
 classes/sanity.bbclass |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
classes/sanity.bbclass +9 -4
index f65df61..4f90975 100644
@@ -97,10 +97,15 @@ def check_sanity(e):
 				messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH"
 
 		if os.path.exists("/proc/sys/vm/mmap_min_addr"):
-			f = file("/proc/sys/vm/mmap_min_addr", "r")
-			if (f.read().strip() != "0"):
-				messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
-			f.close()
+			try:
+				f = file("/proc/sys/vm/mmap_min_addr", "r")
+				if (f.read().strip() != "0"):
+					messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
+				f.close()
+			except:
+				import bb
+				bb.msg.note(1, bb.msg.domain.Parsing, "/proc/sys/vm/mmap_min_addr cannot be checked. This will cause problems with qemu if it is not set to 0, so please check the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n")
+				
 
 	for util in required_utilities.split():
 		if not check_app_exists( util, e.data ):
Signature · 1 line
1.6.6
#1 lore raw
Quoted 8 lines · Martin Jansa

* With 2.6.33-rc2-00252-ge9e5521 on my host I noticed that "cat /proc/sys/vm/mmap_min_addr" returns now
"cat: /proc/sys/vm/mmap_min_addr: Operation not permitted" Its probably becuse of
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0e1a6ef2dea88101b056b6d9984f3325c5efced3
But I'm not sure if checking CAP_SYS_RAWIO even for reading this value is intentional or just bug which should be fixed in kernel.

Quoted 8 lines

* This patch prints notice about need to check that value yourself (as root) instead of failing with "ERROR: IO Error: [Errno 1] Operation not permitted"

* Its not optimal, because this notice is shown every time you run bitbake (even after checking/setting 0 to mmap_min_addr if you have kernel not allowing to read it

That does sound fairly unsatisfactory. Printing a diagnostic on every build, with no way for the user to suppress it, surely can't be the way of the future.

If you can't tell whether mmap_min_addr is set correctly or not then it would probably be better to not show the diagnostic at all. Perhaps you could investigate patching qemu to print a more meaningful message if it actually encounters a mmap() failure of this kind.

p.

#2 lore raw
Quoted 18 lines · Phil Blundell
Quoted 8 lines · Martin Jansa

* With 2.6.33-rc2-00252-ge9e5521 on my host I noticed that "cat /proc/sys/vm/mmap_min_addr" returns now
"cat: /proc/sys/vm/mmap_min_addr: Operation not permitted" Its probably becuse of
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0e1a6ef2dea88101b056b6d9984f3325c5efced3
But I'm not sure if checking CAP_SYS_RAWIO even for reading this value is intentional or just bug which should be fixed in kernel.

Quoted 8 lines

* This patch prints notice about need to check that value yourself (as root) instead of failing with "ERROR: IO Error: [Errno 1] Operation not permitted"

* Its not optimal, because this notice is shown every time you run bitbake (even after checking/setting 0 to mmap_min_addr if you have kernel not allowing to read it

Quoted 8 lines

That does sound fairly unsatisfactory. Printing a diagnostic on every build, with no way for the user to suppress it, surely can't be the way of the future.

If you can't tell whether mmap_min_addr is set correctly or not then it would probably be better to not show the diagnostic at all. Perhaps you could investigate patching qemu to print a more meaningful message if it actually encounters a mmap() failure of this kind.

BTW, wasn't the latest qemu "fixed" for this mmap() issue?

Signature · 1 line
Denys
#3 lore raw

Dnia niedziela, 3 stycznia 2010 o 01:53:09 Denys Dmytriyenko napisał(a):

Quoted 1 line

BTW, wasn't the latest qemu "fixed" for this mmap() issue?

It was. I am running qemu 0.12.1 on my Debian host without problem. Did not made recipe for it anyway.

Attached is cleaned version of Martin's patch which I use with stable/2009 and OE.dev branches. Please Ack it.

Regards,

Signature · 3 lines
JID:      [email protected]
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz

From 2c335c2bfba52b8a7672cec02159c9d8bba658a1 Mon Sep 17 00:00:00 2001
From: Martin Jansa <[email protected]>
Date: Fri, 15 Jan 2010 18:10:29 +0100
Subject: [PATCH] sanity.bbclass: handle lack of permission to read /proc/sys/vm/mmap_min_addr

* With 2.6.33-rc2-00252-ge9e5521 on my host I noticed that "cat /proc/sys/vm/mmap_min_addr" returns now
"cat: /proc/sys/vm/mmap_min_addr: Operation not permitted" Its probably becuse of
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0e1a6ef2dea88101b056b6d9984f3325c5efced3
But I'm not sure if checking CAP_SYS_RAWIO even for reading this value is intentional or just bug which should be fixed in kernel.

This patch makes bitbake ignore reading error. Possible QEmu failure is not handled yet.

---
 classes/sanity.bbclass |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
classes/sanity.bbclass +8 -5
index f65df61..f57d8e4 100644
@@ -96,11 +96,14 @@ def check_sanity(e):
 			if not check_app_exists("qemu-arm", e.data):
 				messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH"
 
-		if os.path.exists("/proc/sys/vm/mmap_min_addr"):
-			f = file("/proc/sys/vm/mmap_min_addr", "r")
-			if (f.read().strip() != "0"):
-				messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
-			f.close()
+		try:
+			if os.path.exists("/proc/sys/vm/mmap_min_addr"):
+				f = file("/proc/sys/vm/mmap_min_addr", "r")
+				if (f.read().strip() != "0"):
+					messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
+				f.close()
+		except:
+			pass
 
 	for util in required_utilities.split():
 		if not check_app_exists( util, e.data ):
Signature · 1 line
1.6.6
#4 lore raw

Re: [PATCH] sanity.bbclass: Reading?/proc/sys/vm/mmap_min_addr is not permitted with 2.6.33+ on host

Quoted 9 lines · Marcin Juszkiewicz

Dnia niedziela, 3 stycznia 2010 o 01:53:09 Denys Dmytriyenko napisa??(a):

Quoted 1 line

BTW, wasn't the latest qemu "fixed" for this mmap() issue?

It was. I am running qemu 0.12.1 on my Debian host without problem. Did not made recipe for it anyway.

Attached is cleaned version of Martin's patch which I use with stable/2009 and OE.dev branches. Please Ack it.

Is there any way to remove the check altogether? Are there any other issues, besides backward compatibility with older QEMU?

Signature · 1 line
Denys
Quoted 59 lines

Regards,

Signature · 24 lines
JID:      [email protected]
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz

From 2c335c2bfba52b8a7672cec02159c9d8bba658a1 Mon Sep 17 00:00:00 2001
From: Martin Jansa <[email protected]>
Date: Fri, 15 Jan 2010 18:10:29 +0100
Subject: [PATCH] sanity.bbclass: handle lack of permission to read /proc/sys/vm/mmap_min_addr

* With 2.6.33-rc2-00252-ge9e5521 on my host I noticed that
  "cat /proc/sys/vm/mmap_min_addr" returns now
  "cat: /proc/sys/vm/mmap_min_addr: Operation not permitted"
  Its probably becuse of
  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0e1a6ef2dea88101b056b6d9984f3325c5efced3
  But I'm not sure if checking CAP_SYS_RAWIO even for reading this value
  is intentional or just bug which should be fixed in kernel.

This patch makes bitbake ignore reading error. Possible QEmu failure is not
handled yet.

Signed-off-by: Marcin Juszkiewicz <[email protected]>
---
 classes/sanity.bbclass |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
classes/sanity.bbclass +8 -5
index f65df61..f57d8e4 100644
@@ -96,11 +96,14 @@ def check_sanity(e):
 			if not check_app_exists("qemu-arm", e.data):
 				messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH"
 
-		if os.path.exists("/proc/sys/vm/mmap_min_addr"):
-			f = file("/proc/sys/vm/mmap_min_addr", "r")
-			if (f.read().strip() != "0"):
-				messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
-			f.close()
+		try:
+			if os.path.exists("/proc/sys/vm/mmap_min_addr"):
+				f = file("/proc/sys/vm/mmap_min_addr", "r")
+				if (f.read().strip() != "0"):
+					messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
+				f.close()
+		except:
+			pass
 
 	for util in required_utilities.split():
 		if not check_app_exists( util, e.data ):
Signature · 7 lines
1.6.6


_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
#5 lore raw

Re: [PATCH] sanity.bbclass: Reading?/proc/sys/vm/mmap_min_addr is not permitted with 2.6.33+ on host

Dnia piątek, 15 stycznia 2010 o 19:56:39 Denys Dmytriyenko napisał(a):

Quoted 2 lines

Is there any way to remove the check altogether? Are there any other
issues, besides backward compatibility with older QEMU?

Fine for me.

Regards,

Signature · 3 lines
JID:      [email protected]
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz
#6 lore raw
In reply to Phil Blundell
Quoted 13 lines · Phil Blundell
Quoted 12 lines · Martin Jansa

* With 2.6.33-rc2-00252-ge9e5521 on my host I noticed that "cat /proc/sys/vm/mmap_min_addr" returns now
"cat: /proc/sys/vm/mmap_min_addr: Operation not permitted" Its probably becuse of
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0e1a6ef2dea88101b056b6d9984f3325c5efced3
But I'm not sure if checking CAP_SYS_RAWIO even for reading this value is intentional or just bug which should be fixed in kernel.

* This patch prints notice about need to check that value yourself (as root) instead of failing with "ERROR: IO Error: [Errno 1] Operation not permitted"

Quoted 8 lines
Quoted 4 lines

* Its not optimal, because this notice is shown every time you run bitbake (even after checking/setting 0 to mmap_min_addr if you have kernel not allowing to read it

That does sound fairly unsatisfactory. Printing a diagnostic on every build, with no way for the user to suppress it, surely can't be the way of the future.

Yes, agreed. I consider this only as temporary solution, because without this change I cannot use bitbake at all and of course I can remove that message if this behavior stay the same in 2.6.33 release or someone check qemu mmap failure.

That's why I didn't push it and just sent it here as heads up for builders with 2.6.33-rc* to save tham few mins checking what happen to bitbake.

Quoted 4 lines

If you can't tell whether mmap_min_addr is set correctly or not then it would probably be better to not show the diagnostic at all. Perhaps you could investigate patching qemu to print a more meaningful message if it actually encounters a mmap() failure of this kind.

Cheers,

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa