Skip to contentSkip to conversation

How is user-mode-linux using /dev/shm/?

uml-devel Mattia Dongili 5 participants 9 messages Sep 28, 2006 – Sep 30, 2006 1 message not in the archive User-mode Linux (UML)

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Thanks Petter for writing,
I was going to followup to the sysvinit bug :)

I'm Cc-ing upstream too.

Quoted 8 lines · Petter Reinholdtsen

Hi

I am one of the sysvinit maintainers. Recently we changed the mount options of /dev/shm/, and got a bug report about uml refusing to start (#386945). Because of this, I am curious how uml uses /dev/shm/. Is it using the shm-functions in glibc, or something else? Please explain how it work.

I don't think it uses shm* functions, as far as I can tell the /dev/shm location is sensible to $TMP, $TEMP or $TEMPDIR, thus changing one of them to a different location goes farther than what's reported in the bureport:

$ TMPDIR=./TMP linux ubd0=rootfs_debian-sid.172.20.0.20 ubd1=swap-172.20.0.20 eth0=tuntap,,,172.20.0.19 umid=debian mem=128
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking for tmpfs mount on /dev/shm...OK
Checking PROT_EXEC mmap in ./TMP/...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found
  - PTRACE_FAULTINFO...not found
  - PTRACE_LDT...not found
UML running in SKAS0 mode
Mapping memory: Cannot allocate memory

Don't know now, it's maybe easy to fix, there's a nice global variable set to "/dev/shm" in arch/um/os-Linux/mem.c and UML uses mkstemp() to create files.

Quoted 8 lines

To make some writable tmpfs available to those in need of such system, and to avoid using /dev/shm/ which is reserved for the shm-functions, I just uploaded sysvinit version 2.86.ds1-26. It will mount a tmpfs on /lib/init/rw/ that can be used instead. If /lib/init/rw/.ramfs exist, that mount point is a tmpfs. I'm not sure if this last change will make it into Etch or not, but I hope so, to solve any problems with packages previously using /dev/shm/ as a generic tmpfs file system.

Well, I'd actually prefer if you could remove the noexec flag from /dev/shm. I understand the security reasons given in the bugreport but I'd prefer avoid having to deal with one more Debian-only (is it?) thing given the soon to come general freeze.

Thanks

Signature · 12 lines
mattia
:wq!

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#2 lore raw

[Mattia Dongili]

Quoted 4 lines

Well, I'd actually prefer if you could remove the noexec flag from /dev/shm. I understand the security reasons given in the bugreport but I'd prefer avoid having to deal with one more Debian-only (is it?) thing given the soon to come general freeze.

I am considering this for etch only, and to reinsert it once etch is released. I suspect it is better to break uml, dosemu and others misusing /dev/shm/ early in the etch+1 release cycle instead of late in the etch cycle.

But I might be too late, as base and sysvinit is already frozen, according to the email from Andreas. :( We will have to discuss it with the release managers, I guess.

Friendly,

Signature · 11 lines
Petter Reinholdtsen

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#4 lore raw
In reply to Mattia Dongili
Quoted 10 lines · Mattia Dongili
Quoted 8 lines · Petter Reinholdtsen

To make some writable tmpfs available to those in need of such system, and to avoid using /dev/shm/ which is reserved for the shm-functions, I just uploaded sysvinit version 2.86.ds1-26. It will mount a tmpfs on /lib/init/rw/ that can be used instead. If /lib/init/rw/.ramfs exist, that mount point is a tmpfs. I'm not sure if this last change will make it into Etch or not, but I hope so, to solve any problems with packages previously using /dev/shm/ as a generic tmpfs file system.

Quoted 4 lines

Well, I'd actually prefer if you could remove the noexec flag from /dev/shm. I understand the security reasons given in the bugreport but I'd prefer avoid having to deal with one more Debian-only (is it?) thing given the soon to come general freeze.

UML needs a non-noexec place to keep a file that will be used as its physical memory. A tmpfs mount is greatly preferred for performance reasons as well as tmpfs being the only filesystem supporting MADV_REMOVE, which is used for memory hotplug.

Jeff

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw
In reply to Petter Reinholdtsen
Quoted 10 lines · Petter Reinholdtsen

[Mattia Dongili]

Quoted 4 lines

Well, I'd actually prefer if you could remove the noexec flag from /dev/shm. I understand the security reasons given in the bugreport but I'd prefer avoid having to deal with one more Debian-only (is it?) thing given the soon to come general freeze.

I am considering this for etch only, and to reinsert it once etch is released. I suspect it is better to break uml, dosemu and others misusing /dev/shm/ early in the etch+1 release cycle instead of late in the etch cycle.

absolutely seconded.

Quoted 3 lines

But I might be too late, as base and sysvinit is already frozen, according to the email from Andreas. :( We will have to discuss it with the release managers, I guess.

I can still file a critical bug because sysvinit "breaks unrelated SW" :) Let's submit the question to d-release then.

Signature · 14 lines
mattia
:wq!



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#5 lore raw
In reply to Jeff Dike
Quoted 16 lines · Jeff Dike
Quoted 10 lines · Mattia Dongili
Quoted 8 lines · Petter Reinholdtsen

To make some writable tmpfs available to those in need of such system, and to avoid using /dev/shm/ which is reserved for the shm-functions, I just uploaded sysvinit version 2.86.ds1-26. It will mount a tmpfs on /lib/init/rw/ that can be used instead. If /lib/init/rw/.ramfs exist, that mount point is a tmpfs. I'm not sure if this last change will make it into Etch or not, but I hope so, to solve any problems with packages previously using /dev/shm/ as a generic tmpfs file system.

Quoted 4 lines

Well, I'd actually prefer if you could remove the noexec flag from /dev/shm. I understand the security reasons given in the bugreport but I'd prefer avoid having to deal with one more Debian-only (is it?) thing given the soon to come general freeze.

Quoted 4 lines

UML needs a non-noexec place to keep a file that will be used as its physical memory. A tmpfs mount is greatly preferred for performance reasons as well as tmpfs being the only filesystem supporting MADV_REMOVE, which is used for memory hotplug.

Thinking of a Debian only fix for the above, does simply playing with default_tmpdir in arch/um/os-Linux/mem.c (probably in which_tmpdir()) suffice to use /lib/init/rw/.ramfs as default?

(Yes I should try it... will try to find some time next week)

Thanks

Signature · 12 lines
mattia
:wq!

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#6 lore raw
Quoted 5 lines · Mattia Dongili

Thinking of a Debian only fix for the above, does simply playing with default_tmpdir in arch/um/os-Linux/mem.c (probably in which_tmpdir()) suffice to use /lib/init/rw/.ramfs as default?

(Yes I should try it... will try to find some time next week)

What difference would this make? You still have some world-writable place not mounted noexec that nasty people could try to take advantage of. You're just changing the name of that place.

Jeff

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#7 lore raw
Quoted 10 lines · Jeff Dike
Quoted 5 lines · Mattia Dongili

Thinking of a Debian only fix for the above, does simply playing with default_tmpdir in arch/um/os-Linux/mem.c (probably in which_tmpdir()) suffice to use /lib/init/rw/.ramfs as default?

(Yes I should try it... will try to find some time next week)

What difference would this make? You still have some world-writable place not mounted noexec that nasty people could try to take advantage of. You're just changing the name of that place.

It does not intrude in SYSV shm namespace anymore.

Signature · 14 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#8 lore raw
In reply to Mattia Dongili
Quoted 17 lines · Mattia Dongili
Quoted 16 lines · Jeff Dike
Quoted 14 lines · Mattia Dongili
Quoted 8 lines · Petter Reinholdtsen

To make some writable tmpfs available to those in need of such system, and to avoid using /dev/shm/ which is reserved for the shm-functions, I just uploaded sysvinit version 2.86.ds1-26. It will mount a tmpfs on /lib/init/rw/ that can be used instead. If /lib/init/rw/.ramfs exist, that mount point is a tmpfs. I'm not sure if this last change will make it into Etch or not, but I hope so, to solve any problems with packages previously using /dev/shm/ as a generic tmpfs file system.

Well, I'd actually prefer if you could remove the noexec flag from /dev/shm. I understand the security reasons given in the bugreport but I'd prefer avoid having to deal with one more Debian-only (is it?) thing given the soon to come general freeze.

Quoted 8 lines
Quoted 4 lines

UML needs a non-noexec place to keep a file that will be used as its physical memory. A tmpfs mount is greatly preferred for performance reasons as well as tmpfs being the only filesystem supporting MADV_REMOVE, which is used for memory hotplug.

Thinking of a Debian only fix for the above, does simply playing with default_tmpdir in arch/um/os-Linux/mem.c (probably in which_tmpdir()) suffice to use /lib/init/rw/.ramfs as default?

Is it world-writable with the sticky bit set as /tmp and /dev/shm? I do not know

Signature · 16 lines
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#9 lore raw
In reply to Mattia Dongili
Quoted 10 lines · Mattia Dongili

Thanks Petter for writing,
I was going to followup to the sysvinit bug :)

I'm Cc-ing upstream too.

I don't think it uses shm* functions, as far as I can tell the /dev/shm location is sensible to $TMP, $TEMP or $TEMPDIR, thus changing one of them to a different location goes farther than what's reported in the bureport:

Quoted 13 lines
$ TMPDIR=./TMP linux ubd0=rootfs_debian-sid.172.20.0.20
ubd1=swap-172.20.0.20 eth0=tuntap,,,172.20.0.19 umid=debian mem=128
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking for tmpfs mount on /dev/shm...OK
Checking PROT_EXEC mmap in ./TMP/...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found
  - PTRACE_FAULTINFO...not found
  - PTRACE_LDT...not found
UML running in SKAS0 mode
Mapping memory: Cannot allocate memory

There is probably some additional bug here, it should be easy to fix.

Quoted 13 lines

Don't know now, it's maybe easy to fix, there's a nice global variable set to "/dev/shm" in arch/um/os-Linux/mem.c and UML uses mkstemp() to create files.

Quoted 8 lines

To make some writable tmpfs available to those in need of such system, and to avoid using /dev/shm/ which is reserved for the shm-functions, I just uploaded sysvinit version 2.86.ds1-26. It will mount a tmpfs on /lib/init/rw/ that can be used instead. If /lib/init/rw/.ramfs exist, that mount point is a tmpfs. I'm not sure if this last change will make it into Etch or not, but I hope so, to solve any problems with packages previously using /dev/shm/ as a generic tmpfs file system.

Quoted 3 lines

Well, I'd actually prefer if you could remove the noexec flag from /dev/shm. I understand the security reasons given in the bugreport but I'd prefer avoid having to deal with one more Debian-only (is it?)

It is not - it can happen on Gentoo too (actually, the issue there is simply that the manuals _recommend_ to use noexec for /dev/shm).

Quoted 1 line

thing given the soon to come general freeze.

As Jeff Dike explained, we just need to use an executable tmpfs mount. For a long time, we used /tmp and _suggested_ people to use tmpfs for it, or to use it elsewhere and point TMP there. And quite frankly, it would be nicer to make that a default (i.e. if /tmp is automatically a tmpfs mount, switching back there would be nice).

In 2.4 days, using tmpfs for /tmp was bad for one issue: you could not do a loopback mount from tmpfs, and this broke mkinitrd; but that has been solved since then, for 2.6 at least.

Signature · 16 lines
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel