Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1706198 > unrolled thread
| Started by | Artem Savkov <asavkov@redhat.com> |
|---|---|
| First post | 2017-08-08 11:00 +0200 |
| Last post | 2017-08-08 13:30 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device Artem Savkov <asavkov@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device Will Deacon <will.deacon@arm.com> - 2017-08-08 11:30 +0200
[PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device Artem Savkov <asavkov@redhat.com> - 2017-08-08 12:30 +0200
Re: [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device Robin Murphy <robin.murphy@arm.com> - 2017-08-08 12:40 +0200
Re: [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device Will Deacon <will.deacon@arm.com> - 2017-08-08 13:30 +0200
| From | Artem Savkov <asavkov@redhat.com> |
|---|---|
| Date | 2017-08-08 11:00 +0200 |
| Subject | [PATCH] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device |
| Message-ID | <uc8wO-5yr-27@gated-at.bofh.it> |
Commit c54451a "iommu/arm-smmu: Fix the error path in arm_smmu_add_device"
removed fwspec assignment in legacy_binding path as redundant which is
wrong. It needs to be updated after fwspec initialisation in
arm_smmu_register_legacy_master() as it is dereferenced later. Without
this there is a NULL-pointer dereference panic during boot on some hosts.
Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
drivers/iommu/arm-smmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index b97188a..95f1c86 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1519,6 +1519,7 @@ static int arm_smmu_add_device(struct device *dev)
if (using_legacy_binding) {
ret = arm_smmu_register_legacy_master(dev, &smmu);
+ fwspec = dev->iommu_fwspec;
if (ret)
goto out_free;
} else if (fwspec && fwspec->ops == &arm_smmu_ops) {
--
2.7.5
[toc] | [next] | [standalone]
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Date | 2017-08-08 11:30 +0200 |
| Subject | Re: [PATCH] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device |
| Message-ID | <uc8ZP-62n-1@gated-at.bofh.it> |
| In reply to | #1706198 |
Hi Artem,
Thanks for the patch.
On Tue, Aug 08, 2017 at 10:58:01AM +0200, Artem Savkov wrote:
> Commit c54451a "iommu/arm-smmu: Fix the error path in arm_smmu_add_device"
> removed fwspec assignment in legacy_binding path as redundant which is
> wrong. It needs to be updated after fwspec initialisation in
> arm_smmu_register_legacy_master() as it is dereferenced later. Without
> this there is a NULL-pointer dereference panic during boot on some hosts.
>
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
> ---
> drivers/iommu/arm-smmu.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> index b97188a..95f1c86 100644
> --- a/drivers/iommu/arm-smmu.c
> +++ b/drivers/iommu/arm-smmu.c
> @@ -1519,6 +1519,7 @@ static int arm_smmu_add_device(struct device *dev)
>
> if (using_legacy_binding) {
> ret = arm_smmu_register_legacy_master(dev, &smmu);
> + fwspec = dev->iommu_fwspec;
> if (ret)
> goto out_free;
> } else if (fwspec && fwspec->ops == &arm_smmu_ops) {
Damn, you're completely right! Robin and I bashed our heads against this for
a while and couldn't remember why the code was structured like it was, but
that explains it. Can you add a comment saying that
arm_smmu_register_legacy_master will allocate an fwspec if its initially NULL,
please?
Cheers,
Will
[toc] | [prev] | [next] | [standalone]
| From | Artem Savkov <asavkov@redhat.com> |
|---|---|
| Date | 2017-08-08 12:30 +0200 |
| Subject | [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device |
| Message-ID | <uc9VT-6Xw-7@gated-at.bofh.it> |
| In reply to | #1706253 |
Commit c54451a "iommu/arm-smmu: Fix the error path in arm_smmu_add_device"
removed fwspec assignment in legacy_binding path as redundant which is
wrong. It needs to be updated after fwspec initialisation in
arm_smmu_register_legacy_master() as it is dereferenced later. Without
this there is a NULL-pointer dereference panic during boot on some hosts.
Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
drivers/iommu/arm-smmu.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index b97188a..2d80fa8 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1519,6 +1519,13 @@ static int arm_smmu_add_device(struct device *dev)
if (using_legacy_binding) {
ret = arm_smmu_register_legacy_master(dev, &smmu);
+
+ /*
+ * If dev->iommu_fwspec is initally NULL, arm_smmu_register_legacy_master()
+ * will allocate/initialise a new one. Thus we need to update fwspec for
+ * later use.
+ */
+ fwspec = dev->iommu_fwspec;
if (ret)
goto out_free;
} else if (fwspec && fwspec->ops == &arm_smmu_ops) {
--
2.7.5
[toc] | [prev] | [next] | [standalone]
| From | Robin Murphy <robin.murphy@arm.com> |
|---|---|
| Date | 2017-08-08 12:40 +0200 |
| Subject | Re: [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device |
| Message-ID | <uca5A-71u-23@gated-at.bofh.it> |
| In reply to | #1706297 |
On 08/08/17 11:26, Artem Savkov wrote:
> Commit c54451a "iommu/arm-smmu: Fix the error path in arm_smmu_add_device"
> removed fwspec assignment in legacy_binding path as redundant which is
> wrong. It needs to be updated after fwspec initialisation in
> arm_smmu_register_legacy_master() as it is dereferenced later. Without
> this there is a NULL-pointer dereference panic during boot on some hosts.
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Thanks for fixing it up, and sorry for failing to document the
unfortunately subtle logic in the first place!
Robin.
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
> ---
> drivers/iommu/arm-smmu.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> index b97188a..2d80fa8 100644
> --- a/drivers/iommu/arm-smmu.c
> +++ b/drivers/iommu/arm-smmu.c
> @@ -1519,6 +1519,13 @@ static int arm_smmu_add_device(struct device *dev)
>
> if (using_legacy_binding) {
> ret = arm_smmu_register_legacy_master(dev, &smmu);
> +
> + /*
> + * If dev->iommu_fwspec is initally NULL, arm_smmu_register_legacy_master()
> + * will allocate/initialise a new one. Thus we need to update fwspec for
> + * later use.
> + */
> + fwspec = dev->iommu_fwspec;
> if (ret)
> goto out_free;
> } else if (fwspec && fwspec->ops == &arm_smmu_ops) {
>
[toc] | [prev] | [next] | [standalone]
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Date | 2017-08-08 13:30 +0200 |
| Subject | Re: [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device |
| Message-ID | <ucaRY-7FO-25@gated-at.bofh.it> |
| In reply to | #1706308 |
[+ Joerg]
On Tue, Aug 08, 2017 at 11:37:40AM +0100, Robin Murphy wrote:
> On 08/08/17 11:26, Artem Savkov wrote:
> > Commit c54451a "iommu/arm-smmu: Fix the error path in arm_smmu_add_device"
> > removed fwspec assignment in legacy_binding path as redundant which is
> > wrong. It needs to be updated after fwspec initialisation in
> > arm_smmu_register_legacy_master() as it is dereferenced later. Without
> > this there is a NULL-pointer dereference panic during boot on some hosts.
>
> Reviewed-by: Robin Murphy <robin.murphy@arm.com>
>
> Thanks for fixing it up, and sorry for failing to document the
> unfortunately subtle logic in the first place!
Well, I was the one that messed it up:
Acked-by: Will Deacon <will.deacon@arm.com>
Joerg, can you pick this up as a fix for 4.13, please?
Will
> > Signed-off-by: Artem Savkov <asavkov@redhat.com>
> > ---
> > drivers/iommu/arm-smmu.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> > index b97188a..2d80fa8 100644
> > --- a/drivers/iommu/arm-smmu.c
> > +++ b/drivers/iommu/arm-smmu.c
> > @@ -1519,6 +1519,13 @@ static int arm_smmu_add_device(struct device *dev)
> >
> > if (using_legacy_binding) {
> > ret = arm_smmu_register_legacy_master(dev, &smmu);
> > +
> > + /*
> > + * If dev->iommu_fwspec is initally NULL, arm_smmu_register_legacy_master()
> > + * will allocate/initialise a new one. Thus we need to update fwspec for
> > + * later use.
> > + */
> > + fwspec = dev->iommu_fwspec;
> > if (ret)
> > goto out_free;
> > } else if (fwspec && fwspec->ops == &arm_smmu_ops) {
> >
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web