From: Andrew Morton <akpm@linux-foundation.org>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: linux-audit@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/15] don't reallocate buffer in every audit_sockaddr()
Date: Tue, 16 Dec 2008 23:49:27 -0800 [thread overview]
Message-ID: <20081216234927.9cb8a077.akpm@linux-foundation.org> (raw)
In-Reply-To: <E1LCogg-00008b-SH@ZenIV.linux.org.uk>
On Wed, 17 Dec 2008 05:11:10 +0000 Al Viro <viro@ftp.linux.org.uk> wrote:
> int audit_sockaddr(int len, void *a)
> {
> - struct audit_aux_data_sockaddr *ax;
> struct audit_context *context = current->audit_context;
>
> if (likely(!context || context->dummy))
> return 0;
>
> - ax = kmalloc(sizeof(*ax) + len, GFP_KERNEL);
> - if (!ax)
> - return -ENOMEM;
> -
> - ax->len = len;
> - memcpy(ax->a, a, len);
> + if (!context->sockaddr) {
> + void *p = kmalloc(sizeof(struct sockaddr_storage), GFP_KERNEL);
argh, I really hate having to run all around the code verifying that
the type passed to sizeof matches the type that we'll be storing there :(
> + if (!p)
> + return -ENOMEM;
> + context->sockaddr = p;
> + }
>
> - ax->d.type = AUDIT_SOCKADDR;
> - ax->d.next = context->aux;
> - context->aux = (void *)ax;
> + context->sockaddr_len = len;
> + memcpy(context->sockaddr, a, len);
> return 0;
> }
stoopid question: can an audit_contect be shared between
threads/processes? If so, is locking needed around the read/test/write
of context->sockaddr and friends?
next prev parent reply other threads:[~2008-12-17 7:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-17 5:11 [PATCH 1/15] don't reallocate buffer in every audit_sockaddr() Al Viro
2008-12-17 7:20 ` James Morris
2008-12-17 7:49 ` Andrew Morton [this message]
2008-12-17 7:56 ` Al Viro
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=20081216234927.9cb8a077.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ftp.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.