From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: Seth Forshee <seth.forshee@canonical.com>
Cc: Alban Crequy <alban.crequy@gmail.com>,
linux-integrity@vger.kernel.org,
"Eric W . Biederman" <ebiederm@xmission.com>,
dmitry.kasatkin@gmail.com, Sascha Hauer <s.hauer@pengutronix.de>,
Alban Crequy <alban@kinvolk.io>,
dongsu@kinvolk.io
Subject: Re: [PATCH] ima: define a new policy option named "force"
Date: Wed, 10 Jan 2018 09:48:02 -0500 [thread overview]
Message-ID: <1515595682.5739.44.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180110144418.GB4546@ubuntu-xps13>
On Wed, 2018-01-10 at 08:44 -0600, Seth Forshee wrote:
> On Wed, Jan 10, 2018 at 09:39:10AM -0500, Mimi Zohar wrote:
> > On Wed, 2018-01-10 at 15:13 +0100, Alban Crequy wrote:
> > > > There are times instead of relying on previously cached status
> > > > information we want to force the file to be re-measured, re-appraised,
> > > > and re-audited.
> > > >
> > > > This patch defines a new policy option named "force", which forces
> > > > files to be re-measured, re-appraised or re-audited.
> > > >
> > > > Signed-off-by: Mimi Zohar <zohar@xxxxxxxxxxxxxxxxxx>
> > >
> > > Tested-by: Alban Crequy <alban@kinvolk.io>
> >
> > Thanks! The builtin policies should be updated to require force for
> > fuse filesystems. I was expecting to receive patches (from Seth) to
> > update the builtin policies and upstream them together.
>
> Yes, I was working on a patch but need to update/test it. Was planning
> to do that a few weeks ago but then other things came up, hoping I can
> get back to it soon. But if someone beats me to it that's okay too :-)
Thanks, just making sure you wouldn't object to someone else doing it ...
>
> >
> > >
> > > tl;dr: without the patch, the measurements don't get all the changes
> > > on FUSE. With the patch and when enabling the "force" option,
> > > ascii_runtime_measurements gets the updated measurements.
> > >
> > >
> > > Longer explanation:
This "Longer explanation" would make for a really good patch
description for changing the builtin policies.
Mimi
> > >
> > > The test I did was using a patched version of the memfs FUSE driver
> > > [1][2] and two very simple "hello-world" programs [4] (prog1 prints
> > > "hello world: 1" and prog2 prints "hello world: 2").
> > >
> > > I copy prog1 and prog2 in the fuse-memfs mount point, execute them and
> > > check the sha1 hash in
> > > "/sys/kernel/security/ima/ascii_runtime_measurements".
> > >
> > > My patch on the memfs FUSE driver added a backdoor command to serve
> > > prog1 when the kernel asks for prog2 or vice-versa. In this way, I can
> > > exec prog1 and get it to print "hello world: 2" without ever replacing
> > > the file via the VFS, so the kernel is not aware of the change.
> > >
> > > The test was done using Dongsu's branch "fuse-userns-v5-2" [3],
> > > including both this new force option and Sascha's patch ("ima: Use
> > > i_version only when filesystem supports it").
> > >
> > >
> > > Step by step test procedure:
> > >
> > > 1. Mount the memfs FUSE using [2]:
> > > rm -f /tmp/memfs-switch* ; memfs -L DEBUG /mnt/memfs
> > >
> > > 2. Copy prog1 and prog2 using [4]
> > > cp prog1 /mnt/memfs/prog1
> > > cp prog2 /mnt/memfs/prog2
> > >
> > > 3. Lookup the files and let the FUSE driver to keep the handles open:
> > > dd if=/mnt/memfs/prog1 bs=1 | (read -n 1 x ; sleep 3600 ) &
> > > dd if=/mnt/memfs/prog2 bs=1 | (read -n 1 x ; sleep 3600 ) &
> > >
> > > 4. Check the 2 programs work correctly:
> > > $ /mnt/memfs/prog1
> > > hello world: 1
> > > $ /mnt/memfs/prog2
> > > hello world: 2
> > >
> > > 5. Check the measurements for prog1 and prog2:
> > > $ sudo cat /sys/kernel/security/ima/ascii_runtime_measurements|grep
> > > /mnt/memfs/prog
> > > 10 7ac5aed52061cb09120e977c6d04ee5c7b11c371 ima-ng
> > > sha1:ac14c9268cd2811f7a5adea17b27d84f50e1122c /mnt/memfs/prog1
> > > 10 9acc17a9a32aec4a676b8f6558e17a3d6c9a78e6 ima-ng
> > > sha1:799cb5d1e06d5c37ae7a76ba25ecd1bd01476383 /mnt/memfs/prog2
> > >
> > > 6. Use the backdoor command in my patched memfs to redirect file
> > > operations on file handle 3 to file handle 2:
> > > rm -f /tmp/memfs-switch* ; touch /tmp/memfs-switch-3-2
> > >
> > > 7. Check how the FUSE driver serves different content for the files:
> > > $ /mnt/memfs/prog1
> > > hello world: 2
> > > $ /mnt/memfs/prog2
> > > hello world: 2
> > >
> > > 8. Check the measurements:
> > > sudo cat /sys/kernel/security/ima/ascii_runtime_measurements|grep
> > > /mnt/memfs/prog
> > >
> > > Without the patches, on a vanilla kernel, there are no new
> > > measurements, despite the FUSE driver having served different
> > > executables. Same thing with the patch but without enabling the new
> > > force option.
> > >
> > > However, with the "force" option enabled, I can see additional
> > > measurements for prog1 and prog2 with the hashes reversed when the
> > > FUSE driver served the alternative content.
> > >
> > >
> > > [1] https://github.com/bbengfort/memfs
> > > [2] https://github.com/kinvolk/memfs/commits/alban/switch-files
> > > [3] https://github.com/kinvolk/linux/commits/dongsu/fuse-userns-v5-2
> > > [4] https://github.com/kinvolk/fuse-userns-patches/commit/cf1f5750cab0
> > >
> >
>
next prev parent reply other threads:[~2018-01-10 14:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 14:13 [PATCH] ima: define a new policy option named "force" Alban Crequy
2018-01-10 14:39 ` Mimi Zohar
2018-01-10 14:44 ` Seth Forshee
2018-01-10 14:48 ` Mimi Zohar [this message]
2018-01-11 13:59 ` Alban Crequy
-- strict thread matches above, loose matches on Subject: below --
2017-12-08 18:12 Mimi Zohar
2017-12-10 22:07 ` James Morris
2017-12-11 13:12 ` Mimi Zohar
2017-12-11 13:30 ` Seth Forshee
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=1515595682.5739.44.camel@linux.vnet.ibm.com \
--to=zohar@linux.vnet.ibm.com \
--cc=alban.crequy@gmail.com \
--cc=alban@kinvolk.io \
--cc=dmitry.kasatkin@gmail.com \
--cc=dongsu@kinvolk.io \
--cc=ebiederm@xmission.com \
--cc=linux-integrity@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=seth.forshee@canonical.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 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.