aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/auditsc.c
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2007-03-12 12:17:42 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-03-14 18:27:48 -0400
commitc4823bce033be74c0fcfbcae2f1be0854fdc2e18 (patch)
treea37dce7574167fc3639b70bab2626bbf8eb896e3 /kernel/auditsc.c
parentbaab1087c61d4506f2c9f4cdb7da162160de16c2 (diff)
[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: Stephen Smalley <sds@tycho.nsa.gov> Acked-by: James Morris <jmorris@namei.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/auditsc.c')
-rw-r--r--kernel/auditsc.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 359955800dd2..628c7ac590a0 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -739,28 +739,26 @@ static inline void audit_free_context(struct audit_context *context)
739void audit_log_task_context(struct audit_buffer *ab) 739void audit_log_task_context(struct audit_buffer *ab)
740{ 740{
741 char *ctx = NULL; 741 char *ctx = NULL;
742 ssize_t len = 0; 742 unsigned len;
743 int error;
744 u32 sid;
745
746 selinux_get_task_sid(current, &sid);
747 if (!sid)
748 return;
743 749
744 len = security_getprocattr(current, "current", NULL, 0); 750 error = selinux_sid_to_string(sid, &ctx, &len);
745 if (len < 0) { 751 if (error) {
746 if (len != -EINVAL) 752 if (error != -EINVAL)
747 goto error_path; 753 goto error_path;
748 return; 754 return;
749 } 755 }
750 756
751 ctx = kmalloc(len, GFP_KERNEL);
752 if (!ctx)
753 goto error_path;
754
755 len = security_getprocattr(current, "current", ctx, len);
756 if (len < 0 )
757 goto error_path;
758
759 audit_log_format(ab, " subj=%s", ctx); 757 audit_log_format(ab, " subj=%s", ctx);
758 kfree(ctx);
760 return; 759 return;
761 760
762error_path: 761error_path:
763 kfree(ctx);
764 audit_panic("error in audit_log_task_context"); 762 audit_panic("error in audit_log_task_context");
765 return; 763 return;
766} 764}