diff mbox

ima: Fix warn potential negative subtraction from max

Message ID 1513871754-13943-1-git-send-email-gomonovych@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vasyl Gomonovych Dec. 21, 2017, 3:55 p.m. UTC
Found by smatch:
security/integrity/ima/ima_queue.c:122 ima_add_digest_entry() warn:
potential negative subtraction from max '(~0)- size'

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
---
 security/integrity/ima/ima_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Serge E. Hallyn Dec. 21, 2017, 6 p.m. UTC | #1
Quoting Vasyl Gomonovych (gomonovych@gmail.com):
> Found by smatch:
> security/integrity/ima/ima_queue.c:122 ima_add_digest_entry() warn:
> potential negative subtraction from max '(~0)- size'
> 
> Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
> ---
>  security/integrity/ima/ima_queue.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
> index a02a86d51102..446018478b81 100644
> --- a/security/integrity/ima/ima_queue.c
> +++ b/security/integrity/ima/ima_queue.c
> @@ -116,7 +116,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry,
>  	}
>  
>  	if (binary_runtime_size != ULONG_MAX) {
> -		int size;
> +		unsigned int size;

Hm, but get_binary_runtime_size() returns an int.

>  
>  		size = get_binary_runtime_size(entry);
>  		binary_runtime_size = (binary_runtime_size < ULONG_MAX - size) ?
> -- 
> 1.9.1
diff mbox

Patch

diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
index a02a86d51102..446018478b81 100644
--- a/security/integrity/ima/ima_queue.c
+++ b/security/integrity/ima/ima_queue.c
@@ -116,7 +116,7 @@  static int ima_add_digest_entry(struct ima_template_entry *entry,
 	}
 
 	if (binary_runtime_size != ULONG_MAX) {
-		int size;
+		unsigned int size;
 
 		size = get_binary_runtime_size(entry);
 		binary_runtime_size = (binary_runtime_size < ULONG_MAX - size) ?