Skip to contentSkip to conversation

apparmor: leverage audit_log_n_untrustedstring() when possible

PATCH In review Paul Moore 3 participants 6 messages Jul 17 – Jul 21

Subsystems (2)
lore
Share & tools
lore

Paul Moore

author maintainer
#0 lore raw

PATCH 1/1 apparmor: leverage audit_log_n_untrustedstring() when possible

Make use of the audit_log_n_untrustedstring() function to simplify the code in aa_label_xaudit().

---
 security/apparmor/label.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
security/apparmor/label.c +1 -4
index 3fd384d8c41a..a165cadf8249 100644
@@ -1743,10 +1743,7 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns,
 		str = (char *) label->hname;
 		len = strlen(str);
 	}
-	if (audit_string_contains_control(str, len))
-		audit_log_n_hex(ab, str, len);
-	else
-		audit_log_n_string(ab, str, len);
+	audit_log_n_untrustedstring(ab, str, len);
 
 	kfree(name);
 }
Signature · 1 line
2.55.0
author maintainer
#1 lore raw
Quoted 8 lines · Paul Moore

Make use of the audit_log_n_untrustedstring() function to simplify the code in aa_label_xaudit().

---
 security/apparmor/label.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Untested beyond a basic compile, but I noticed this while looking at something else (unrelated) and wanted to send it to the list before I forgot about it ...

Quoted 18 lines
security/apparmor/label.c +1 -5
index 3fd384d8c41a..a165cadf8249 100644
@@ -1743,10 +1743,7 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns,
                str = (char *) label->hname;
                len = strlen(str);
        }
-       if (audit_string_contains_control(str, len))
-               audit_log_n_hex(ab, str, len);
-       else
-               audit_log_n_string(ab, str, len);
+       audit_log_n_untrustedstring(ab, str, len);
 
        kfree(name);
 }
--

2.55.0

Signature · 1 line
paul-moore.com
author maintainer
#2 lore raw
Quoted 5 lines · Paul Moore
Quoted 4 lines · Paul Moore

Make use of the audit_log_n_untrustedstring() function to simplify the code in aa_label_xaudit().

Quoted 8 lines
Quoted 4 lines
---
 security/apparmor/label.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Untested beyond a basic compile, but I noticed this while looking at something else (unrelated) and wanted to send it to the list before I forgot about it ...

My apologies Georgia, I thought I had copied your email into the original posting but it appears I copied John's email twice into my posting script (which helpfully de-duped it).

Sorry about that.

Quoted 18 lines
Quoted 18 lines
security/apparmor/label.c +1 -5
index 3fd384d8c41a..a165cadf8249 100644
@@ -1743,10 +1743,7 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns,
                str = (char *) label->hname;
                len = strlen(str);
        }
-       if (audit_string_contains_control(str, len))
-               audit_log_n_hex(ab, str, len);
-       else
-               audit_log_n_string(ab, str, len);
+       audit_log_n_untrustedstring(ab, str, len);
 
        kfree(name);
 }
--

2.55.0

Signature · 1 line
paul-moore.com
Reviewed-by
#3 lore raw
Quoted 36 lines · Paul Moore
Quoted 5 lines · Paul Moore
Quoted 4 lines · Paul Moore

Make use of the audit_log_n_untrustedstring() function to simplify the code in aa_label_xaudit().

Quoted 8 lines
Quoted 4 lines
---
 security/apparmor/label.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Untested beyond a basic compile, but I noticed this while looking at something else (unrelated) and wanted to send it to the list before I forgot about it ...

My apologies Georgia, I thought I had copied your email into the original posting but it appears I copied John's email twice into my posting script (which helpfully de-duped it).

Sorry about that.

Quoted 14 lines
Quoted 14 lines
security/apparmor/label.c +1 -4
index 3fd384d8c41a..a165cadf8249 100644
@@ -1743,10 +1743,7 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns,
                str = (char *) label->hname;
                len = strlen(str);
        }
-       if (audit_string_contains_control(str, len))
-               audit_log_n_hex(ab, str, len);
-       else
-               audit_log_n_string(ab, str, len);
+       audit_log_n_untrustedstring(ab, str, len);
 
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
security/apparmor/label.c +0 -1
        kfree(name);
 }
--

2.55.0

--
paul-moore.com

maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Paul Moore
Quoted 4 lines · Paul Moore

Make use of the audit_log_n_untrustedstring() function to simplify the code in aa_label_xaudit().

unless you object I will pull this into the apparmor tree

Quoted 20 lines
---
  security/apparmor/label.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
security/apparmor/label.c +1 -4
index 3fd384d8c41a..a165cadf8249 100644
@@ -1743,10 +1743,7 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns,
  		str = (char *) label->hname;
  		len = strlen(str);
  	}
-	if (audit_string_contains_control(str, len))
-		audit_log_n_hex(ab, str, len);
-	else
-		audit_log_n_string(ab, str, len);
+	audit_log_n_untrustedstring(ab, str, len);
 
  	kfree(name);
  }
author maintainer
#5 lore raw
Quoted 9 lines · John Johansen
Quoted 4 lines · Paul Moore

Make use of the audit_log_n_untrustedstring() function to simplify the code in aa_label_xaudit().

unless you object I will pull this into the apparmor tree

Please do, that code is up to you and Georgia, not me.

Thanks.

Quoted 2 lines
Quoted 2 lines

--
paul-moore.com