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] [day] [month] [year] [list]
Message-ID: <20240401174009.00003644@Huawei.com>
Date: Mon, 1 Apr 2024 17:40:09 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Aleksandr Aprelkov <aaprelkov@...rgate.com>
CC: Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>, Joerg
 Roedel <joro@...tes.org>, Jason Gunthorpe <jgg@...pe.ca>, "Nicolin Chen"
	<nicolinc@...dia.com>, Michael Shavit <mshavit@...gle.com>, Lu Baolu
	<baolu.lu@...ux.intel.com>, Marc Zyngier <maz@...nel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <iommu@...ts.linux.dev>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] iommu/arm-smmu-v3: Free MSIs in case of ENOMEM

On Fri, 29 Mar 2024 16:51:33 +0700
Aleksandr Aprelkov <aaprelkov@...rgate.com> wrote:

> If devm_add_action() returns ENOMEM, then MSIs allocated but
> not freed on teardown.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 166bdbd23161 ("iommu/arm-smmu: Add support for MSI on SMMUv3")
> Signed-off-by: Aleksandr Aprelkov <aaprelkov@...rgate.com>

I've not checked this is an actual bug (though it looks like one from
the context of the patch - the comment below is just about
how you fix it.

> ---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 41f93c3ab160..136d0cdce6a9 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -3402,7 +3402,12 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu)
>  	smmu->priq.q.irq = msi_get_virq(dev, PRIQ_MSI_INDEX);
>  
>  	/* Add callback to free MSIs on teardown */
> -	devm_add_action(dev, arm_smmu_free_msis, dev);
> +	ret = devm_add_action(dev, arm_smmu_free_msis, dev);

Use devm_add_action_or_reset() which exists to solve the case of devm registration failing.


> +	if (ret) {
> +		dev_warn(dev, "failed to add free MSIs callback - falling back to wired irqs\n");
> +		arm_smmu_free_msis(dev);
> +		return;
> +	}
>  }
>  
>  static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ