Skip to contentSkip to conversation

fix deadlock in audit_log_task_context()

PATCH New Al Viro 1 participant 1 message Mar 12, 2007 Audit

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 fix deadlock in audit_log_task_context()

GFP_KERNEL allocations in non-blocking context; fixed by killing an idiotic use of security_getprocattr().

---
 kernel/auditsc.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)
kernel/auditsc.c +11 -13
index 3599558..628c7ac 100644
@@ -739,28 +739,26 @@ static inline void audit_free_context(struct audit_context *context)
 void audit_log_task_context(struct audit_buffer *ab)
 {
 	char *ctx = NULL;
-	ssize_t len = 0;
+	unsigned len;
+	int error;
+	u32 sid;
+
+	selinux_get_task_sid(current, &sid);
+	if (!sid)
+		return;
 
-	len = security_getprocattr(current, "current", NULL, 0);
-	if (len < 0) {
-		if (len != -EINVAL)
+	error = selinux_sid_to_string(sid, &ctx, &len);
+	if (error) {
+		if (error != -EINVAL)
 			goto error_path;
 		return;
 	}
 
-	ctx = kmalloc(len, GFP_KERNEL);
-	if (!ctx)
-		goto error_path;
-
-	len = security_getprocattr(current, "current", ctx, len);
-	if (len < 0 )
-		goto error_path;
-
 	audit_log_format(ab, " subj=%s", ctx);
+	kfree(ctx);
 	return;
 
 error_path:
-	kfree(ctx);
 	audit_panic("error in audit_log_task_context");
 	return;
 }
Signature · 1 line
1.5.0-rc2.GIT