Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 520260 - /dev/shm must be not mounted noexec
Summary: /dev/shm must be not mounted noexec
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-19 17:22 UTC by Toralf Förster
Modified: 2014-10-20 19:09 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2014-08-19 17:22:43 UTC
In IRC I was told that this line in /etc/fstab :

shm                     /dev/shm        tmpfs           nodev

is superflous nowadays - bit it isn't.

As soon as I try to start a user mode linuc image I do get :

tfoerste@n22 ~ $ start_uml.sh -r ~/virtual/uml/n22stab4 
Locating the bottom of the address space ... 0x1000
Locating the top of the address space ... 0xc0000000
Core dump limits :
        soft - 0
        hard - NONE
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 environment variables for a tempdir...none found
Checking if /dev/shm is on tmpfs...OK
Checking PROT_EXEC mmap in /dev/shm...Operation not permitted
/dev/shm must be not mounted noexec



This is  a x86 Gentoo.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2014-08-19 18:30:23 UTC
That's your UML script. Maybe you should make it check that, too.
Comment 2 Toralf Förster gentoo-dev 2014-08-19 18:49:06 UTC
nope, that comes from the UML linux executable, this is the command line :

/usr/local/bin/linux-v3.17-rc1 earlyprintk ubda=/home/tfoerste/virtual/uml/n22unst4 ubdb=/mnt/ramdisk/n22unst4_swap eth0=tuntap,tap0,72:ef:3d:5d:d3:db mem=2000M con0=fd:0,fd:1 con=pts umid=uml_n22unst4 rootfstype=ext4
Comment 3 Toralf Förster gentoo-dev 2014-08-19 18:51:11 UTC
And FWIW re-adding that line to /etc/fstab makes the error went away.
So b/c the way was changed of how shm is handled at least an news item and/or an ewarn would be nice and/or a hint in the handbook would be nice.
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2014-08-19 20:19:30 UTC
(In reply to Toralf Förster from comment #2)
> nope, that comes from the UML linux executable, this is the command line :
> 
> /usr/local/bin/linux-v3.17-rc1 

Gentoo can't fix /usr/local for you either, but if the executable can't fix the issue by remounting /dev/shm with the required options, then your script certainly can. Or you set up your own fstab as circumstances warrant.

It's too late now for a news item, since these changes probably went stable more than a year ago with baselayout-2.2.
Comment 5 Toralf Förster gentoo-dev 2014-08-19 21:07:58 UTC
ok, understood, but just for the record:

it is not an issue with a /usr/local, it is UML itself, which depends on "exec" on /dev/shm
Comment 6 William Hubbs gentoo-dev 2014-08-19 21:58:52 UTC
(In reply to Toralf Förster from comment #5)
> ok, understood, but just for the record:
> 
> it is not an issue with a /usr/local, it is UML itself, which depends on
> "exec" on /dev/shm

I thought Gentoo has always mounted /dev/shm noexec; I don't remember OpenRC ever doing otherwise.

@vapier:
Is this something I should change in OpenRC?
Comment 7 Toralf Förster gentoo-dev 2014-08-22 19:27:57 UTC
HHm, I must admit, I cannot swear, that my fstab is the original entry from the installation and not later modified by me to run UML.

But because I do not see in that file any comment from me I believed it at least...
Comment 8 Rick Farina (Zero_Chaos) gentoo-dev 2014-08-25 22:35:48 UTC
Without ANY shm entry in fstab:

shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)

So if this should be changed, then it's the kernel that needs to change.
Comment 9 Joshua Kinard gentoo-dev 2014-08-26 09:47:27 UTC
(In reply to Rick Farina (Zero_Chaos) from comment #8)
> Without ANY shm entry in fstab:
> 
> shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)
> 
> So if this should be changed, then it's the kernel that needs to change.

Can you try booting with init=/bin/bash on the kernel command line, manually mount /proc, and then check to see if the kernel automounted /dev/shm?  Not sure if this is caused by CONFIG_DEVTMPFS or not.  But by booting straight into bash, you'll eliminate any startup scripts as the culprit.
Comment 10 SpanKY gentoo-dev 2014-10-20 19:09:37 UTC
(In reply to William Hubbs from comment #6)

yes, baselayout-1.x & openrc have long used noexec in /dev/shm.  we do not want to change that behavior.

the # of packages that want to get executable shared memory maps can probably be counted on one hand.  Chrome comes to mind (NaCl needs to generate code on the fly and share it between processes).  not sure why UML needs interprocess executable memory ... i'm not familiar with its internals.

(In reply to Rick Farina (Zero_Chaos) from comment #8)

that's because baselayout/openrc have long mounted a default one for you when there's no entry in fstab.  this isn't a kernel issue at all (well, ignoring the fact that UML is in the kernel source tree, but that's orthogonal to what you actually mean here).