]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
evm: fix writing <securityfs>/evm overflow
authorMimi Zohar <zohar@linux.ibm.com>
Mon, 26 Apr 2021 22:13:45 +0000 (18:13 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:53:21 +0000 (16:53 +0200)
[ Upstream commit 49219d9b8785ba712575c40e48ce0f7461254626 ]

EVM_SETUP_COMPLETE is defined as 0x80000000, which is larger than INT_MAX.
The "-fno-strict-overflow" compiler option properly prevents signaling
EVM that the EVM policy setup is complete.  Define and read an unsigned
int.

Fixes: f00d79750712 ("EVM: Allow userspace to signal an RSA key has been loaded")
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/integrity/evm/evm_secfs.c

index f93b688037b1b072e4359e95bbd832458e24a82e..d7f12ed19183710a3eaaa7dc57f04a28d9436af1 100644 (file)
@@ -68,12 +68,13 @@ static ssize_t evm_read_key(struct file *filp, char __user *buf,
 static ssize_t evm_write_key(struct file *file, const char __user *buf,
                             size_t count, loff_t *ppos)
 {
-       int i, ret;
+       unsigned int i;
+       int ret;
 
        if (!capable(CAP_SYS_ADMIN) || (evm_initialized & EVM_SETUP_COMPLETE))
                return -EPERM;
 
-       ret = kstrtoint_from_user(buf, count, 0, &i);
+       ret = kstrtouint_from_user(buf, count, 0, &i);
 
        if (ret)
                return ret;