All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
To: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: Linux Containers
	<containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>,
	Paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	"Eric W. Biederman"
	<ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
Subject: Re: [RFC][PATCH] Devices visibility container
Date: Mon, 24 Sep 2007 18:58:10 +0400	[thread overview]
Message-ID: <46F7D082.7090304@openvz.org> (raw)
In-Reply-To: <20070924143915.GA30195-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>

Serge E. Hallyn wrote:
> Quoting Pavel Emelyanov (xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org):
>> Hi.
>>
>> At KS we have pointed out the need in some container, that allows
>> to limit the visibility of some devices to task within it. I.e.
>> allow for /dev/null, /dev/zero etc, but disable (by default) some
>> IDE devices or SCSI discs and so on.
>>
>> Here's the beta of the container. Currently this only allows to
>> hide the _character_ devices only from the living tasks. To play 
>> with it you just create the container like this
>>
>>  # mount -t container none /cont/devs -o devices
>>  # mkdir /cont/devs/0
>>
>> it will have two specific files
>>
>>  # ls /cont/devs
>> devices.block  devices.char  notify_on_release  releasable  release_agent  tasks
>>
>> then move a task into it
>>
>>  # /bin/echo -n $$ > /cont/devs/0/tasks
>>
>> after this you won't be able to read from even /dev/zero
>>
>>  # hexdump /dev/zero 
>> hexdump: /dev/zero: No such device or address
>> hexdump: /dev/zero: Bad file descriptor
>>
>> meanwhile from another ssh session you will. You may allow access
>> to /dev/zero like this
>>
>>  # /bin/echo -n '+1:5' > /cont/devs/0/devices.char
>>
>> More generally, the '+<major>:<minor>' string grants access to
>> some device, and '-<major>:<minor>' disables one.
>>
>> The TODO list now looks like this:
>> * add the block devices support :) don't know how to make it yet;
>> * make /proc/devices show relevant info depending on who is
>>   reading it. currently even if major 1 is disabled for task,
>>   it will be listed in this file;
>> * make it possible to enable/disable not just individual major:minor
>>   pair, but something more flexible, e.g. major:* for all minors
>>   for given major or major:m1-m2 for minor range, etc;
>> * add the ability to restrict the read/write permissions for a 
>>   container. currently one may just control the visible-invisible
>>   state for a device in a container, but maybe just readable or
>>   just writable would be better.
>>
>> This patch is minimally tested, because I just want to know your
>> opinion on whether it worths developing the container in such a way or not.
> 
> Hmm,
> 
> I was thinking we would use LSM for this.  Mostly it should suffice
> to set up a reasonable /dev for the container to start with, and
> hook security_mknod() to prevent it creating devices not on it's

Are you talking about disabling of mknod() for some files? No, please
no! This will break many... no - MANY tools inside such a container.

> whitelist.  If deemed necessary, read/write could be controlled
> by hooking security_permission() and checking whether
> file->f_path.dentry->d_inode is a device on the read or write
> whitelist.
> 
> It would still be a device controller, so it can be composed with an
> ns_proxy controller, and the whitelist is modified using the
> devs_controller.whitelist file, but it registers a security_ops
> with these two hooks.
> 
> I haven't implemented that yet, though, whereas you already have code :)
> As for handling blkdevs with your code, would just hooking
> fs/block_dev.c:do_open() not work?  Or is that not what you are
> asking?

Well, placing a hook into needed functions is something that can
work, of course, but this is not something that community would like
to see, so I tried to integrate them deeply.

> thanks,
> -serge

  parent reply	other threads:[~2007-09-24 14:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-24  8:28 [RFC][PATCH] Devices visibility container Pavel Emelyanov
     [not found] ` <46F77523.9020001-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-09-24  9:55   ` Cedric Le Goater
     [not found]     ` <46F78982.2000901-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-09-24 11:47       ` Pavel Emelyanov
2007-09-24 14:39   ` Serge E. Hallyn
     [not found]     ` <20070924143915.GA30195-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-09-24 14:58       ` Pavel Emelyanov [this message]
     [not found]         ` <46F7D082.7090304-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-09-24 15:20           ` Serge E. Hallyn
     [not found]             ` <20070924152001.GB30195-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-09-24 15:31               ` Pavel Emelyanov
     [not found]                 ` <46F7D86D.3060106-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-09-24 15:51                   ` Serge E. Hallyn
     [not found]                     ` <20070924155139.GC30195-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-09-24 15:57                       ` Cedric Le Goater
     [not found]                         ` <46F7DE58.1020505-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-09-24 16:18                           ` Serge E. Hallyn
2007-09-24 15:32               ` Kirill Korotaev
     [not found]                 ` <46F7D8A6.8040303-3ImXcnM4P+0@public.gmane.org>
2007-09-24 16:53                   ` Serge E. Hallyn
2007-09-24 16:47   ` Eric W. Biederman
     [not found]     ` <m1r6kodn7t.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2007-09-25  7:48       ` Pavel Emelyanov
     [not found]         ` <46F8BD33.5040108-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-09-25 13:30           ` Eric W. Biederman
     [not found]             ` <m13ax2eut7.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2007-09-26 15:36               ` Dave Hansen
2007-09-26 19:09                 ` Eric W. Biederman
     [not found]                   ` <m1641xuttx.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2007-09-27 15:46                     ` Dave Hansen
2007-09-25 12:25       ` Cedric Le Goater
     [not found]         ` <46F8FE34.4020703-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-09-25 13:43           ` Eric W. Biederman
2007-09-25  7:53   ` Paul Menage
     [not found]     ` <6599ad830709250053m715a1848mf6c17a6dd321092-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-09-25  8:00       ` Pavel Emelyanov
     [not found]         ` <46F8C007.1090000-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-09-25 11:20           ` Cedric Le Goater

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=46F7D082.7090304@openvz.org \
    --to=xemul-gefaqzzx7r8dnm+yrofe0a@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
    --cc=menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.