linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Zelenoff <antonz@parallels.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "linux-watchdog@vger.kernel.org" <linux-watchdog@vger.kernel.org>,
	"wim@iguana.be" <wim@iguana.be>
Subject: Re: [RFC 0/3] watchdog: do not allow reboot without CAP_SYS_BOOT set
Date: Sat, 9 Jun 2012 19:28:35 +0400	[thread overview]
Message-ID: <4FD36BA3.4090607@parallels.com> (raw)
In-Reply-To: <4FD263A6.4020800@redhat.com>

Thanks for the detailed explanation. Ok, let all stay as is, you are 
right :)

9/06/12 12:42 AM, Hans de Goede пишет:
>>>> The CAP_SYS_BOOT capability required to reboot hardware node. But watchdog
>>>> writers are not checked for this capability. So, the process may reboot
>>>> hardware node even if it has no any capabilities to do it.
>>>
>>> Hmm, I can imagine people explicitly doing a chown on /dev/watchdog, to allow
>>> some non root running, critical from a service availability pov, process to
>>> open it and ping it.
>>>
>>> The suggest change would mean for most standard linux distributions, that
>>> a process opening /dev/watchdog now must run as root, even if the rights
>>> of /dev/watchdog allow a process to open it.
>> Hmm. I've missed it ) The patches may be modified to skip capabilities check
>> when watchdog opened from non root user.
>
> That makes no sense, if you add a capability check you should *always*
> check that capability.
>
>>
>>
>>> Also since you add the check on open, not on specific syscalls you are
>>> adding extra security checks to the open path. Now users are trained when
>>> open() fails with -EPERM to check
>>> 1: Standard unix file rights
>>> 2: For selinux denials
>>>
>>> Adding a third way to make open() fail with -EPERM is not going to make
>>> sysadmins very happy, esp. since this will not have any special logging
>>> to make the cause clear (unlike selinux).
>> Add log message is not problem too. The EPERM error got from other places,
>> where this capability checked. May be you can suggest better error code?
>>
>
> The error code is fine, if we are going to add a capability check
> logging if things fail on it is probably a very good idea.
>
>>> Moreover, since you add the check to open, what does it buy us over
>>> normal file-permissions? We already have a perfectly fine way to limit
>>> access to the watchdog device, namely standard unix file permissions,
>>> needing to fiddle with both file permissions and capabilities to allow
>>> a non root process to open /dev/watchdog is not making things easier,
>>> while at the same time not adding any value, since no extra granularity
>>> wrt security is gained.
>> Hm, so for what capabilities were created if standard permissions are good enough?
>
> Because a lot of actions require a process to have root rights, and the whole
> idea of capabilities is to allow a process to do something like
> say build raw network packets (ie ping) without requiring full root, ie
> normally ping will be:
> -rwsr-xr-x. 1 root root 40912 Jan 25 20:52 /usr/bin/ping
>
> However with capabilities ping will be:
> [hans@shalem ~]$ ls -l /usr/bin/ping
> -rwxr-xr-x. 1 root root 40912 Jan 25 20:52 /usr/bin/ping
> [hans@shalem ~]$ getcap /usr/bin/ping
> /usr/bin/ping = cap_net_raw+ep
>
> So if as a normal user you now run ping, the ping process does not get
> elevated to the full privileges of root (note it is not suid root),
> the only privilege elevation it gets is gaining the CAP_NET_RAW
> capability.
>
>   > Reason of this patchset is to guard one more way to reboot hardware node in same manner as it does in other places, because now root process without this capability set can write something to watchdog device and after some timeout the hardware reboots. May be my way is wrong, but this looks like a small security hole when non authorized process do things that it should not be able to do.
>
> I can see where you're coming from, but having a process run as root,
> but with some capabilites removed, is not how capabilities are normally
> used. The whole idea is not to run the process as root as all, and instead
> only give it the capabilities it needs. Also note that even with stripped
> capabilities running as root pretty much means full system access anyways,
> ie a program as root can do the following without needing any special
> capabilities (AFAIK): create a copy of /bin/sh (the copy will be owned by
> root), make it suid (this is allowed since the file is owned by the same
> uid as the process setting the suid bit), execute it -> full root.
>
> Regards,
>
> Hans
>


--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2012-06-09 15:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-08 13:09 [RFC 0/3] watchdog: do not allow reboot without CAP_SYS_BOOT set Tony Zelenoff
2012-06-08 13:09 ` [RFC 1/3] watchdog: check CAP_SYS_BOOT at watchdog open Tony Zelenoff
2012-06-08 13:09 ` [RFC 2/3] watchdog: move err initialization to place it used Tony Zelenoff
2012-06-08 13:09 ` [RFC 3/3] watchdog: connect watchdog_may_open to legacy code Tony Zelenoff
2012-06-08 14:28 ` [RFC 0/3] watchdog: do not allow reboot without CAP_SYS_BOOT set Hans de Goede
2012-06-08 15:12   ` Tony Zelenoff
2012-06-08 20:42     ` Hans de Goede
2012-06-09 15:28       ` Tony Zelenoff [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FD36BA3.4090607@parallels.com \
    --to=antonz@parallels.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@iguana.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).