Skip to contentSkip to conversation

ima: fix showing large 'violations' or 'runtime_measurements_count'

PATCH Superseded Eric Biggers 2 participants 2 messages Sep 8, 2018 – Sep 22, 2018

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ima: fix showing large 'violations' or 'runtime_measurements_count'

From: Eric Biggers <[email protected]>

The 12 character temporary buffer is not necessarily long enough to hold a 'long' value. Increase it.

---
 security/integrity/ima/ima_fs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
security/integrity/ima/ima_fs.c +3 -3
index fe0ede883557..9e239b1dea2f 100644
@@ -42,14 +42,14 @@ static int __init default_canonical_fmt_setup(char *str)
 __setup("ima_canonical_fmt", default_canonical_fmt_setup);
 
 static int valid_policy = 1;
-#define TMPBUFLEN 12
+
 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
 				     loff_t *ppos, atomic_long_t *val)
 {
-	char tmpbuf[TMPBUFLEN];
+	char tmpbuf[32];
 	ssize_t len;
 
-	len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
+	len = scnprintf(tmpbuf, sizeof(tmpbuf), "%li\n", atomic_long_read(val));
 	return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
 }
 
Signature · 1 line
2.19.0.rc2.392.g5ba43deb5a-goog
maintainer
#1 lore raw
Quoted 15 lines · Eric Biggers

From: Eric Biggers <[email protected]>

The 12 character temporary buffer is not necessarily long enough to hold a 'long' value. Increase it

---
 security/integrity/ima/ima_fs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
security/integrity/ima/ima_fs.c +0 -0
index fe0ede883557..9e239b1dea2f 100644

security/integrity/ima/ima_fs.c static int __init default_canonical_fmt_setup(char *str) · line 49

Quoted 10 lines
security/integrity/ima/ima_fs.c +2 -2
@@ -42,14 +42,14 @@ static int __init default_canonical_fmt_setup(char *str)
 __setup("ima_canonical_fmt", default_canonical_fmt_setup);
 
 static int valid_policy = 1;
-#define TMPBUFLEN 12
+
 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
 				     loff_t *ppos, atomic_long_t *val)
 {
-	char tmpbuf[TMPBUFLEN];
+	char tmpbuf[32];

The maximum string size needed to represent a long is not 32, even on a 64 bit system. 32 bytes is fine, but please comment this.

Quoted 7 lines
security/integrity/ima/ima_fs.c +1 -1
 	ssize_t len;
 
-	len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
+	len = scnprintf(tmpbuf, sizeof(tmpbuf), "%li\n", atomic_long_read(val));
 	return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
 }