* FAILED: patch "[PATCH] iommu/arm-smmu-v3: Don't free page table ops twice" failed to apply to 4.4-stable tree
@ 2018-01-07 8:35 gregkh
2018-01-08 14:56 ` Jean-Philippe Brucker
0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2018-01-07 8:35 UTC (permalink / raw)
To: jean-philippe.brucker, robin.murphy, stable, will.deacon; +Cc: stable
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 57d72e159b60456c8bb281736c02ddd3164037aa Mon Sep 17 00:00:00 2001
From: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Date: Thu, 14 Dec 2017 11:03:01 +0000
Subject: [PATCH] iommu/arm-smmu-v3: Don't free page table ops twice
Kasan reports a double free when finalise_stage_fn fails: the io_pgtable
ops are freed by arm_smmu_domain_finalise and then again by
arm_smmu_domain_free. Prevent this by leaving pgtbl_ops empty on failure.
Cc: <stable@vger.kernel.org>
Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index f122071688fd..db4281d0e269 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1698,13 +1698,15 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
domain->geometry.aperture_end = (1UL << ias) - 1;
domain->geometry.force_aperture = true;
- smmu_domain->pgtbl_ops = pgtbl_ops;
ret = finalise_stage_fn(smmu_domain, &pgtbl_cfg);
- if (ret < 0)
+ if (ret < 0) {
free_io_pgtable_ops(pgtbl_ops);
+ return ret;
+ }
- return ret;
+ smmu_domain->pgtbl_ops = pgtbl_ops;
+ return 0;
}
static __le64 *arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: FAILED: patch "[PATCH] iommu/arm-smmu-v3: Don't free page table ops twice" failed to apply to 4.4-stable tree
2018-01-07 8:35 FAILED: patch "[PATCH] iommu/arm-smmu-v3: Don't free page table ops twice" failed to apply to 4.4-stable tree gregkh
@ 2018-01-08 14:56 ` Jean-Philippe Brucker
2018-01-10 16:30 ` gregkh
0 siblings, 1 reply; 5+ messages in thread
From: Jean-Philippe Brucker @ 2018-01-08 14:56 UTC (permalink / raw)
To: gregkh@linuxfoundation.org
Cc: Robin Murphy, stable@vger.kernel.org, Will Deacon
Hi,
On Sun, Jan 07, 2018 at 08:35:02AM +0000, gregkh@linuxfoundation.org wrote:
> The patch below does not apply to the 4.4-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
Please consider applying the updated backport for 4.4-stable, below.
Thanks,
Jean
--- 8< ---
>From 36a792dfdaff7fafeb7b870cc0f86a339df9ea25 Mon Sep 17 00:00:00 2001
From: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Date: Thu, 14 Dec 2017 11:03:01 +0000
Subject: [PATCH] iommu/arm-smmu-v3: Don't free page table ops twice
commit 57d72e159b60456c8bb281736c02ddd3164037aa upstream.
Kasan reports a double free when finalise_stage_fn fails: the io_pgtable
ops are freed by arm_smmu_domain_finalise and then again by
arm_smmu_domain_free. Prevent this by leaving pgtbl_ops empty on failure.
Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
drivers/iommu/arm-smmu-v3.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 64f1eb8fdcbc..347aaaa5a7ea 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1541,13 +1541,15 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
return -ENOMEM;
arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
- smmu_domain->pgtbl_ops = pgtbl_ops;
ret = finalise_stage_fn(smmu_domain, &pgtbl_cfg);
- if (IS_ERR_VALUE(ret))
+ if (IS_ERR_VALUE(ret)) {
free_io_pgtable_ops(pgtbl_ops);
+ return ret;
+ }
- return ret;
+ smmu_domain->pgtbl_ops = pgtbl_ops;
+ return 0;
}
static struct arm_smmu_group *arm_smmu_group_get(struct device *dev)
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: FAILED: patch "[PATCH] iommu/arm-smmu-v3: Don't free page table ops twice" failed to apply to 4.4-stable tree
2018-01-08 14:56 ` Jean-Philippe Brucker
@ 2018-01-10 16:30 ` gregkh
2018-01-10 18:37 ` [PATCH v4.4.y] iommu/arm-smmu-v3: Don't free page table ops twice Jean-Philippe Brucker
0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2018-01-10 16:30 UTC (permalink / raw)
To: Jean-Philippe Brucker; +Cc: Robin Murphy, stable@vger.kernel.org, Will Deacon
On Mon, Jan 08, 2018 at 02:56:36PM +0000, Jean-Philippe Brucker wrote:
> Hi,
>
> On Sun, Jan 07, 2018 at 08:35:02AM +0000, gregkh@linuxfoundation.org wrote:
> > The patch below does not apply to the 4.4-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
>
> Please consider applying the updated backport for 4.4-stable, below.
>
> Thanks,
> Jean
>
> --- 8< ---
> >From 36a792dfdaff7fafeb7b870cc0f86a339df9ea25 Mon Sep 17 00:00:00 2001
> From: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
> Date: Thu, 14 Dec 2017 11:03:01 +0000
> Subject: [PATCH] iommu/arm-smmu-v3: Don't free page table ops twice
>
> commit 57d72e159b60456c8bb281736c02ddd3164037aa upstream.
>
> Kasan reports a double free when finalise_stage_fn fails: the io_pgtable
> ops are freed by arm_smmu_domain_finalise and then again by
> arm_smmu_domain_free. Prevent this by leaving pgtbl_ops empty on failure.
>
> Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
> ---
> drivers/iommu/arm-smmu-v3.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
This does not apply to the 4.4-stable tree:
checking file drivers/iommu/arm-smmu-v3.c
Hunk #1 FAILED at 1541.
1 out of 1 hunk FAILED
Are you sure you tried it?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4.4.y] iommu/arm-smmu-v3: Don't free page table ops twice
2018-01-10 16:30 ` gregkh
@ 2018-01-10 18:37 ` Jean-Philippe Brucker
2018-01-10 19:13 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Jean-Philippe Brucker @ 2018-01-10 18:37 UTC (permalink / raw)
To: gregkh; +Cc: stable, Will.Deacon, Robin.Murphy, jean-philippe.brucker
commit 57d72e159b60456c8bb281736c02ddd3164037aa upstream.
Kasan reports a double free when finalise_stage_fn fails: the io_pgtable
ops are freed by arm_smmu_domain_finalise and then again by
arm_smmu_domain_free. Prevent this by leaving pgtbl_ops empty on failure.
Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
The whitespaces got corrupted last time, sorry about that. Let's hope
this one works.
Thanks,
Jean
---
drivers/iommu/arm-smmu-v3.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 64f1eb8fdcbc..347aaaa5a7ea 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1541,13 +1541,15 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
return -ENOMEM;
arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
- smmu_domain->pgtbl_ops = pgtbl_ops;
ret = finalise_stage_fn(smmu_domain, &pgtbl_cfg);
- if (IS_ERR_VALUE(ret))
+ if (IS_ERR_VALUE(ret)) {
free_io_pgtable_ops(pgtbl_ops);
+ return ret;
+ }
- return ret;
+ smmu_domain->pgtbl_ops = pgtbl_ops;
+ return 0;
}
static struct arm_smmu_group *arm_smmu_group_get(struct device *dev)
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4.4.y] iommu/arm-smmu-v3: Don't free page table ops twice
2018-01-10 18:37 ` [PATCH v4.4.y] iommu/arm-smmu-v3: Don't free page table ops twice Jean-Philippe Brucker
@ 2018-01-10 19:13 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2018-01-10 19:13 UTC (permalink / raw)
To: Jean-Philippe Brucker; +Cc: stable, Will.Deacon, Robin.Murphy
On Wed, Jan 10, 2018 at 06:37:11PM +0000, Jean-Philippe Brucker wrote:
> commit 57d72e159b60456c8bb281736c02ddd3164037aa upstream.
>
> Kasan reports a double free when finalise_stage_fn fails: the io_pgtable
> ops are freed by arm_smmu_domain_finalise and then again by
> arm_smmu_domain_free. Prevent this by leaving pgtbl_ops empty on failure.
>
> Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
> ---
>
> The whitespaces got corrupted last time, sorry about that. Let's hope
> this one works.
It worked, thanks, now queued up.
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-10 19:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-07 8:35 FAILED: patch "[PATCH] iommu/arm-smmu-v3: Don't free page table ops twice" failed to apply to 4.4-stable tree gregkh
2018-01-08 14:56 ` Jean-Philippe Brucker
2018-01-10 16:30 ` gregkh
2018-01-10 18:37 ` [PATCH v4.4.y] iommu/arm-smmu-v3: Don't free page table ops twice Jean-Philippe Brucker
2018-01-10 19:13 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).