aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2016-12-02 10:35:31 -0500
committerEric W. Biederman <ebiederm@xmission.com>2016-12-02 21:58:41 -0500
commit19339c251607a3defc7f089511ce8561936fee45 (patch)
treebc9111556f3cdf375c0a3530420ae9da0b578342
parentf84df2a6f268de584a201e8911384a2d244876e3 (diff)
Revert "evm: Translate user/group ids relative to s_user_ns when computing HMAC"
This reverts commit 0b3c9761d1e405514a551ed24d3ea89aea26ce14. Seth Forshee <seth.forshee@canonical.com> writes: > All right, I think 0b3c9761d1e405514a551ed24d3ea89aea26ce14 should be > reverted then. EVM is a machine-local integrity mechanism, and so it > makes sense that the signature would be based on the kernel's notion of > the uid and not the filesystem's. I added a commment explaining why the EVM hmac needs to be in the kernel's notion of uid and gid, not the filesystems to prevent remounting the filesystem and gaining unwaranted trust in files. Acked-by: Seth Forshee <seth.forshee@canonical.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r--security/integrity/evm/evm_crypto.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index bf663915412e..d7f282d75cc1 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -151,8 +151,16 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
151 memset(&hmac_misc, 0, sizeof(hmac_misc)); 151 memset(&hmac_misc, 0, sizeof(hmac_misc));
152 hmac_misc.ino = inode->i_ino; 152 hmac_misc.ino = inode->i_ino;
153 hmac_misc.generation = inode->i_generation; 153 hmac_misc.generation = inode->i_generation;
154 hmac_misc.uid = from_kuid(inode->i_sb->s_user_ns, inode->i_uid); 154 /* The hmac uid and gid must be encoded in the initial user
155 hmac_misc.gid = from_kgid(inode->i_sb->s_user_ns, inode->i_gid); 155 * namespace (not the filesystems user namespace) as encoding
156 * them in the filesystems user namespace allows an attack
157 * where first they are written in an unprivileged fuse mount
158 * of a filesystem and then the system is tricked to mount the
159 * filesystem for real on next boot and trust it because
160 * everything is signed.
161 */
162 hmac_misc.uid = from_kuid(&init_user_ns, inode->i_uid);
163 hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid);
156 hmac_misc.mode = inode->i_mode; 164 hmac_misc.mode = inode->i_mode;
157 crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc)); 165 crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc));
158 if (evm_hmac_attrs & EVM_ATTR_FSUUID) 166 if (evm_hmac_attrs & EVM_ATTR_FSUUID)