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: <a745c910-f4be-62f6-cb02-a610c04f4698@intel.com>
Date:   Wed, 31 May 2023 15:09:56 +0800
From:   Yanfei Xu <yanfei.xu@...el.com>
To:     Baolu Lu <baolu.lu@...ux.intel.com>, <dwmw2@...radead.org>,
        <joro@...tes.org>, <will@...nel.org>, <robin.murphy@....com>
CC:     <iommu@...ts.linux.dev>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] iommu/vt-d: Use BUG_ON to check NULL value of 'table'

Hi Baolu,

On 5/31/2023 11:26 AM, Baolu Lu wrote:
> On 5/30/23 5:25 PM, Yanfei Xu wrote:
>> Checking NULL value of 'table' variable deserves a BUG_ON as the
>> following code will trigger a crash by dereferencing the NULL
>> 'table' pointer. Crash in advance with BUG_ON to avoid WARN_ON
>> plus NULL pointer dereferencing can simplify the crash log.
>>
>> Signed-off-by: Yanfei Xu<yanfei.xu@...el.com>
>> ---
>>   drivers/iommu/intel/iommu.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
>> index e98f1b122b49..8aa3bfdb7f95 100644
>> --- a/drivers/iommu/intel/iommu.c
>> +++ b/drivers/iommu/intel/iommu.c
>> @@ -1944,7 +1944,7 @@ static int domain_context_mapping_one(struct 
>> dmar_domain *domain,
>>       if (sm_supported(iommu)) {
>>           unsigned long pds;
>>   -        WARN_ON(!table);
>> +        BUG_ON(!table);
>
> BUG_ON() is not recommended. Perhaps,
>
>         if (!table)
>             -ENODEV;
>
Agree:) It is always better to handle the error than crash kernel.

How about:
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 8096273b034c..7f077e3a4128 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -1944,7 +1944,10 @@ static int domain_context_mapping_one(struct 
dmar_domain *domain,
         if (sm_supported(iommu)) {
                 unsigned long pds;

-               WARN_ON(!table);
+               if (WARN_ON(!table)) {
+                       ret = -ENODEV;
+                       goto out_unlock;
+               }

Thanks,
Yanfei

> ?
>
> Best regards,
> baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ