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] [day] [month] [year] [list]
Message-ID: <43c2227a-71c9-4cbf-bfec-5a2fbf698f27@os.amperecomputing.com>
Date: Thu, 3 Oct 2024 08:31:23 -0700
From: Yang Shi <yang@...amperecomputing.com>
To: Jason Gunthorpe <jgg@...pe.ca>
Cc: Nicolin Chen <nicolinc@...dia.com>, james.morse@....com, will@...nel.org,
 robin.murphy@....com, linux-arm-kernel@...ts.infradead.org,
 linux-kernel@...r.kernel.org
Subject: Re: [v2 PATCH] iommu/arm-smmu-v3: Fix L1 stream table index
 calculation for 32-bit sid size



On 10/3/24 4:16 AM, Jason Gunthorpe wrote:
> On Wed, Oct 02, 2024 at 01:05:08PM -0700, Yang Shi wrote:
>>> It would make some sense to have something like:
>>>
>>>    u64 size = arm_smmu_strtab_max_sid()
>>>
>>>    /* Would require too much memory */
>>>    if (size > SZ_512M)
>>>       return -EINVAL;
>> Why not just check smmu->sid_bits?
>>
>> For example,
>>
>> if (smmu->sid_bits > 28)
>>      return -EINVAL;
>>
>> The check can happen before the shift.
> Sure, but IMHO it reads a bit better to check the size computed from
> the helper
>
> MAX_PAGE_ORDER is often 10, so kmalloc will always fail before we
> reach 28 bits of sid space.

I'm wondering we may just use 31 instead of using some magic number:

if (smmu->sid_bits > 31)
     return -EINVAL;

If I understand correctly, the check is mainly used to avoid the u64 -> 
u32 overflow. This check guarantee no overflow. If some crazy hardware 
really requests that large memory, the allocation will fail.

>
> Jason


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ