From: Linda Knippers <linda.knippers@hp.com>
To: "George C. Wilson" <ltcgcw@us.ibm.com>
Cc: linux-audit@redhat.com
Subject: Re: [PATCH] Audit of POSIX Message Queue Syscalls v.2
Date: Wed, 24 May 2006 17:23:03 -0400 [thread overview]
Message-ID: <4474CEB7.10901@hp.com> (raw)
In-Reply-To: <20060524210955.GA27747@us.ibm.com>
Hi George,
> > memory leak from above allocation.
> These do not appear to be leaks. They always get freed in
> do_syscall_trace_leave(), both when the syscalls return -EFAULT and
> when audit is disabled. I verified this with printk's. With the
> check for audit enabled, they no longer get allocated needlessly.
> Unless a syscall can bypass do_syscall_trace_leave(), these look
> like they don't leak.
I think you do have some memory leaks. For example:
> +int audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr)
> +{
> + struct audit_aux_data_mq_open *ax;
> + struct audit_context *context = current->audit_context;
> +
> + if (!audit_enabled)
> + return 0;
> +
> + if (likely(!context))
> + return 0;
> +
> + ax = kmalloc(sizeof(*ax), GFP_ATOMIC);
> + if (!ax)
> + return -ENOMEM;
> +
> + if (u_attr != NULL) {
> + if (copy_from_user(&ax->attr, u_attr, sizeof(ax->attr)))
> + return -EFAULT;
If this return is taken, the memory allocated above will not be freed
at syscall exit time because the assignment of context->aux was not
made. ax needs to be freed before returning from the error paths.
> + } else
> + memset(&ax->attr, 0, sizeof(ax->attr));
> +
> + ax->oflag = oflag;
> + ax->mode = mode;
> +
> + ax->d.type = AUDIT_MQ_OPEN;
> + ax->d.next = context->aux;
> + context->aux = (void *)ax;
> + return 0;
> +}
There are similar cases in other functions.
-- ljk
next prev parent reply other threads:[~2006-05-24 21:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-17 1:40 [PATCH] Audit of POSIX Message Queue Syscalls George C. Wilson
2006-05-17 13:34 ` Steve Grubb
2006-05-17 16:39 ` Amy Griffis
2006-05-17 18:11 ` Steve Grubb
2006-05-17 22:38 ` George C. Wilson
2006-05-17 14:34 ` Timothy R. Chavez
2006-05-17 18:27 ` Steve Grubb
2006-05-24 21:09 ` [PATCH] Audit of POSIX Message Queue Syscalls v.2 George C. Wilson
2006-05-24 21:23 ` Linda Knippers [this message]
2006-05-24 21:32 ` Amy Griffis
2006-05-24 21:53 ` Steve Grubb
2006-05-25 1:33 ` George C. Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4474CEB7.10901@hp.com \
--to=linda.knippers@hp.com \
--cc=linux-audit@redhat.com \
--cc=ltcgcw@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox