Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752272AbdHIVl5 (ORCPT ); Wed, 9 Aug 2017 17:41:57 -0400 Received: from mail-sn1nam02on0065.outbound.protection.outlook.com ([104.47.36.65]:19040 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752084AbdHIVl4 (ORCPT ); Wed, 9 Aug 2017 17:41:56 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@cavium.com; Subject: Re: [PATCH v2] iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device To: Will Deacon , Robin Murphy Cc: Artem Savkov , joro@8bytes.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20170808092614.GB12887@arm.com> <1502187962-16861-1-git-send-email-asavkov@redhat.com> <20170808112144.GE13355@arm.com> From: David Daney Message-ID: Date: Wed, 9 Aug 2017 14:41:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170808112144.GE13355@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: DM5PR07CA0048.namprd07.prod.outlook.com (10.168.109.34) To CY4PR07MB3494.namprd07.prod.outlook.com (10.171.252.151) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 00ab4ff1-ccc7-4dba-0233-08d4df6f73f8 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY4PR07MB3494; X-Microsoft-Exchange-Diagnostics: 1;CY4P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4QtvSNkk83DZcYgJtldEUJDjqIYHSujHUzKShwGVI5dHjA/OBO8whB2mQ0AHROhEdJYWTG1OLy17E20yDdr4k7MeWEFeDmNtBUV+ynUivEQKrvnJpwpdp0fDSdPTGUMem2pKPmjYqVDKLD7Xj69Tp0MwqR//wq8Dnz9r9v0nO2/MBjx85LzQ8S95+nX7e0i15FOASeCifBJS1tl91o5nNP94UYQrk7Fj7YugKGjFUeE2xBmeFPMEYCsUKfQrE74jZvdJYO4lsk3GZNkQe+vLL3u0i/YRpHSvSgYIKCUd+C3pEWqPQw1G0xGPu9mlhZrZmflSQgc7UHMoUTHbLLLI4n++ahh8afFKjGG+k+pc4KQGnEOOljkF6yj+cEKdzhoFLlej9q+vB1CM2xojcsVtduWiyuTbFb/C2CcEmDe3k633l18LK+WHQgjIJOWDRmCwy412xoKGY3Frjk= X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(258649278758335); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123555025)(20161123560025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR07MB3494;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR07MB3494; X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB3494;4:VCLSi49RsUMlkDTv7HoYShJOM42utRtIvPIkUbak4m7MIRsO6fQUJ726Pf6Ma6zND8QnkteXHQV0ujNFqL1SQ8pykC5Yt7KmsmX63iYy68PwzCV2VTjkUkEVRJoUYGkhFouRDwxm/fbLyaeeeMEnIcO81OO770NPyTPQ0llZgS0QboyWALQ522E0ZCSgxONO8HlS6UvtvmiK8lgZnvpmjSolzbB1gW8NKaO20ZdNDb6a7yGtqYhT5GczCiYOmY58XOXmhkqOxQgR99YE8Cn4JcGkoSIPi6BacqwQh/E1yZyWVwj2U7MPyqkh+TTjgYtf2W9WYMDY8P2X8Kmcj26Gjw== X-Forefront-PRVS: 0394259C80 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(39840400002)(39450400003)(39850400002)(39410400002)(39400400002)(24454002)(199003)(189002)(377454003)(7350300001)(6506006)(38730400002)(6486002)(53416004)(53546010)(229853002)(1720100001)(66066001)(65956001)(105586002)(6246003)(93886004)(65806001)(106356001)(47776003)(4001350100001)(36756003)(42882006)(83506001)(2950100002)(72206003)(64126003)(69596002)(5660300001)(65826007)(33646002)(42186005)(68736007)(7736002)(31686004)(4326008)(966005)(31696002)(6306002)(23676002)(478600001)(305945005)(6512007)(3846002)(230700001)(76176999)(81166006)(54356999)(50986999)(2906002)(25786009)(81156014)(53936002)(189998001)(101416001)(97736004)(6116002)(8676002)(50466002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR07MB3494;H:ddl.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjA3TUIzNDk0OzIzOlRrQlllckRWNjFuOFQxMnkvWFVRRmI4L2JO?= =?utf-8?B?Z3N5V3M2LzhXeGxCa1Y5Q25ZaHJvRU5jWU9VVm9sclpjTXBMRDFSaDRSV1VD?= =?utf-8?B?SEZwSmtITHRRdlN1ZnpERnYrZVRjTzBuZHVKOVJzNXptWXBNM25XVE1GdXla?= =?utf-8?B?dFJCMVZ0eThIdGhYMnZEeUwyYUJNellUY3FzTXEvOGNSaC9URmxScHFCbVdo?= =?utf-8?B?VTJEWUl6RFRKSitVVVdST1FRVDN2dEdhUXpxTGppSVRqR2wzdU1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Metadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2017 21:41:54.0142 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3494 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2083 Lines: 65 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 >> >> 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 > > 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 Thanks for working on this. > > Will > >>> Signed-off-by: Artem Savkov >>> --- >>> 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@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >