lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110611102754.GB29908@amd.com>
Date:	Sat, 11 Jun 2011 12:27:54 +0200
From:	"Roedel, Joerg" <Joerg.Roedel@....com>
To:	Chris Wright <chrisw@...s-sol.org>
CC:	"iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/9] x86/amd-iommu: Introduce global dev_data_list

On Fri, Jun 10, 2011 at 01:36:04PM -0400, Chris Wright wrote:
> * Joerg Roedel (joerg.roedel@....com) wrote:
> > +static struct iommu_dev_data *alloc_dev_data(void)
> > +{
> > +	struct iommu_dev_data *dev_data;
> > +	unsigned long flags;
> > +
> > +	dev_data = kzalloc(sizeof(*dev_data), GFP_KERNEL);
> > +	if (!dev_data)
> > +		return NULL;
> > +
> > +	atomic_set(&dev_data->bind, 0);
> > +
> > +	spin_lock_irqsave(&dev_data_list_lock, flags);
> > +	list_add_tail(&dev_data->dev_data_list, &dev_data_list);
> > +	spin_unlock_irqrestore(&dev_data_list_lock, flags);
> 
> Globally visible but only paritially initiailized.  I didn't see any, but
> would this ever cause an issue?

I don't think so. Everything allocated here goes into iommu_init_device
where the alias-part of the struct is initialized. As long as this is
the only place that calls find_dev_data everything is fine.

> > +static void free_dev_data(struct iommu_dev_data *dev_data)
> > +{
> > +	unsigned long flags;
> > +
> > +	spin_lock_irqsave(&dev_data_list_lock, flags);
> > +	list_del(&dev_data->dev_data_list);
> > +	spin_unlock_irqrestore(&dev_data_list_lock, flags);
> > +
> > +	kfree(dev_data);
> <snip>
> > +	/* Free all of our dev_data structures */
> > +	list_for_each_entry_safe(dev_data, n, &dev_data_list, dev_data_list)
> > +		free_dev_data(dev_data);
> 
> Given that it's not actually contended in early init, should be fine...but
> typically full list traversal would be protected by lock rather than
> repeatedly acquiring and releasing the lock.

Well, the lock shouldn't be necessary here at all. This function is
called in the error-path to clean up. Otherwise the dev_data structures
are never freed, so the lock can probably be removed from free_dev_data.

	Joerg

-- 
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ