mirror of
				https://git.zx2c4.com/wireguard-go
				synced 2025-10-31 20:02:37 +08:00 
			
		
		
		
	device: wait for and lock ipc operations during close
If an IPC operation is in flight while close starts, it is possible for both processes to deadlock. Prevent this by taking the IPC lock at the start of close and for the duration. Signed-off-by: James Tucker <jftucker@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		 James Tucker
					James Tucker
				
			
				
					committed by
					
						 Jason A. Donenfeld
						Jason A. Donenfeld
					
				
			
			
				
	
			
			
			 Jason A. Donenfeld
						Jason A. Donenfeld
					
				
			
						parent
						
							052af4a807
						
					
				
				
					commit
					b7cd547315
				
			| @@ -368,6 +368,8 @@ func (device *Device) RemoveAllPeers() { | |||||||
| } | } | ||||||
|  |  | ||||||
| func (device *Device) Close() { | func (device *Device) Close() { | ||||||
|  | 	device.ipcMutex.Lock() | ||||||
|  | 	defer device.ipcMutex.Unlock() | ||||||
| 	device.state.Lock() | 	device.state.Lock() | ||||||
| 	defer device.state.Unlock() | 	defer device.state.Unlock() | ||||||
| 	if device.isClosed() { | 	if device.isClosed() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user