public inbox for linux-unionfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Salyzyn <salyzyn@android.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: linux-kernel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
	Jonathan Corbet <corbet@lwn.net>,
	"Eric W . Biederman" <ebiederm@xmission.com>,
	Amir Goldstein <amir73il@gmail.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	linux-unionfs@vger.kernel.org, linux-doc@vger.kernel.org,
	kernel-team@android.com
Subject: Re: [PATCH v8 2/2] overlayfs: override_creds=off option bypass creator_cred
Date: Thu, 8 Nov 2018 08:27:00 -0800	[thread overview]
Message-ID: <a2796740-acd4-d39d-d78c-1957894fe278@android.com> (raw)
In-Reply-To: <20181108155620.GA3663@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3712 bytes --]

On 11/08/2018 07:56 AM, Vivek Goyal wrote:
> On Tue, Nov 06, 2018 at 03:01:15PM -0800, Mark Salyzyn wrote:
>> By default, all access to the upper, lower and work directories is the
>> recorded mounter's MAC and DAC credentials.  The incoming accesses are
>> checked against the caller's credentials.
>>
>> If the principles of least privilege are applied, the mounter's
>> credentials might not overlap the credentials of the caller's when
>> accessing the overlayfs filesystem.  For example, a file that a lower
>> DAC privileged caller can execute, is MAC denied to the generally
>> higher DAC privileged mounter, to prevent an attack vector.
>>
>> We add the option to turn off override_creds in the mount options; all
>> subsequent operations after mount on the filesystem will be only the
>> caller's credentials.  The module boolean parameter and mount option
>> override_creds is also added as a presence check for this "feature",
>> existence of /sys/module/overlay/parameters/override_creds.
>>
>> It was not always this way.  Circa 4.4 there was no recorded mounter's
>> credentials, instead privileged access to upper or work directories
>> were temporarily increased to perform the operations.  The MAC
>> (selinux) policies were caller's in all cases.  override_creds=off
>> partially returns us to this older access model minus the insecure
>> temporary credential increases.
>
> So what will have to bunch of overlay operations now which require
> priviliges or additional capabilities. To make all that succeed,
> you will have to give those capabilities to processes accessing
> overlayfs. If yes, I am wondering how is that more secure. IOW,
> having to give these capabilities to all processes accessing
> fs as opposed to giving those capabilities to only mounter.
>
> You also mentioned that you want init to be least priviliged as
> it could be attacked. But now all the processses are priviliged
> and these could be attacked as well.
>
> The way I am looking at it as follows.
>
> - With current model, only mounter needs to have capabilities to
>    do some operations such as whiteout creation etc.
>
> - With override_creds=off, all services accessing overlayfs needs
>    to have increased priviliges.
>
> Is that not increasing attack surface. Previously, you will have to
> attach init and now you can get away by breaking one of the services.
>
> /me is wondering how does that increase security.
>
> Thanks
> Vivek
In Android's case, the only processes that are writing the files are 
themselves privileged, and "they" are actually only one process doing so 
that is not init, and has a non-overlapping set, so well controlled, 
different zones of privilege. The issue is that the privileges of the 
mounter does not allow read, search or execute in a large swath of the 
directories and files as it is not needed or desired, only the processes 
that are granted sepolicy to do so will be allowed in a non-overlapping 
fashion. In a vast majority of the daemons and applications, read only 
and execute only accesses, and executing a file is a transition to a new 
security domain with a completely different set of privileges.

init and others are not allowed to talk to the gpu, keyboard events, 
camera, audio or the keymaster security elements. Most processes are 
not, yet libraries and Hardware Abstraction Layers, and executed daemons 
are. None of this requires the _any_ of the mounter's credentials and 
privileges; yet the files inside the filesystem are.

Think MAC (sepolicy) where every operation is individually labelled, not 
DAC (capabilities or traditional rwxrwxrwx) where privileges are in 
essence a hierarchy of security controls.

Sincerely -- Mark Salyzyn

[-- Attachment #2: Type: text/html, Size: 6712 bytes --]

  reply	other threads:[~2018-11-08 16:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 23:01 [PATCH v8 1/2] overlayfs: check CAP_DAC_READ_SEARCH before issuing exportfs_decode_fh Mark Salyzyn
2018-11-06 23:01 ` [PATCH v8 2/2] overlayfs: override_creds=off option bypass creator_cred Mark Salyzyn
2018-11-08 15:56   ` Vivek Goyal
2018-11-08 16:27     ` Mark Salyzyn [this message]
2018-11-08 20:01   ` Vivek Goyal
2018-11-08 21:28     ` Mark Salyzyn
2018-11-09  3:05       ` Amir Goldstein
2018-11-09 17:32         ` Mark Salyzyn
2018-11-10  7:51           ` Amir Goldstein
2018-11-12 18:15             ` Mark Salyzyn
2018-11-09 15:20       ` Vivek Goyal
2018-11-14 22:00   ` Vivek Goyal

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=a2796740-acd4-d39d-d78c-1957894fe278@android.com \
    --to=salyzyn@android.com \
    --cc=amir73il@gmail.com \
    --cc=corbet@lwn.net \
    --cc=ebiederm@xmission.com \
    --cc=kernel-team@android.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=rdunlap@infradead.org \
    --cc=sds@tycho.nsa.gov \
    --cc=vgoyal@redhat.com \
    /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