<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/security/integrity, branch v2.6.37</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.37</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.37'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2011-01-04T00:36:33Z</updated>
<entry>
<title>ima: fix add LSM rule bug</title>
<updated>2011-01-04T00:36:33Z</updated>
<author>
<name>Mimi Zohar</name>
<email>zohar@linux.vnet.ibm.com</email>
</author>
<published>2011-01-03T22:59:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=867c20265459d30a01b021a9c1e81fb4c5832aa9'/>
<id>urn:sha1:867c20265459d30a01b021a9c1e81fb4c5832aa9</id>
<content type='text'>
If security_filter_rule_init() doesn't return a rule, then not everything
is as fine as the return code implies.

This bug only occurs when the LSM (eg. SELinux) is disabled at runtime.

Adding an empty LSM rule causes ima_match_rules() to always succeed,
ignoring any remaining rules.

 default IMA TCB policy:
  # PROC_SUPER_MAGIC
  dont_measure fsmagic=0x9fa0
  # SYSFS_MAGIC
  dont_measure fsmagic=0x62656572
  # DEBUGFS_MAGIC
  dont_measure fsmagic=0x64626720
  # TMPFS_MAGIC
  dont_measure fsmagic=0x01021994
  # SECURITYFS_MAGIC
  dont_measure fsmagic=0x73636673

  &lt; LSM specific rule &gt;
  dont_measure obj_type=var_log_t

  measure func=BPRM_CHECK
  measure func=FILE_MMAP mask=MAY_EXEC
  measure func=FILE_CHECK mask=MAY_READ uid=0

Thus without the patch, with the boot parameters 'tcb selinux=0', adding
the above 'dont_measure obj_type=var_log_t' rule to the default IMA TCB
measurement policy, would result in nothing being measured.  The patch
prevents the default TCB policy from being replaced.

Signed-off-by: Mimi Zohar &lt;zohar@us.ibm.com&gt;
Cc: James Morris &lt;jmorris@namei.org&gt;
Acked-by: Serge Hallyn &lt;serge.hallyn@canonical.com&gt;
Cc: David Safford &lt;safford@watson.ibm.com&gt;
Cc: &lt;stable@kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: fix the ToMToU logic</title>
<updated>2010-10-26T18:37:19Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:42:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bade72d607c4eb1b1d6c7852c493b75f065a56b5'/>
<id>urn:sha1:bade72d607c4eb1b1d6c7852c493b75f065a56b5</id>
<content type='text'>
Current logic looks like this:

        rc = ima_must_measure(NULL, inode, MAY_READ, FILE_CHECK);
        if (rc &lt; 0)
                goto out;

        if (mode &amp; FMODE_WRITE) {
                if (inode-&gt;i_readcount)
                        send_tomtou = true;
                goto out;
        }

        if (atomic_read(&amp;inode-&gt;i_writecount) &gt; 0)
                send_writers = true;

Lets assume we have a policy which states that all files opened for read
by root must be measured.

Lets assume the file has permissions 777.

Lets assume that root has the given file open for read.

Lets assume that a non-root process opens the file write.

The non-root process will get to ima_counts_get() and will check the
ima_must_measure().  Since it is not supposed to measure it will goto
out.

We should check the i_readcount no matter what since we might be causing
a ToMToU voilation!

This is close to correct, but still not quite perfect.  The situation
could have been that root, which was interested in the mesurement opened
and closed the file and another process which is not interested in the
measurement is the one holding the i_readcount ATM.  This is just overly
strict on ToMToU violations, which is better than not strict enough...

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: explicit IMA i_flag to remove global lock on inode_delete</title>
<updated>2010-10-26T18:37:19Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:42:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=196f518128d2ee6e0028b50e6fec0313640db142'/>
<id>urn:sha1:196f518128d2ee6e0028b50e6fec0313640db142</id>
<content type='text'>
Currently for every removed inode IMA must take a global lock and search
the IMA rbtree looking for an associated integrity structure.  Instead
we explicitly mark an inode when we add an integrity structure so we
only have to take the global lock and do the removal if it exists.

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: drop refcnt from ima_iint_cache since it isn't needed</title>
<updated>2010-10-26T18:37:19Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:42:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=64c62f06bef8314a64d3189cb9c78062d54169b3'/>
<id>urn:sha1:64c62f06bef8314a64d3189cb9c78062d54169b3</id>
<content type='text'>
Since finding a struct ima_iint_cache requires a valid struct inode, and
the struct ima_iint_cache is supposed to have the same lifetime as a
struct inode (technically they die together but don't need to be created
at the same time) we don't have to worry about the ima_iint_cache
outliving or dieing before the inode.  So the refcnt isn't useful.  Just
get rid of it and free the structure when the inode is freed.

Signed-off-by: Eric Paris &lt;eapris@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: only allocate iint when needed</title>
<updated>2010-10-26T18:37:18Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:42:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bc7d2a3e66b40477270c3cbe3b89b47093276e7a'/>
<id>urn:sha1:bc7d2a3e66b40477270c3cbe3b89b47093276e7a</id>
<content type='text'>
IMA always allocates an integrity structure to hold information about
every inode, but only needed this structure to track the number of
readers and writers currently accessing a given inode.  Since that
information was moved into struct inode instead of the integrity struct
this patch stops allocating the integrity stucture until it is needed.
Thus greatly reducing memory usage.

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: move read counter into struct inode</title>
<updated>2010-10-26T18:37:18Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:41:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a178d2027d3198b0a04517d764326ab71cd73da2'/>
<id>urn:sha1:a178d2027d3198b0a04517d764326ab71cd73da2</id>
<content type='text'>
IMA currently allocated an inode integrity structure for every inode in
core.  This stucture is about 120 bytes long.  Most files however
(especially on a system which doesn't make use of IMA) will never need
any of this space.  The problem is that if IMA is enabled we need to
know information about the number of readers and the number of writers
for every inode on the box.  At the moment we collect that information
in the per inode iint structure and waste the rest of the space.  This
patch moves those counters into the struct inode so we can eventually
stop allocating an IMA integrity structure except when absolutely
needed.

This patch does the minimum needed to move the location of the data.
Further cleanups, especially the location of counter updates, may still
be possible.

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: use i_writecount rather than a private counter</title>
<updated>2010-10-26T18:37:18Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:41:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b9593d309d17c57e9ddc3934d641902533896ca9'/>
<id>urn:sha1:b9593d309d17c57e9ddc3934d641902533896ca9</id>
<content type='text'>
IMA tracks the number of struct files which are holding a given inode
readonly and the number which are holding the inode write or r/w.  It
needs this information so when a new reader or writer comes in it can
tell if this new file will be able to invalidate results it already made
about existing files.

aka if a task is holding a struct file open RO, IMA measured the file
and recorded those measurements and then a task opens the file RW IMA
needs to note in the logs that the old measurement may not be correct.
It's called a "Time of Measure Time of Use" (ToMToU) issue.  The same is
true is a RO file is opened to an inode which has an open writer.  We
cannot, with any validity, measure the file in question since it could
be changing.

This patch attempts to use the i_writecount field to track writers.  The
i_writecount field actually embeds more information in it's value than
IMA needs but it should work for our purposes and allow us to shrink the
struct inode even more.

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: use inode-&gt;i_lock to protect read and write counters</title>
<updated>2010-10-26T18:37:18Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:41:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ad16ad00c34d3f320a5876b3d711ef6bc81362e1'/>
<id>urn:sha1:ad16ad00c34d3f320a5876b3d711ef6bc81362e1</id>
<content type='text'>
Currently IMA used the iint-&gt;mutex to protect the i_readcount and
i_writecount.  This patch uses the inode-&gt;i_lock since we are going to
start using in inode objects and that is the most appropriate lock.

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: convert internal flags from long to char</title>
<updated>2010-10-26T18:37:18Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:41:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=15aac676778f206b42c4d7782b08f89246680485'/>
<id>urn:sha1:15aac676778f206b42c4d7782b08f89246680485</id>
<content type='text'>
The IMA flags is an unsigned long but there is only 1 flag defined.
Lets save a little space and make it a char.  This packs nicely next to
the array of u8's.

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IMA: use unsigned int instead of long for counters</title>
<updated>2010-10-26T18:37:18Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-10-25T18:41:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=497f32337073a2da102c49a53779097b5394711b'/>
<id>urn:sha1:497f32337073a2da102c49a53779097b5394711b</id>
<content type='text'>
Currently IMA uses 2 longs in struct inode.  To save space (and as it
seems impossible to overflow 32 bits) we switch these to unsigned int.
The switch to unsigned does require slightly different checks for
underflow, but it isn't complex.

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Acked-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
