* [PATCH] ima: Fix warn potential negative subtraction from max
@ 2017-12-21 15:55 Vasyl Gomonovych
2017-12-21 18:00 ` Serge E. Hallyn
0 siblings, 1 reply; 3+ messages in thread
From: Vasyl Gomonovych @ 2017-12-21 15:55 UTC (permalink / raw)
To: linux-security-module
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;
size = get_binary_runtime_size(entry);
binary_runtime_size = (binary_runtime_size < ULONG_MAX - size) ?
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info@ http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] ima: Fix warn potential negative subtraction from max
2017-12-21 15:55 [PATCH] ima: Fix warn potential negative subtraction from max Vasyl Gomonovych
@ 2017-12-21 18:00 ` Serge E. Hallyn
2017-12-21 21:54 ` [PATCH v2] " Vasyl Gomonovych
0 siblings, 1 reply; 3+ messages in thread
From: Serge E. Hallyn @ 2017-12-21 18:00 UTC (permalink / raw)
To: linux-security-module
Quoting Vasyl Gomonovych (gomonovych at 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
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] ima: Fix warn potential negative subtraction from max
2017-12-21 18:00 ` Serge E. Hallyn
@ 2017-12-21 21:54 ` Vasyl Gomonovych
0 siblings, 0 replies; 3+ messages in thread
From: Vasyl Gomonovych @ 2017-12-21 21:54 UTC (permalink / raw)
To: linux-security-module
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>
---
This minor change remove smatch warning but
I don't think that before change it was vulnerable,
motivation for this patch was smatch report.
Changelog:
- v2: change get_binary_runtime_size return type
security/integrity/ima/ima_queue.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
index a02a86d51102..3d5f981b8453 100644
--- a/security/integrity/ima/ima_queue.c
+++ b/security/integrity/ima/ima_queue.c
@@ -74,9 +74,9 @@ static struct ima_queue_entry *ima_lookup_digest_entry(u8 *digest_value,
* binary_runtime_measurement list entry, which contains a
* couple of variable length fields (e.g template name and data).
*/
-static int get_binary_runtime_size(struct ima_template_entry *entry)
+static unsigned int get_binary_runtime_size(struct ima_template_entry *entry)
{
- int size = 0;
+ unsigned int size = 0;
size += sizeof(u32); /* pcr */
size += sizeof(entry->digest);
@@ -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) ?
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info@ http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-21 21:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-21 15:55 [PATCH] ima: Fix warn potential negative subtraction from max Vasyl Gomonovych
2017-12-21 18:00 ` Serge E. Hallyn
2017-12-21 21:54 ` [PATCH v2] " Vasyl Gomonovych
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).