Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 336801

Summary: memory leak in audit_receive_msg in AUDIT_MAKE_EQUIV:
Product: Red Hat Enterprise Linux 5 Reporter: Eric Paris <eparis>
Component: kernelAssignee: Eric Paris <eparis>
Status: CLOSED DUPLICATE QA Contact: Martin Jenner <mjenner>
Severity: low Docs Contact:
Priority: low    
Version: 5.0CC: aviro, sgrubb
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-10-18 14:58:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric Paris 2007-10-17 22:14:58 UTC
Description of problem:

                ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE);
                if (!ab)
                        break;
                audit_log_format(ab, "auid=%u", loginuid);
                if (sid) {
                        u32 len;
                        ctx = NULL;
                        if (selinux_ctxid_to_string(sid, &ctx, &len))
                                audit_log_format(ab, " ssid=%u", sid);
                        else
                                audit_log_format(ab, " subj=%s", ctx);
                        kfree(ctx);
                }
                audit_log_format(ab, " op=make_equiv old=");
                audit_log_untrustedstring(ab, old);
                audit_log_format(ab, " new=");
                audit_log_untrustedstring(ab, new);
                audit_log_format(ab, " res=%d", !err);
                audit_log_end(ab);
                kfree(old);
                kfree(new);

If ab is null for any reason we are going to leak old and new

Comment 1 Eric Paris 2007-10-17 22:16:21 UTC
easy enough to fix.  Either drop the if (!ab) check altogether since everything
can handle null just fine, or wrap all of the audit_log_ stuff in a if(ab) so we
always call the kfrees.

Comment 2 Eric Paris 2007-10-18 14:58:23 UTC
submitted fix for this as part of patch for 335731

*** This bug has been marked as a duplicate of 335731 ***