瀏覽代碼

Kernel: Reject loading ELF files with no loadable segments

If there's no loadable segments then there can't be any code to execute
either. This resolves a crash these kinds of ELF files would cause from
the directly following VERIFY statement.
Idan Horowitz 1 年之前
父節點
當前提交
1bea780a7f
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      Kernel/Syscalls/execve.cpp

+ 4 - 0
Kernel/Syscalls/execve.cpp

@@ -201,6 +201,10 @@ static ErrorOr<RequiredLoadRange> get_required_load_range(OpenFileDescription& p
             range.end = region_end;
     });
 
+    // If there's nothing to load, there's nothing to execute
+    if (range.start == range.end)
+        return EINVAL;
+
     VERIFY(range.end > range.start);
     return range;
 }