Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4823bce authored by Al Viro's avatar Al Viro Committed by Linus Torvalds
Browse files

[PATCH] fix deadlock in audit_log_task_context()



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

Acked-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
Acked-by: default avatarJames Morris <jmorris@namei.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent baab1087
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -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;

	len = security_getprocattr(current, "current", NULL, 0);
	if (len < 0) {
		if (len != -EINVAL)
			goto error_path;
	selinux_get_task_sid(current, &sid);
	if (!sid)
		return;
	}

	ctx = kmalloc(len, GFP_KERNEL);
	if (!ctx)
		goto error_path;

	len = security_getprocattr(current, "current", ctx, len);
	if (len < 0 )
	error = selinux_sid_to_string(sid, &ctx, &len);
	if (error) {
		if (error != -EINVAL)
			goto error_path;
		return;
	}

	audit_log_format(ab, " subj=%s", ctx);
	kfree(ctx);
	return;

error_path:
	kfree(ctx);
	audit_panic("error in audit_log_task_context");
	return;
}