public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: linux-audit@redhat.com, linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org, eparis@redhat.com,
	sgrubb@redhat.com
Subject: Re: [PATCH] integrity: get comm using lock to avoid race in string printing
Date: Wed, 2 Apr 2014 14:45:17 -0400	[thread overview]
Message-ID: <20140402184517.GA24814@madcap2.tricolour.ca> (raw)
In-Reply-To: <1396460387.20325.22.camel@dhcp-9-2-203-236.watson.ibm.com>

On 14/04/02, Mimi Zohar wrote:
> On Wed, 2014-04-02 at 12:19 -0400, Richard Guy Briggs wrote: 
> > When task->comm is passed directly to audit_log_untrustedstring() without
> > getting a copy or using the task_lock, there is a race that could happen that
> > would output a NULL (\0) in the output string that would effectively truncate
> > the rest of the report text after the comm= field in the audit, losing fields.
> > 
> > Use get_task_comm() to get a copy while acquiring the task_lock to prevent
> > this and to prevent the result from being a mixture of old and new values of
> > comm.
> > 
> > Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
> > ---
> >  security/integrity/integrity_audit.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> > 
> > diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c
> > index 85253b5..11706a2 100644
> > --- a/security/integrity/integrity_audit.c
> > +++ b/security/integrity/integrity_audit.c
> > @@ -33,6 +33,7 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
> >  			 const char *cause, int result, int audit_info)
> >  {
> >  	struct audit_buffer *ab;
> > +	char comm[sizeof(current->comm)];
> > 
> >  	if (!integrity_audit_info && audit_info == 1)	/* Skip info messages */
> >  		return;
> > @@ -49,7 +50,7 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
> >  	audit_log_format(ab, " cause=");
> >  	audit_log_string(ab, cause);
> >  	audit_log_format(ab, " comm=");
> > -	audit_log_untrustedstring(ab, current->comm);
> > +	audit_log_untrustedstring(ab, get_task_comm(comm, current));
> >  	if (fname) {
> >  		audit_log_format(ab, " name=");
> >  		audit_log_untrustedstring(ab, fname);
> 
> This change is already being upstreamed as commit 73a6b44 "Integrity:
> Pass commname via get_task_comm()".

Excellent.  Missed that.  Thanks.

> thanks,
> 
> Mimi

- RGB

--
Richard Guy Briggs <rbriggs@redhat.com>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

      parent reply	other threads:[~2014-04-02 18:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-02 16:19 [PATCH] integrity: get comm using lock to avoid race in string printing Richard Guy Briggs
2014-04-02 17:39 ` Mimi Zohar
2014-04-02 18:00   ` Steve Grubb
2014-04-02 18:12     ` Mimi Zohar
2014-04-02 18:18       ` Eric Paris
2014-04-02 18:27         ` Mimi Zohar
2014-04-02 18:52           ` oraphaned keywords in audit log text [was: Re: [PATCH] integrity: get comm using lock to avoid race in string] printing Richard Guy Briggs
2014-06-14  0:02             ` Richard Guy Briggs
2014-06-14  9:43               ` [Linux-ima-user] " Dmitry Kasatkin
2014-06-15  1:46                 ` Mimi Zohar
2014-06-15  2:45                   ` Richard Guy Briggs
2014-04-02 18:45   ` Richard Guy Briggs [this message]

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=20140402184517.GA24814@madcap2.tricolour.ca \
    --to=rgb@redhat.com \
    --cc=eparis@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sgrubb@redhat.com \
    --cc=zohar@linux.vnet.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