Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 87745 - /dev permissions from tmpfs (udev) world writable
Summary: /dev permissions from tmpfs (udev) world writable
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-02 23:08 UTC by Jordan
Modified: 2005-05-14 13:00 UTC (History)
0 users

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 Jordan 2005-04-02 23:08:09 UTC
Alright so the other day I go to jokingly cat /dev/zero > /dev/hda (as a normal user) so I can go paste the permission denied as a joke, forgetting that it's /dev/sda on my computer (SATA.) Oddly enough, it works, and I quickly ctrl-c wondering what happened. A 260mb file named "hda" inside /dev created by a normal unprived user.

I do some investigation into the matter.
ls -ld /dev
drwxrwxrwt  17 root root 3500 Apr  3 01:52 /dev

/dev is marked rwxrwxrwt. I wonder why? Someone else was just configuring udev in a chat and theirs is rwxr-xr-x. The difference? They're using ramfs. I am using tmpfs. Tmpfs's default permissions are apparently 1777. Adding an -o mode=755 to the line in /sbin/rc should probably fix this, but I'm not even sure if it's a problem or not. The potential risk, seems to be that you could potentially max out your memory AND swap (seeing as tmpfs can swap unlike ramfs) by doing this, which would not be very good at all. Another thing is that there's no max limit option passed to mount when mounting tmpfs, so that also allows this to happen, though of course if the first issue is fixed only root could potentially cause this. Switching to ramfs makes the permissions rwxr-xr-x for me, so it's not just this other person with different permissions.

Of course it's not very likely someone would do this, and a normal user cannot remove or edit existing things in /dev, just create new, so this isn't a super-major issue. However, it does seem like this is incorrect behavior.

I'm running a pure udev system with udev 056 and baselayout 1.11.10-r5.

/dev/shm potentially has this same problem as it's using tmpfs and has the same permissions, but I'm not really sure what permissions /dev/shm is supposed to have.
Comment 1 SpanKY gentoo-dev 2005-05-12 20:38:19 UTC
not a udev issue
Comment 2 SpanKY gentoo-dev 2005-05-12 20:39:06 UTC
try this:
# ebuild /usr/portage/sys-apps/baselayout/baselayout-1.11.11-r3.ebuild clean unpack compile install
# ls -l /var/tmp/portage/baselayout-1.11.11-r3/image/
Comment 3 Jordan 2005-05-12 20:44:08 UTC
$ ls -l /var/tmp/portage/baselayout-1.11.11-r3/image/
total 24
drwxr-xr-x  2 root root 4096 May 12 23:41 bin
drwxr-xr-x  2 root root 4096 May 12 23:41 dev
drwxr-xr-x  9 root root 4096 May 12 23:41 etc
drwxr-xr-x  3 root root 4096 May 12 23:41 lib
drwxr-xr-x  2 root root 4096 May 12 23:41 sbin
drwxr-xr-x  5 root root 4096 May 12 23:41 usr

it appears that dev is fine there...
Comment 4 Jordan 2005-05-12 20:46:48 UTC
oh yeah I should probably mention that I'm using baselayout 1.11.11-r3 now, I usually keep my system up to date. And I have rebooted since then, so /dev has been mounted using the latest baselayout, this problem still persists.
Comment 5 SpanKY gentoo-dev 2005-05-12 21:14:41 UTC
portage does not change permissions on existing directories so you will have to fix them yourself ...

try doing `chmod 755 /dev` and `chmod 1777 /tmp`

then reboot and see if permissions are still screwed
Comment 6 Jakub Moc (RETIRED) gentoo-dev 2005-05-13 01:34:23 UTC
Tried here and yup, it reverts back to 1777 after reboot. 
Comment 7 SpanKY gentoo-dev 2005-05-13 07:20:26 UTC
sounds good
Comment 8 Jordan 2005-05-13 10:04:26 UTC
how is this resolved? he said it reverts back to 1777 after reboot, which indeed it does. I tried it.
Comment 9 SpanKY gentoo-dev 2005-05-13 11:46:04 UTC
what is 'it' ?  we were talking about two dirs (dev and tmp), /tmp is *supposed* to be 1777
Comment 10 Jordan 2005-05-13 11:49:39 UTC
I don't get why /tmp is even being mentioned. My /tmp never had incorrect permissions in the first place. I was talking about tmpfs, however. My /dev permissions remain 1777 after reboot, despite the chmod, which I figured would happen, seeing as /dev is being mounted with tmpfs, which is not having it's permissions set.
Comment 11 SpanKY gentoo-dev 2005-05-13 12:23:57 UTC
i thought you mentioned /tmp somewhere

you neglected to provide `emerge info` like the bug report page said to so i dont know what kernel you're running ...
Comment 12 Jordan 2005-05-13 12:31:33 UTC
# emerge info
Portage 2.0.51.21-r1 (default-linux/x86/2005.0, gcc-3.4.3-20050110, glibc-2.3.5-r0, 2.6.11-ck7-r1 i686)
=================================================================
System uname: 2.6.11-ck7-r1 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz
Gentoo Base System version 1.6.11
dev-lang/python:     2.3.5
sys-apps/sandbox:    1.2.7
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.5
sys-devel/binutils:  2.15.92.0.2-r8
sys-devel/libtool:   1.5.16
virtual/os-headers:  2.6.11
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O3 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=pentium4 -O3 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://mirror.datapipe.net/gentoo http://gentoo.mirrors.tds.net/gentoo ftp://gentoo.netnitco.net/pub/mirrors/gentoo/source/ http://gentoo.oregonstate.edu"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
USE="x86 X aalib acpi alsa apm artworkextra avi bitmap-fonts cdr crypt cups curl dvd dvdr emboss encode esd fam ffmpeg flac foomaticdb fortran gdbm gif gimpprint gnome gpm gstreamer gtk gtk2 guile imagemagick ipv6 java jpeg ldap libg++ libwww lirc mad mikmod mmx mmx2 mozilla mp3 mpeg ncurses network nls nptl nptlonly nvidia offensive ogg oggvorbis opengl oss pam pango pdflib perl png ppds python quicktime readline real rtc samba sdl slang spell sse sse2 ssl tcltk tcpd tiff truetype truetype-fonts type1-fonts userlocales v4l v4l2 vorbis win32codecs xine xinerama xml2 xv xvmc zlib userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS


i only mentioned tmpfs, if you read my initial report you'll notice I state that adding -o mode=755 to the mount line in /sbin/rc fixes this. Also, I mention that /dev/shm potentially has the same issue, as both are mounted using tmpfs, which seems to have default permissions that are somewhat insecure...
Comment 13 SpanKY gentoo-dev 2005-05-13 12:57:26 UTC
/dev/shm is supposed to be world accessible

i'll update /sbin/rc to mount /dev by default with mode=755 as you suggested, and throw in some noexec/nosuid while i'm at it

the odd thing is that /dev is 755 on a bunch of my machines while some others are 1777 even though they are all mounted tmpfs

oh well, better to assume insanity and force sane settings
Comment 14 Jordan 2005-05-13 13:01:17 UTC
I'm curious now if perhaps the chmod had no effect because /dev was already mounted with tmpfs, and all the chmod did was change tmpfs's permissions. Maybe I should try booting to a livecd and seeing what /dev's permissions are? I'll do this now infact...
Comment 15 Jordan 2005-05-13 13:11:56 UTC
nope, unmounted /dev permissions were correct, so it's definitely tmpfs causing this.

It's very odd that it'd be different on some systems than others if all are using tmpfs, only thing that would make sense is kernel differences...

here's the relevant mount output just for reference...

udev on /dev type tmpfs (rw)
Comment 16 Jordan 2005-05-13 13:19:31 UTC
with some more investigation i notice my laptop which uses tmpfs has the correct permissions...yet this box doesn't...weird...It's using ck4 not ck7...i'm going to upgrade the kernel now and see if it changes...I doubt it will though, as checking my emerge log shows the time i reported this bug I was probably using ck3...unless 3 causes it and 4 doesn't and 7 does...I doubt it. Somethings weird is going on here...
Comment 17 Jakub Moc (RETIRED) gentoo-dev 2005-05-13 13:50:32 UTC
Comment #9: "It" is /dev of course, I miss how /tmp is relevant here... I have reproduced this on three Gentoo boxes so there must be a bug somewhere. It does not happen with ramfs. 
Comment 18 Jordan 2005-05-13 13:57:20 UTC
so maybe I was wrong...after updating my laptops kernel to ck7-r1 now /dev is showing up wrong...but I sort of doubt it's one of con's changes that causes this, I'm guessing it's one of the point-point-point releases or whatever they're called which con includes in his latest releases...
Comment 19 Jakub Moc (RETIRED) gentoo-dev 2005-05-13 14:02:24 UTC
# mkdir /mnt/test
# mount --bind / /mnt/test
# ls -la /mnt/test/ | grep dev

drwxr-xr-x   2 root root  120 Apr 16 17:43 dev

Running gentoo-sources-2.6.11-r6
Comment 20 SpanKY gentoo-dev 2005-05-14 13:00:37 UTC
ok, fixed in cvs, will be in baselayout-1.11.12