Bug 689217 - folder /dev/shm changed to read-only permission
Summary: folder /dev/shm changed to read-only permission
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.0
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Osier Yang
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 682015 689220
TreeView+ depends on / blocked
 
Reported: 2011-03-20 11:55 UTC by Tomer
Modified: 2011-07-25 15:13 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 689220 (view as bug list)
Environment:
Last Closed: 2011-05-05 02:06:51 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Tomer 2011-03-20 11:55:29 UTC
Description of problem:

When I tried to run new created vm, VM failed to run, 
vdsm log file report that spice failed to access to /dev/shm

Workaround :

need to restart the vdsm to change permission mode to all users rw.

Additional info:

rw permission to all users is a security  problem.
this allows shared memory to be accessible to every user.
should to create dedicated directory to spice under /dev/shm/qumenu

Comment 2 Dan Kenigsberg 2011-03-23 12:50:29 UTC
come to think of this, if qemu process won't start if it cannot write into /dev/shm, that this is a libvirt bug (or something else, even lower down the stack).

Comment 3 Vivian Bian 2011-03-25 05:54:52 UTC
Hi Tomer , 
Would you please provide following info for bug reproduction ? 

1. Which version of libvirt, qemu-kvm , kernel , vdsm did you use when meeting this bug 
2. Any Steps to reproduce this bug ? 
3. Is there any specific configuration for the guest ? Or libvirt or vdsm to reproduce this bug ? 

Thanks
Vivian

Comment 4 Tomer 2011-03-27 07:25:05 UTC
Hi Vivian

In fact the bug occurred on rhel5.
I don't have a specific scenario how to reproduce this bug,
I'll try to reproduce this bug on both OS rhel5 and rhel6, I'll update if I'll have more info.

Thanks,
Tomer

Comment 5 Daniel Veillard 2011-03-29 06:36:47 UTC
Hum, if the bug was found only on RHEL-5, I really don't see why that bug
is being assigned to RHEL-6, that's bogus.
Either provide a way to reproduce this on RHEL-6, or reassign it to RHEL-5,

 thanks !

Daniel

Comment 6 RHEL Program Management 2011-04-04 02:06:21 UTC
Since RHEL 6.1 External Beta has begun, and this bug remains
unresolved, it has been rejected as it is not proposed as
exception or blocker.

Red Hat invites you to ask your support representative to
propose this request, if appropriate and relevant, in the
next release of Red Hat Enterprise Linux.

Comment 7 Dan Kenigsberg 2011-04-24 08:34:00 UTC
It's pretty easy to reproduce on RHEL6.
- install RHEL6 from scratch. make sure that no vdsm is around.
- verify that /dev/shm is not writable by qemu:kvm. It's that way by default.
- try to start a domain with spice.

Comment 8 Osier Yang 2011-04-27 07:14:59 UTC
(In reply to comment #0)
> Description of problem:
> 
> When I tried to run new created vm, VM failed to run, 
> vdsm log file report that spice failed to access to /dev/shm
> 
> Workaround :
> 
> need to restart the vdsm to change permission mode to all users rw.
> 
> Additional info:
> 
> rw permission to all users is a security  problem.
> this allows shared memory to be accessible to every user.
> should to create dedicated directory to spice under /dev/shm/qumenu

I don't think libvirt could control this, qemu doesn't provide any flag of option "-spice" for us to speicify the location of the tmpfs location.

Comment 9 Dan Kenigsberg 2011-04-27 10:46:33 UTC
libvirt could chmod /dev/shm to let qemu write there.
(or spice should think of a better place to put its statistics)

Comment 10 Osier Yang 2011-04-27 12:30:47 UTC
Yes, The entry under /dev/shm for spice guest (e.g. "/dev/shm/spice.$pid") is created by spice, we can't control the location either in libvirt or in qemu.

5444     int shm_name_len = strlen(REDS_STAT_SHM_NAME) + 20;
5445     int fd;
5446 
5447     if (!(reds->stat_shm_name = (char *)malloc(shm_name_len))) {
5448         red_error("stat_shm_name alloc failed");
5449     }
5450     snprintf(reds->stat_shm_name, shm_name_len, REDS_STAT_SHM_NAME, getpid());
5451     if ((fd = shm_open(reds->stat_shm_name, O_CREAT | O_RDWR, 0444)) == -1) {
5452         red_error("statistics shm_open failed, %s", strerror(errno));
5453     }

I'm wondering if it's reasonable to chmod /dev/shm in libvirt, the default permision mode of "/dev/shm" is "rw" by all, obviously it's changed by some outside app, chmod in libvirt as a "fix" will be strange then, assuming outside app changed permission mode of /dev/shm to "1000", but finally the entry in /dev/shm for spice guest could be created successfully, and the guest could be started successfully, one will be surprised, and perhaps he'd like file another bug.

What I'm thinking is: if changing the permission mode outside, then do all outside, splitting the actions may not be good idea.

By the way, vdsmd chmod's /dev/shm to "1777" when startup.

# grep '/dev/shm' * -r
vdsm/vdsmd:    /bin/chmod 1777 /dev/shm

So curious what changes it into only "rw" by root.

Comment 11 Dan Kenigsberg 2011-04-27 14:34:12 UTC
> the default permission mode of "/dev/shm" is "rw" by all

If this is the case in RHEL6, there's no bug here. But as far as I recall that's not the case.

Comment 12 Osier Yang 2011-04-27 14:56:29 UTC
It's "rw" by all indeed.

[root@dhcp-* ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.0 (Santiago)
[root@dhcp-* ~]# ls -ld /dev/shm/
drwxrwxrwt. 2 root root 160 2011-04-19 05:04 /dev/shm/
[root@dhcp-4-231 ~]#

Comment 13 Osier Yang 2011-04-27 15:18:44 UTC
Same case on RHEL6.1 

[root@localhost ~]# reboot

Broadcast message from root
	(/dev/pts/9) at 23:35 ...

The system is going down for reboot NOW!
[root@localhost ~]# Connection to 10.*.*.* closed by remote host.
Connection to 10.*.*.*  closed.
[osier@Osier ~]$ ssh root@10.*.*.*
ssh: connect to host 10.*.*.* port 22: Connection refused
[osier@Osier ~]$ ssh root@10.*.*.*
root@10.*.*.*'s password: 
Last login: Wed Apr 27 23:35:36 2011 from vpn1-.nay.redhat.com
[root@localhost ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.1 Beta (Santiago)
[root@localhost ~]# ls -ld /dev/shm/
drwxrwxrwt. 2 root root 80 2011-04-27 23:36 /dev/shm/

Comment 14 Dan Kenigsberg 2011-04-27 15:31:11 UTC
Is that on a fresh RHEL6 that had never seen vdsm?
(vdsm sets this permission explicitly)

Comment 15 Osier Yang 2011-04-28 01:42:48 UTC
yes, no vdsm installed, there are not fresh installed boxes, but I think a reboot is enough, /dev/shm is mounted as the setting in /etc/fstab, I truse it's not changed.

Comment 16 Osier Yang 2011-04-28 01:44:53 UTC
s/there/they/, s/truse/trust/,

Comment 17 Dave Allan 2011-05-05 02:06:51 UTC
Dan, I'm going to close this as WORKSFORME, but of course if you don't see boxes behaving as you expect, please reopen.


Note You need to log in before you can comment on or make changes to this bug.