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: <3f12b315-b7bf-e0c3-7105-4c9c9536f52f@kernel.org>
Date:   Fri, 20 Sep 2019 16:37:45 +0100
From:   Marc Zyngier <maz@...nel.org>
To:     "Sverdlin, Alexander (Nokia - DE/Ulm)" <alexander.sverdlin@...ia.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Grant Likely <grant.likely@...retlab.ca>
Cc:     Mark Brown <broonie@...nsource.wolfsonmicro.com>,
        Jon Hunter <jonathanh@...dia.com>,
        "Glavinic-Pecotic, Matija (EXT - DE/Ulm)" 
        <matija.glavinic-pecotic.ext@...ia.com>,
        "Adamski, Krzysztof (Nokia - PL/Wroclaw)" 
        <krzysztof.adamski@...ia.com>,
        "stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: Re: [PATCH 1/3] genirq/irqdomain: Check for existing mapping in
 irq_domain_associate()

On 12/09/2019 10:44, Sverdlin, Alexander (Nokia - DE/Ulm) wrote:
> From: Alexander Sverdlin <alexander.sverdlin@...ia.com>
> 
> irq_domain_associate() is the only place where irq_find_mapping() can be
> used reliably (under irq_domain_mutex) to make a decision if the mapping
> shall be created or not. Other calls to irq_find_mapping() (not under
> any lock) cannot be used for this purpose and lead to race conditions in
> particular inside irq_create_mapping().
> 
> Give the callers of irq_domain_associate() an ability to detect existing
> domain reliably by examining the return value.
> 
> Cc: stable@...r.kernel.org
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@...ia.com>
> ---
>  kernel/irq/irqdomain.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 3078d0e..7bc07b6 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -532,6 +532,7 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq,
>  			 irq_hw_number_t hwirq)
>  {
>  	struct irq_data *irq_data = irq_get_irq_data(virq);
> +	unsigned int eirq;
>  	int ret;
>  
>  	if (WARN(hwirq >= domain->hwirq_max,
> @@ -543,6 +544,16 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq,
>  		return -EINVAL;
>  
>  	mutex_lock(&irq_domain_mutex);
> +
> +	/* Check if mapping already exists */
> +	eirq = irq_find_mapping(domain, hwirq);
> +	if (eirq) {

nit: Just have

	if (irq_find_mapping(...)) {

and get rid the extra variable, given that it's not used for anything.

> +		mutex_unlock(&irq_domain_mutex);
> +		pr_debug("%s: conflicting mapping for hwirq 0x%x\n",
> +			 domain->name, (int)hwirq);
> +		return -EBUSY;

I'm overall OK with this, although I'd rather we return -EEXIST rather
than -EBUSY.

> +	}
> +
>  	irq_data->hwirq = hwirq;
>  	irq_data->domain = domain;
>  	if (domain->ops->map) {
> 

Thanks,

	M.
-- 
Jazz is not dead, it just smells funny...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ