mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	Kernel: Handle promise violations in the syscall handler
Previously we would crash the process immediately when a promise violation was found during a syscall. This is error prone, as we don't unwind the stack. This means that in certain cases we can leak resources, like an OwnPtr / RefPtr tracked on the stack. Or even leak a lock acquired in a ScopeLockLocker. To remedy this situation we move the promise violation handling to the syscall handler, right before we return to user space. This allows the code to follow the normal unwind path, and grantees there is no longer any cleanup that needs to occur. The Process::require_promise() and Process::require_no_promises() functions were modified to return ErrorOr<void> so we enforce that the errors are always propagated by the caller.
This commit is contained in:
		
							parent
							
								
									c444a3fc9e
								
							
						
					
					
						commit
						54b9a4ec1e
					
				
					 66 changed files with 156 additions and 148 deletions
				
			
		|  | @ -13,7 +13,7 @@ namespace Kernel { | |||
| ErrorOr<FlatPtr> Process::sys$rmdir(Userspace<const char*> user_path, size_t path_length) | ||||
| { | ||||
|     VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) | ||||
|     require_promise(Pledge::cpath); | ||||
|     TRY(require_promise(Pledge::cpath)); | ||||
|     auto path = TRY(get_syscall_path_argument(user_path, path_length)); | ||||
|     TRY(VirtualFileSystem::the().rmdir(path->view(), current_directory())); | ||||
|     return 0; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brian Gianforcaro
						Brian Gianforcaro