Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 100115 - sys-fs/udev doesnt set proper group with partitions
Summary: sys-fs/udev doesnt set proper group with partitions
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High critical
Assignee: Greg Kroah-Hartman (RETIRED)
URL:
Whiteboard:
Keywords:
: 100116 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-24 06:58 UTC by apache
Modified: 2005-08-11 16:21 UTC (History)
2 users (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 apache 2005-07-24 06:58:31 UTC
udev sets permissions for partitions to root:root which is ok, but it sets
permissions for disks to root:disk. That means every ordinary user with group
disk can run commands like this:

cat /dev/hda /home/foobar/out.txt
dd if=/dev/zero of=/dev/hda

That should not be possible. If a program has a security hole and runs one of
this commands, it can damage the whole system without root permissions.

Problem is already discussed here:
http://forums.gentoo.org/viewtopic-p-2597592.html#2597592

Reproducible: Always
Steps to Reproduce:
Attention! Do not perform the following actions, just read it !

1. Login with a user in group disk
2. Run dd if=/dev/zero of=/dev/hda
3. Reinstall gentoo *g*
Comment 1 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-07-24 07:01:26 UTC
base-system please advise. 
Comment 2 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-07-24 07:04:06 UTC
*** Bug 100116 has been marked as a duplicate of this bug. ***
Comment 3 SpanKY gentoo-dev 2005-07-24 10:04:13 UTC
uhh, how is this a bug ?  dont add your users to the disk group, simple as that
Comment 4 apache 2005-07-24 10:17:29 UTC
Just read the following thread and you will understand why we filled that bug:

http://forums.gentoo.org/viewtopic-t-355069-postdays-0-postorder-asc-start-75.html
Comment 5 SpanKY gentoo-dev 2005-07-25 04:50:48 UTC
all i see there is discussion of whether using a disk group makes sense

that doesnt change the fact that if a misguided user added someone to the disk
group that's their own damned fault and really isnt a security issue
Comment 6 SpanKY gentoo-dev 2005-07-25 05:55:17 UTC
also, it's not like udev is doing anything new

if you review MAKEDEV you'll see that it uses root:disk 660 permissions too ...
that means this permissions setup has been this way for quite a long time
(pre-devfs and pre-udev)
Comment 7 Gergan Penkov 2005-07-25 08:08:22 UTC
but why? that's the question and why not apply it for all the partitions also
(as ubuntu does it)? and why one more group? what's the sense?
Comment 8 SpanKY gentoo-dev 2005-07-25 08:28:24 UTC
i think the fact that hda[0-9]* is not set to the disk group is a bug in udev

the rule that executes the devfs script doesnt seem to communicate properly thus
the group is set to the default root ...
Comment 9 Gergan Penkov 2005-07-25 08:36:36 UTC
Ok this makes more sense, I agree, that if the devs decide to use some scheme,
it should be supported. The problem was only the inconsistency of it, and
probably the missing documentation about it.
Comment 10 apache 2005-07-25 08:48:50 UTC
Ok, if there will be only one sheme for disks and partitions, thats fine for me.
But also an update to the documentations (manuals) with a warning about that
group   should not be forgotten. A warning in the next udev ebuild would be fine
too.
Comment 11 SpanKY gentoo-dev 2005-07-25 09:04:20 UTC
add a warning about something that has always been this way ?  if you go back to
even the Gentoo 1.2 release you'll see that the device nodes have always been
like this

i dont see the point in trying to 'protect' a user who screws around with system
groups and has no idea what they're doing ... plus i doubt they'd even see said
warning
Comment 12 Gergan Penkov 2005-07-25 09:22:56 UTC
I thought more of a document like this one
http://modular.fas.harvard.edu/docs/debian-packages/base-passwd/users-and-groups.html
I think it is not up-to-date or complete, but sth like this would be a nice
thing to have, with an explanation, when these groups are needed.
Comment 13 apache 2005-07-25 09:28:34 UTC
(In reply to comment #11)
> i dont see the point in trying to 'protect' a user who screws around with system
> groups and has no idea what they're doing ... plus i doubt they'd even see said
> warning

Sorry, but you sound like a MS official, if you don't press this button, you are
secure ...

Playing around with the system is the way most of us used to learn, beside there
are good documentations and howtos and if there is somewhere a warning about
that, they don't have to learn that through a damaged system (Although, most
will not realise that the failure was a action they have taken maybe months ago
when they installed their system and added their users to the group disk).

Comment 14 SpanKY gentoo-dev 2005-07-25 15:40:40 UTC
(In reply to comment #13)
> Sorry, but you sound like a MS official, if you don't press this button, you
> are secure ...

was there any real point to this comment ?  i didnt think so

if you want documentation on the different system groups, then file a new bug to
create one as part of the Gentoo doc project which covers *all* the groups ...
have assing it by putting in a warning about 1 group because some users did
something dumb like giving out group access to people they shouldnt have doesnt
make sense ... you can cause problems by giving out access with other groups,
not just disk

the only point of this bug now is to fix the devfs script so that all block
nodes are given disk group permissions
Comment 15 apache 2005-07-25 22:33:24 UTC
This is a copy&paste from the forum thread, maybe it's not that simple:

------------------------------------------
drphibes wrote:

bit of a flame war going on in that bug report ... so let's reason this out. i
have no problem removing disk from ordinary users' group lists. but, i need to
give them rw access to my usb writer /dev/dvd -> /dev/sr0 which udev currently
creates as root/disk w/perms 660. i note there is no dvd group in /etc/group,
but there is cdrom and cdrw. i suppose i could change the gid on sr0 to cdrw, or
add a 'dvd' group and use that gid, then grant dvd or cdrw membership to
ordinary users an be done with group disk as far as they are concerned. btw why
isn't there a 'dvd' group?

also i do think that the partition devices (e.g. hda[1-9]) and whole disk device
(e.g. hda) should be in the same group, WHATEVER that ends up being, i.e. disk
or root. it makes little sense to have them in different groups.
------------------------------------------
Comment 16 SpanKY gentoo-dev 2005-07-26 06:40:39 UTC
there is no dvd group because cdrw covers that

the fact that your scsi burner is setup as disk group instead of cdrw / cdrom
could just be another limitation in the devfs script / udev rules
Comment 17 Philip Kovacs 2005-07-26 07:16:32 UTC
hm... udev will not honor my local rule's GROUP="cdrw" specifier:

---10-local-udev.rules----
BUS=="scsi", KERNEL="sr[0-9]*", PROGRAM="/etc/udev/scripts/cdsymlinks.sh %k",
SYMLINK+="%c{1} %c{2} %c{3} %c{4} %c{5} %c{6}", NAME="%k", GROUP="cdrw"

it still creates the node under group disk.  my cdsymlinks.sh sr0 returns:
cdrom1 cdrw dvd dvdrw and those symlinks are created and pointing correctly to sr0.

Phil (drphibes)


Comment 18 Philip Kovacs 2005-07-26 07:21:53 UTC
forgot to mention i am using udev-063.  (i notice 064 is out of the oven)
Comment 19 Philip Kovacs 2005-07-28 08:53:58 UTC
greg, what's the word on comment #17?  should i file a separate bug for that, or
is there a way to accomplish it already?  i want to put sr0 into group cdrw
while keeping the convenient symlinks produced by cdsymlinks.sh.  
Comment 20 Greg Kroah-Hartman (RETIRED) gentoo-dev 2005-07-28 09:46:29 UTC
separate bug please.
Comment 21 Philip Kovacs 2005-07-28 10:26:09 UTC
bug# 100610 filed.
Comment 22 Greg Kroah-Hartman (RETIRED) gentoo-dev 2005-07-28 11:26:35 UTC
marking invalid, as this is the way things always have been.

if someone comes up with a solution, please feel free to reopen this.
Comment 23 SpanKY gentoo-dev 2005-07-28 12:08:39 UTC
gregkh: this bug is kind of a mess, but what it ended up being is this:

udev doesnt properly set disk group permissions on partitions ... so /dev/hda is
root:disk but /dev/hda1 and /dev/hda2 are root:root when they should be root:disk

it looks like a failing of the devfs script and/or what the udev rule expects it
to echo back to it
Comment 24 Greg Kroah-Hartman (RETIRED) gentoo-dev 2005-07-28 12:24:39 UTC
Ah, thanks for the summary.

Ok, found it.  I'll be slowly changing the udev rules file to be much
quicker and make udev take up less memory in the tmpfs partition.  Also, we will
get persistant device names for a lot of different subsystems, as was agreed
apon at OLS this year.

I'll fix this up when I get to the block devices, just want to take it slow for
now, so I don't break peoples boxes.

If you want, you can try adding the line:
SUBSYSTEM="block", GROUP="disk", MODE="0640"
which should solve this (I'll leave it to the reader to determine the best
place for this line...)
Comment 25 SpanKY gentoo-dev 2005-07-28 13:25:37 UTC
the way i 'fixed' it was updating the devfs script to echo ${MEDIA} twice ...
seemed to work well enough for me
Comment 26 Steve Arnold archtester gentoo-dev 2005-07-31 09:41:04 UTC
For Phil:  I think your rule should work if it comes *after* the main rules are 
applied.  This behavior has changed once or twice in the life of udev, but now 
I have my custom rules invoked last, and it seems to work...
Comment 27 Philip Kovacs 2005-07-31 21:52:28 UTC
steve, that's interesteing.  so you're suggesting a rules.d directory which
might include files named like this:

10-local-udev.rules  <- stuff that can or must fire before the 50 file
50-udev.rules
99-local-udev.rules  <- stuff that can or must fire after the 50 file
Comment 28 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-01 12:28:01 UTC
(In reply to comment #27)
> steve, that's interesteing.  so you're suggesting a rules.d directory which
> might include files named like this:
> 
> 10-local-udev.rules  <- stuff that can or must fire before the 50 file
> 50-udev.rules
> 99-local-udev.rules  <- stuff that can or must fire after the 50 file

No, if you read the manpage, you will see that only the first rule that sets
NAME gets used, but all others that do not touch NAME should (not sure from the
docs) stack I guess ... so if your rule sets NAME, it should go before, if not,
it should go after.

Greg, ps, this sorda might be confusing ... does the last MODE rule that apply
for some device apply, or the first?  And if the first sets both NAME and MODE,
does the second that sets both NAME and MODE get totally ignored, or just the
NAME bit ??

It might have been easier if the last MODE/NAME/GROUP/whatever would apply for
all cases, but I guess you guys know best :)
Comment 29 Greg Kroah-Hartman (RETIRED) gentoo-dev 2005-08-11 16:21:51 UTC
Last MODE and GROUP applies.

I'm closing this as it isn't really a bug anywhere...