linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] evm: fix writing <securityfs>/evm overflow
@ 2021-04-29 19:53 Mimi Zohar
  2021-04-29 19:58 ` Stefan Berger
  0 siblings, 1 reply; 2+ messages in thread
From: Mimi Zohar @ 2021-04-29 19:53 UTC (permalink / raw)
  To: linux-integrity; +Cc: Mimi Zohar, Stefan Berger, linux-kernel

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>
---
 security/integrity/evm/evm_secfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c
index bbc85637e18b..0007d3362754 100644
--- a/security/integrity/evm/evm_secfs.c
+++ b/security/integrity/evm/evm_secfs.c
@@ -66,12 +66,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;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] evm: fix writing <securityfs>/evm overflow
  2021-04-29 19:53 [PATCH] evm: fix writing <securityfs>/evm overflow Mimi Zohar
@ 2021-04-29 19:58 ` Stefan Berger
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Berger @ 2021-04-29 19:58 UTC (permalink / raw)
  To: Mimi Zohar, linux-integrity; +Cc: linux-kernel


On 4/29/21 3:53 PM, Mimi Zohar wrote:
> 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>


Tested-by: Stefan Berger <stefanb@linux.ibm.com>

> ---
>   security/integrity/evm/evm_secfs.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c
> index bbc85637e18b..0007d3362754 100644
> --- a/security/integrity/evm/evm_secfs.c
> +++ b/security/integrity/evm/evm_secfs.c
> @@ -66,12 +66,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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-29 20:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 19:53 [PATCH] evm: fix writing <securityfs>/evm overflow Mimi Zohar
2021-04-29 19:58 ` Stefan Berger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).