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]
Date:   Tue, 6 Sep 2022 14:37:18 +0100
From:   Robin Murphy <robin.murphy@....com>
To:     John Garry <john.garry@...wei.com>,
        Ethan Zhao <haifeng.zhao@...ux.intel.com>, joro@...tes.org,
        will@...nel.org
Cc:     iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
        linuxarm@...wei.com
Subject: Re: [PATCH v2 1/2] iova: Remove some magazine pointer NULL checks

On 2022-09-06 11:50, John Garry wrote:
> On 06/09/2022 10:28, Ethan Zhao wrote:
> 
> Hi Ethan,
> 
>>> Signed-off-by: John Garry <john.garry@...wei.com>
>>> Reviewed-by: Robin Murphy <robin.murphy@....com>
>>> ---
>>>   drivers/iommu/iova.c | 7 ++-----
>>>   1 file changed, 2 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
>>> index 47d1983dfa2a..580fdf669922 100644
>>> --- a/drivers/iommu/iova.c
>>> +++ b/drivers/iommu/iova.c
>>> @@ -661,9 +661,6 @@ iova_magazine_free_pfns(struct iova_magazine 
>>> *mag, struct iova_domain *iovad)
>>>       unsigned long flags;
>>>       int i;
>>> -    if (!mag)
>>> -        return;
>>> -
>>
>> iommu_probe_device
>>    ops->probe_finalize(dev);
>>      intel_iommu_probe_finalize
>>         iommu_setup_dma_ops
>>           iommu_dma_init_domain(domain, dma_base, dma_limit, dev)
>>             iova_domain_init_rcaches
>>               {
>>               ...
>>               cpu_rcache->loaded = iova_magazine_alloc(GFP_KERNEL);
>>               cpu_rcache->prev = iova_magazine_alloc(GFP_KERNEL);
>>             if (!cpu_rcache->loaded || !cpu_rcache->prev) {
>>                  ret = -ENOMEM;
>>                        goto out_err;
>>
>> Do you mean iova_magazine_alloc() is impossible to fail ?
> 
> No, iova_magazine_alloc() may fail and return NULL. But if it does then 
> we set iovad rcache pointer = NULL in the error path and don't use the 
> rcache.
> 
> However we have a !iovad->rcache check on the "fast" alloc but not 
> "insert". I need to check why that is again.

Right, if you find a good reason to respin the patch then perhaps also 
tweaking the commit message to clarify that it's impossible to have a 
NULL rcache *at any point where those checks are made* might avoid all 
possible doubt, however I'd hope that it's clear enough that the 
transient case while iova_domain_init_rcaches() is in the process of 
failing really doesn't need consideration in its own right.

I guess the check in iova_rcache_get() was maybe with the intent of 
allowing alloc_iova_fast() to seamlessly fall back to standard 
allocation, so an API user can treat iova_domain_init_rcaches() failure 
as non-fatal? That makes a fair amount of sense, but does mean that 
we're missing the equivalent in iova_rcache_insert() for it to actually 
work. Or we just remove it and tighten up the documentation to say 
that's not valid - I would like a way to make rcaches optional in 
iommu-dma for systems where they're a pointless waste of memory, but we 
can always revisit this when we get there.

Cheers,
Robin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ