Commit 19339c25 authored by Eric W. Biederman's avatar Eric W. Biederman

Revert "evm: Translate user/group ids relative to s_user_ns when computing HMAC"

This reverts commit 0b3c9761.

Seth Forshee <seth.forshee@canonical.com> writes:
> All right, I think 0b3c9761 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: default avatarSeth Forshee <seth.forshee@canonical.com>
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent f84df2a6
...@@ -151,8 +151,16 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode, ...@@ -151,8 +151,16 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
memset(&hmac_misc, 0, sizeof(hmac_misc)); memset(&hmac_misc, 0, sizeof(hmac_misc));
hmac_misc.ino = inode->i_ino; hmac_misc.ino = inode->i_ino;
hmac_misc.generation = inode->i_generation; hmac_misc.generation = inode->i_generation;
hmac_misc.uid = from_kuid(inode->i_sb->s_user_ns, inode->i_uid); /* The hmac uid and gid must be encoded in the initial user
hmac_misc.gid = from_kgid(inode->i_sb->s_user_ns, inode->i_gid); * namespace (not the filesystems user namespace) as encoding
* them in the filesystems user namespace allows an attack
* where first they are written in an unprivileged fuse mount
* of a filesystem and then the system is tricked to mount the
* filesystem for real on next boot and trust it because
* everything is signed.
*/
hmac_misc.uid = from_kuid(&init_user_ns, inode->i_uid);
hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid);
hmac_misc.mode = inode->i_mode; hmac_misc.mode = inode->i_mode;
crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc)); crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc));
if (evm_hmac_attrs & EVM_ATTR_FSUUID) if (evm_hmac_attrs & EVM_ATTR_FSUUID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment