mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: linux-security-module@vger.kernel.org,
	David Howells <dhowells@redhat.com>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	linux-kernel@vger.kernel.org,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH] cred - BUG: synchronize rcu before releasing cred
Date: Tue, 27 Jul 2010 14:15:22 +0200	[thread overview]
Message-ID: <20100727121522.GE1967@jolsa.brq.redhat.com> (raw)
In-Reply-To: <20100702121456.GD1904@jolsa.brq.redhat.com>

hi,
any feedback?

jirka

On Fri, Jul 02, 2010 at 02:14:56PM +0200, Jiri Olsa wrote:
> hi,
> any feedback?
> 
> jirka
> 
> On Fri, Jun 25, 2010 at 09:33:33AM -0400, Jiri Olsa wrote:
> > BZ 591015 - kernel BUG at kernel/cred.c:168
> > https://bugzilla.redhat.com/show_bug.cgi?id=591015
> > 
> > Above bugzilla reported bug during the releasing of
> > old cred structure.
> > 
> > There is reproducer attached to the bugzilla.
> > 
> > The issue is caused by releasing old cred struct while other
> > kernel path might be still using it. This leads to cred->usage
> > inconsistency inside the __put_cred and triggering the bug.
> > 
> > Following kernel paths are affected:
> > 
> > The CPU1 path is setting the new groups creds.
> > The CPU2 path is cat /proc/PID/status
> > 
> > 
> > CPU 1                              CPU 2
> > 
> > sys_setgroups                      proc_pid_status      
> >   set_current_groups                 task_state
> >     commit_creds                       rcu_read_lock
> >       put_cred                         ...
> >         __put_cred                     get_cred
> >           BUG_ON(usage != 0)           ...
> >                                        rcu_read_unlock
> >                                        
> > 
> > 
> > If __put_cred got executed during the CPU2 holding the reference
> > the BUG_ON inside __put_cred is trigered.
> > 
> > I think there's no need to get the cred refference as long as
> > the 'cred' handling stays inside the rcu_read_lock block.
> > 
> > And the condition of __task_cred 'make sure task doesn't go away',
> > is done by proc_single_show as this is the proc file.
> > 
> > wbr,
> > jirka
> > 
> > 
> > Signed-off-by: Jiri Olsa <jolsa@redhat.com>
> > Acked-by: David Howells <dhowells@redhat.com>
> > ---
> > diff --git a/fs/proc/array.c b/fs/proc/array.c
> > index 9b58d38..ac3b3a4 100644
> > --- a/fs/proc/array.c
> > +++ b/fs/proc/array.c
> > @@ -176,7 +176,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
> >  		if (tracer)
> >  			tpid = task_pid_nr_ns(tracer, ns);
> >  	}
> > -	cred = get_cred((struct cred *) __task_cred(p));
> > +	cred = __task_cred(p);
> >  	seq_printf(m,
> >  		"State:\t%s\n"
> >  		"Tgid:\t%d\n"
> > @@ -199,15 +199,14 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
> >  		"FDSize:\t%d\n"
> >  		"Groups:\t",
> >  		fdt ? fdt->max_fds : 0);
> > -	rcu_read_unlock();
> >  
> >  	group_info = cred->group_info;
> >  	task_unlock(p);
> >  
> >  	for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++)
> >  		seq_printf(m, "%d ", GROUP_AT(group_info, g));
> > -	put_cred(cred);
> >  
> > +	rcu_read_unlock();
> >  	seq_printf(m, "\n");
> >  }
> >  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-07-27 12:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-25 13:33 [PATCH] cred - " Jiri Olsa
2010-07-02 12:14 ` Jiri Olsa
2010-07-27 12:15   ` Jiri Olsa [this message]
2010-07-27 12:43   ` [PATCH] cred - BUG: " David Howells

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=20100727121522.GE1967@jolsa.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paulmck@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

all inboxes | Powered by JetHome®