Skip to contentSkip to conversation

module: Prevent crash by resetting local_err in module_load_qom_all()

PATCH Applied Alexander Ivanov 5 participants 7 messages Aug 9, 2024 – Aug 13, 2024

lore
Share & tools
lore
#0 lore raw

cover module: Prevent crash by resetting local_err in module_load_qom_all()

After updating QEMU modules previously executed QEMU processes crash on module loading. It happens because error_setg() calls with a not NULL errp argument.

There is a discussion - https://issues.redhat.com/browse/RHEL-29848

Alexander Ivanov (1):
module: Prevent crash by resetting local_err in module_load_qom_all()

 util/module.c | 1 +
 1 file changed, 1 insertion(+)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/1 module: Prevent crash by resetting local_err in module_load_qom_all()

Set local_err to NULL after it has been freed in error_report_err(). This avoids triggering assert(*errp == NULL) failure in error_setv() when local_err is reused in the loop.

---
 util/module.c | 1 +
 1 file changed, 1 insertion(+)
util/module.c +1 -0
index 32e263163c..3ff4aee2ca 100644
@@ -369,6 +369,7 @@ void module_load_qom_all(void)
         }
         if (module_load("", modinfo->name, &local_err) < 0) {
             error_report_err(local_err);
+            local_err = NULL;
         }
     }
     module_loaded_qom_all = true;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#2 lore raw
Quoted 14 lines · Alexander Ivanov

Set local_err to NULL after it has been freed in error_report_err(). This avoids triggering assert(*errp == NULL) failure in error_setv() when local_err is reused in the loop.

---
  util/module.c | 1 +
  1 file changed, 1 insertion(+)
util/module.c +0 -0
index 32e263163c..3ff4aee2ca 100644

util/module.c void module_load_qom_all(void) · line 375

Quoted 7 lines
util/module.c +1 -0
@@ -369,6 +369,7 @@ void module_load_qom_all(void)
          }
          if (module_load("", modinfo->name, &local_err) < 0) {
              error_report_err(local_err);
+            local_err = NULL;
          }
      }
      module_loaded_qom_all = true;
Reviewed-by on v1 1/1
#3 lore raw
In reply to Alexander Ivanov
Quoted 14 lines · Alexander Ivanov

Set local_err to NULL after it has been freed in error_report_err(). This avoids triggering assert(*errp == NULL) failure in error_setv() when local_err is reused in the loop.

---
 util/module.c | 1 +
 1 file changed, 1 insertion(+)
util/module.c +0 -0
index 32e263163c..3ff4aee2ca 100644

util/module.c void module_load_qom_all(void) · line 375

Quoted 7 lines
util/module.c +1 -0
@@ -369,6 +369,7 @@ void module_load_qom_all(void)
         }
         if (module_load("", modinfo->name, &local_err) < 0) {
             error_report_err(local_err);
+            local_err = NULL;
         }
     }
     module_loaded_qom_all = true;
#4 lore raw
In reply to Alexander Ivanov
Quoted 14 lines · Alexander Ivanov

Set local_err to NULL after it has been freed in error_report_err(). This avoids triggering assert(*errp == NULL) failure in error_setv() when local_err is reused in the loop.

---
  util/module.c | 1 +
  1 file changed, 1 insertion(+)
util/module.c +0 -0
index 32e263163c..3ff4aee2ca 100644

util/module.c void module_load_qom_all(void) · line 375

Quoted 7 lines
util/module.c +1 -0
@@ -369,6 +369,7 @@ void module_load_qom_all(void)
          }
          if (module_load("", modinfo->name, &local_err) < 0) {
              error_report_err(local_err);
+            local_err = NULL;
          }
      }
      module_loaded_qom_all = true;

Better, IMO, to move local_err and its initialization into the loop.

r~

#5 lore raw
Quoted 10 lines · Richard Henderson
Quoted 9 lines · Alexander Ivanov

Set local_err to NULL after it has been freed in error_report_err(). This avoids triggering assert(*errp == NULL) failure in error_setv() when local_err is reused in the loop.

---
  util/module.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 14 lines

util/module.c void module_load_qom_all(void) · line 375

Quoted 12 lines
util/module.c +1 -0
index 32e263163c..3ff4aee2ca 100644
@@ -369,6 +369,7 @@ void module_load_qom_all(void)
           }
           if (module_load("", modinfo->name, &local_err) < 0) {
               error_report_err(local_err);
+            local_err = NULL;
           }
       }
       module_loaded_qom_all = true;

Better, IMO, to move local_err and its initialization into the loop.

Yes, I agree, it makes sense.

Quoted 3 lines

r~

Signature · 2 lines
Best regards,
Alexander Ivanov