Re: [PATCH v2 1/2] PCI: endpoint: Fix API pci_epc_destroy() releasing domain_nr ID faults

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/12/2024 3:03 PM, Manivannan Sadhasivam wrote:
> On Thu, Nov 07, 2024 at 08:53:08AM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>>
>> pci_epc_destroy() invokes pci_bus_release_domain_nr() to release domain_nr
>> ID, but the invocation has below 2 faults:
>>
>> - The later accesses device @epc->dev which has been kfree()ed by previous
>>   device_unregister(), namely, it is a UAF issue.
>>
>> - The later frees the domain_nr ID into @epc->dev, but the ID is actually
>>   allocated from @epc->dev.parent, so it will destroy domain_nr IDA.
>>
>> Fix by freeing the ID to @epc->dev.parent before unregistering @epc->dev.
>>
>> The file(s) affected are shown below since they indirectly use the API.
>> drivers/pci/controller/cadence/pcie-cadence-ep.c
>> drivers/pci/controller/dwc/pcie-designware-ep.c
>> drivers/pci/controller/pcie-rockchip-ep.c
>> drivers/pci/controller/pcie-rcar-ep.c
> 
> No need to mention the callers.
> 

thank you Manivannan for code review.
good suggestions, i will take them for further similar patches.(^^)

>>
>> Fixes: 0328947c5032 ("PCI: endpoint: Assign PCI domain number for endpoint controllers")
>> Cc: Lorenzo Pieralisi <lpieralisi@xxxxxxxxxx>
>> Cc: Jingoo Han <jingoohan1@xxxxxxxxx>
>> Cc: Marek Vasut <marek.vasut+renesas@xxxxxxxxx>
>> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>
>> Cc: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>
>> Cc: Heiko Stuebner <heiko@xxxxxxxxx>
>> Cc: stable@xxxxxxxxxxxxxxx
>> Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
> 
> Good catch! (not sure how I messed up in first place).
> 
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
> 
> - Mani
> 
>> ---

[snip]

>>
> 





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux