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] [thread-next>] [day] [month] [year] [list]
Message-ID: <a7a6a295-160a-94d6-09f9-63f783c8b28a@ti.com>
Date:   Fri, 20 Mar 2020 15:50:53 +0530
From:   Kishon Vijay Abraham I <kishon@...com>
To:     Sriram Dash <sriram.dash@...sung.com>,
        "'Shradha Todi'" <shradha.t@...sung.com>
CC:     <lorenzo.pieralisi@....com>, <bhelgaas@...gle.com>,
        <pankaj.dubey@...sung.com>, <linux-pci@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] PCI: endpoint: Fix NULL pointer dereference for
 ->get_features()

Hi Sriram,

On 3/19/2020 7:06 PM, Sriram Dash wrote:
>> From: Shradha Todi <shradha.t@...sung.com>
>> Subject: [PATCH] PCI: endpoint: Fix NULL pointer dereference for -
>>> get_features()
>>
>> get_features ops of pci_epc_ops may return NULL, causing NULL pointer
>> dereference in pci_epf_test_bind function. Let us add a check for
>> pci_epc_feature pointer in pci_epf_test_bind before we access it to avoid any
>> such NULL pointer dereference and return -ENOTSUPP in case pci_epc_feature
>> is not found.
>>
>> Reviewed-by: Pankaj Dubey <pankaj.dubey@...sung.com>
>> Signed-off-by: Sriram Dash <sriram.dash@...sung.com>
>> Signed-off-by: Shradha Todi <shradha.t@...sung.com>
>> ---
> 
> Hi Kishon,
> 
> Any update on this?

Don't we access epc_features only after checking if epc_features is not NULL in
pci_epf_test_bind() function? However we are accessing epc_features in multiple
other functions all over pci-epf-test.

So the patch itself is correct though the commit log has to be fixed. You
should also check if all the endpoint controller drivers existing currently
provides epc_features.

Thanks
Kishon
> 
> 
>>  drivers/pci/endpoint/functions/pci-epf-test.c | 15 +++++++++------
>>  1 file changed, 9 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c
>> b/drivers/pci/endpoint/functions/pci-epf-test.c
>> index c9121b1b9fa9..af4537a487bf 100644
>> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
>> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
>> @@ -510,14 +510,17 @@ static int pci_epf_test_bind(struct pci_epf *epf)
>>  		return -EINVAL;
>>
>>  	epc_features = pci_epc_get_features(epc, epf->func_no);
>> -	if (epc_features) {
>> -		linkup_notifier = epc_features->linkup_notifier;
>> -		msix_capable = epc_features->msix_capable;
>> -		msi_capable = epc_features->msi_capable;
>> -		test_reg_bar = pci_epc_get_first_free_bar(epc_features);
>> -		pci_epf_configure_bar(epf, epc_features);
>> +	if (!epc_features) {
>> +		dev_err(dev, "epc_features not implemented\n");
>> +		return -ENOTSUPP;
>>  	}
>>
>> +	linkup_notifier = epc_features->linkup_notifier;
>> +	msix_capable = epc_features->msix_capable;
>> +	msi_capable = epc_features->msi_capable;
>> +	test_reg_bar = pci_epc_get_first_free_bar(epc_features);
>> +	pci_epf_configure_bar(epf, epc_features);
>> +
>>  	epf_test->test_reg_bar = test_reg_bar;
>>  	epf_test->epc_features = epc_features;
>>
>> --
>> 2.17.1
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ