* [PATCH] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device
@ 2017-08-08 8:58 Artem Savkov
2017-08-08 9:26 ` Will Deacon
0 siblings, 1 reply; 6+ messages in thread
From: Artem Savkov @ 2017-08-08 8:58 UTC (permalink / raw)
To: Will Deacon
Cc: Vivek Gautam, linux-arm-kernel, iommu, linux-kernel, Artem Savkov
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device
2017-08-08 8:58 [PATCH] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device Artem Savkov
@ 2017-08-08 9:26 ` Will Deacon
2017-08-08 10:26 ` [PATCH v2] " Artem Savkov
0 siblings, 1 reply; 6+ messages in thread
From: Will Deacon @ 2017-08-08 9:26 UTC (permalink / raw)
To: Artem Savkov; +Cc: Vivek Gautam, linux-arm-kernel, iommu, linux-kernel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device
2017-08-08 9:26 ` Will Deacon
@ 2017-08-08 10:26 ` Artem Savkov
2017-08-08 10:37 ` Robin Murphy
0 siblings, 1 reply; 6+ messages in thread
From: Artem Savkov @ 2017-08-08 10:26 UTC (permalink / raw)
To: Will Deacon
Cc: Vivek Gautam, linux-arm-kernel, iommu, linux-kernel, Artem Savkov
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device
2017-08-08 10:26 ` [PATCH v2] " Artem Savkov
@ 2017-08-08 10:37 ` Robin Murphy
2017-08-08 11:21 ` Will Deacon
0 siblings, 1 reply; 6+ messages in thread
From: Robin Murphy @ 2017-08-08 10:37 UTC (permalink / raw)
To: Artem Savkov, Will Deacon; +Cc: iommu, linux-arm-kernel, linux-kernel
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) {
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device
2017-08-08 10:37 ` Robin Murphy
@ 2017-08-08 11:21 ` Will Deacon
[not found] ` <20170808112144.GE13355-5wv7dgnIgG8@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Will Deacon @ 2017-08-08 11:21 UTC (permalink / raw)
To: Robin Murphy; +Cc: Artem Savkov, iommu, linux-arm-kernel, linux-kernel, joro
[+ 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) {
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device
[not found] ` <20170808112144.GE13355-5wv7dgnIgG8@public.gmane.org>
@ 2017-08-09 21:41 ` David Daney
0 siblings, 0 replies; 6+ messages in thread
From: David Daney @ 2017-08-09 21:41 UTC (permalink / raw)
To: Will Deacon, Robin Murphy
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Artem Savkov,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On 08/08/2017 04:21 AM, Will Deacon wrote:
> [+ 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-5wv7dgnIgG8@public.gmane.org>
>>
>> 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-5wv7dgnIgG8@public.gmane.org>
>
> Joerg, can you pick this up as a fix for 4.13, please?
I hit the Oops as well. This patch fixes it for me on a Cavium CN88xx
system, so:
Acked-by: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
Thanks for working on this.
>
> Will
>
>>> Signed-off-by: Artem Savkov <asavkov-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>>> ---
>>> 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) {
>>>
>>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-08-09 21:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-08 8:58 [PATCH] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device Artem Savkov
2017-08-08 9:26 ` Will Deacon
2017-08-08 10:26 ` [PATCH v2] " Artem Savkov
2017-08-08 10:37 ` Robin Murphy
2017-08-08 11:21 ` Will Deacon
[not found] ` <20170808112144.GE13355-5wv7dgnIgG8@public.gmane.org>
2017-08-09 21:41 ` David Daney
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).