GFP_KERNEL allocations in non-blocking context; fixed by killing an idiotic use of security_getprocattr().
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -739,28 +739,26 @@ static inline void audit_free_context(struct audit_context *context) · 738 unmodified lines | ||
| 739 | 739 | void audit_log_task_context(struct audit_buffer *ab) |
| 740 | 740 | { |
| 741 | 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); | |
| 745 | − if (len < 0) { | |
| 746 | − if (len != -EINVAL) | |
| 750 | + error = selinux_sid_to_string(sid, &ctx, &len); | |
| 751 | + if (error) { | |
| 752 | + if (error != -EINVAL) | |
| 747 | 753 | goto error_path; |
| 748 | 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 | 757 | audit_log_format(ab, " subj=%s", ctx); |
| 758 | + kfree(ctx); | |
| 760 | 759 | return; |
| 761 | 760 | |
| 762 | 761 | error_path: |
| 763 | − kfree(ctx); | |
| 764 | 762 | audit_panic("error in audit_log_task_context"); |
| 765 | 763 | return; |
| 766 | 764 | } |