All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Moore <paul.moore@hp.com>
To: James Morris <jmorris@namei.org>
Cc: netdev@vger.kernel.org, selinux@tycho.nsa.gov,
	davem@davemloft.net, sds@epoch.ncsc.mil, jmorris@redhat.com,
	pratt@argus-systems.com
Subject: Re: [PATCH 3/7] NetLabel: CIPSOv4 engine
Date: Sat, 15 Jul 2006 11:14:30 -0400	[thread overview]
Message-ID: <200607151114.30648.paul.moore@hp.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0607150913510.24495@d.namei>

On Saturday 15 July 2006 9:15 am, James Morris wrote:
> On Fri, 14 Jul 2006, paul.moore@hp.com wrote:
> > +int cipso_v4_doi_add(struct cipso_v4_doi *doi_def)
> > +{
> > +	if (doi_def == NULL || doi_def->doi == CIPSO_V4_DOI_UNKNOWN)
> > +		return -EINVAL;
> > +
> > +	doi_def->valid = 1;
> > +	INIT_RCU_HEAD(&doi_def->rcu);
> > +	INIT_LIST_HEAD(&doi_def->dom_list);
> > +
> > +	rcu_read_lock();
> > +	if (cipso_v4_doi_search(doi_def->doi) != NULL) {
> > +		rcu_read_unlock();
> > +		return -EEXIST;
> > +	}
> > +	spin_lock(&cipso_v4_doi_list_lock);
> > +	list_add_tail_rcu(&doi_def->list, &cipso_v4_doi_list);
> > +	spin_unlock(&cipso_v4_doi_list_lock);
> > +	rcu_read_unlock();
> > +
> > +	return 0;
> > +}
>
> This is racy in that you can end up with duplicate entries in the list
> between rcu_read_lock() and spin_lock().
>
> You need to perform the search a second time under the spin_lock() as a
> slow path to verify that an entry wasn't added, before adding a new one.
>

Thanks, there are a few more place which might have similar problems - I'll 
check those as well.

-- 
paul moore
linux security @ hp

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

WARNING: multiple messages have this Message-ID (diff)
From: Paul Moore <paul.moore@hp.com>
To: James Morris <jmorris@namei.org>
Cc: netdev@vger.kernel.org, selinux@tycho.nsa.gov,
	davem@davemloft.net, sds@epoch.ncsc.mil, jmorris@redhat.com,
	pratt@argus-systems.com
Subject: Re: [PATCH 3/7] NetLabel: CIPSOv4 engine
Date: Sat, 15 Jul 2006 11:14:30 -0400	[thread overview]
Message-ID: <200607151114.30648.paul.moore@hp.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0607150913510.24495@d.namei>

On Saturday 15 July 2006 9:15 am, James Morris wrote:
> On Fri, 14 Jul 2006, paul.moore@hp.com wrote:
> > +int cipso_v4_doi_add(struct cipso_v4_doi *doi_def)
> > +{
> > +	if (doi_def == NULL || doi_def->doi == CIPSO_V4_DOI_UNKNOWN)
> > +		return -EINVAL;
> > +
> > +	doi_def->valid = 1;
> > +	INIT_RCU_HEAD(&doi_def->rcu);
> > +	INIT_LIST_HEAD(&doi_def->dom_list);
> > +
> > +	rcu_read_lock();
> > +	if (cipso_v4_doi_search(doi_def->doi) != NULL) {
> > +		rcu_read_unlock();
> > +		return -EEXIST;
> > +	}
> > +	spin_lock(&cipso_v4_doi_list_lock);
> > +	list_add_tail_rcu(&doi_def->list, &cipso_v4_doi_list);
> > +	spin_unlock(&cipso_v4_doi_list_lock);
> > +	rcu_read_unlock();
> > +
> > +	return 0;
> > +}
>
> This is racy in that you can end up with duplicate entries in the list
> between rcu_read_lock() and spin_lock().
>
> You need to perform the search a second time under the spin_lock() as a
> slow path to verify that an entry wasn't added, before adding a new one.
>

Thanks, there are a few more place which might have similar problems - I'll 
check those as well.

-- 
paul moore
linux security @ hp

  reply	other threads:[~2006-07-15 15:14 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-14 18:57 [PATCH 0/7] Latest NetLabel patch for 2.6.19 paul.moore
2006-07-14 18:57 ` paul.moore
2006-07-14 18:57 ` [PATCH 1/7] NetLabel: documentation paul.moore
2006-07-14 18:57   ` paul.moore
2006-07-14 18:57 ` [PATCH 2/7] NetLabel: core network changes paul.moore
2006-07-14 18:57   ` paul.moore
2006-07-14 23:34   ` James Morris
2006-07-14 23:34     ` James Morris
2006-07-14 23:36     ` David Miller
2006-07-15 14:48     ` Paul Moore
2006-07-15 14:48       ` Paul Moore
2006-07-14 18:57 ` [PATCH 3/7] NetLabel: CIPSOv4 engine paul.moore
2006-07-14 18:57   ` paul.moore
2006-07-14 23:56   ` James Morris
2006-07-14 23:56     ` James Morris
2006-07-15  2:03   ` James Morris
2006-07-15  2:03     ` James Morris
2006-07-15 14:59     ` Paul Moore
2006-07-15 14:59       ` Paul Moore
2006-07-16 16:10     ` Paul Moore
2006-07-16 16:10       ` Paul Moore
2006-07-17  1:12       ` David Miller
2006-07-17  2:42         ` Paul Moore
2006-07-17  2:42           ` Paul Moore
2006-07-17  2:53           ` David Miller
2006-07-15  2:18   ` James Morris
2006-07-15  2:18     ` James Morris
2006-07-15 15:03     ` Paul Moore
2006-07-15 15:03       ` Paul Moore
2006-07-15 13:08   ` James Morris
2006-07-15 13:08     ` James Morris
2006-07-15 13:11     ` James Morris
2006-07-15 13:11       ` James Morris
2006-07-15 15:13       ` Paul Moore
2006-07-15 15:13         ` Paul Moore
2006-07-15 15:09     ` Paul Moore
2006-07-15 15:09       ` Paul Moore
2006-07-15 13:15   ` James Morris
2006-07-15 13:15     ` James Morris
2006-07-15 15:14     ` Paul Moore [this message]
2006-07-15 15:14       ` Paul Moore
2006-07-15 22:39   ` James Morris
2006-07-15 22:39     ` James Morris
2006-07-15 23:26     ` Paul Moore
2006-07-15 23:26       ` Paul Moore
2006-07-14 18:57 ` [PATCH 4/7] NetLabel: core NetLabel subsystem paul.moore
2006-07-14 18:57   ` paul.moore
2006-07-14 18:57 ` [PATCH 5/7] NetLabel: CIPSOv4 and Unlabeled packet integration paul.moore
2006-07-14 18:57   ` paul.moore
2006-07-14 18:57 ` [PATCH 6/7] NetLabel: SELinux support paul.moore
2006-07-14 18:57   ` paul.moore
2006-07-14 18:57 ` [PATCH 7/7] NetLabel: tie NetLabel into the Kconfig system paul.moore
2006-07-14 18:57   ` paul.moore
  -- strict thread matches above, loose matches on Subject: below --
2006-07-17 15:52 [PATCH 0/7] Updated patchset w/James' comments paul.moore
2006-07-17 15:52 ` [PATCH 3/7] NetLabel: CIPSOv4 engine paul.moore
2006-07-17 15:52   ` paul.moore
2006-07-28  7:56   ` David Miller

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=200607151114.30648.paul.moore@hp.com \
    --to=paul.moore@hp.com \
    --cc=davem@davemloft.net \
    --cc=jmorris@namei.org \
    --cc=jmorris@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pratt@argus-systems.com \
    --cc=sds@epoch.ncsc.mil \
    --cc=selinux@tycho.nsa.gov \
    /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.