ios dns proxy sys extension process not re-spawn automatically after crash

Hi there,

This is the case of using dns proxy provider on ios. One thing noticed is that when the system extension process of dns proxy crashes, it is not re-spawn automatically by the wrapper process as it is when using the same dns proxy provider under macOS.

The test I carried out was:

  • Under macOS

Launch an application with dns proxy provider sys extension. Kill that sys extension process. After several seconds, another sys extension process of dns proxy extension will be re-spawn.

sudo ps -A|grep macappproxy
Password:
47796 ??     0:00.35 /Applications/macappproxy.app/Contents/MacOS/macappproxy
47875 ??     0:00.62 /Library/SystemExtensions/439F12A7-1304-4A92-BEED-3EBEC979ADBE/com.familyzone.macappproxy.fzmacdnsproxy.systemextension/Contents/MacOS/com.familyzone.macappproxy.fzmacdnsproxy
47929 ttys001  0:00.00 grep macappproxy
AU-L-0306:fc-ios-edu-client richardwang$ sudo pkill -9 com.familyzone.macappproxy.fzmacdnsproxy
AU-L-0306:fc-ios-edu-client richardwang$ sudo ps -A|grep macappproxy
47796 ??     0:00.35 /Applications/macappproxy.app/Contents/MacOS/macappproxy
48433 ??     0:00.31 /Library/SystemExtensions/439F12A7-1304-4A92-BEED-3EBEC979ADBE/com.familyzone.macappproxy.fzmacdnsproxy.systemextension/Contents/MacOS/com.familyzone.macappproxy.fzmacdnsproxy
48531 ttys001  0:00.00 grep macappproxy

We can see from above that dns proxy pid changed after it was killed and re-spawn.

  • Under ios

Doing the same thing, but slightly different: By adding below code into startProxy(), crashing dns proxy.

1		let bug: Int? = nil
2		os_log("bug: %{public}s", log: Log.ext, type: .debug, bug!)

It can be seen from below the log that “starting proxy“ happens three times before it died. It makes no difference if we put the same bug inside handleNewFlow(). And that causes no browsing through under incognito mode.

Can you help confirm this? If it is the case, is there any way to guard sys extension process and respawn it as a kind of robusness?

Thanks in advance for any suggestion. Richard

As found that on ios if leave it long enough, that dns proxy extension process will get re-spawn again after crash. That is good to see.

I am glad you were able to see the re-spawn of the provider process for NEDNSProxyProvider on iOS. One thing to note here, although it does not affect your testing, is that on iOS a NEDNSProxyProvider runs a Network App Extension and on macOS a NEDNSProxyProvider can ONLY run a Network System Extension. A Network System Extension as long as it's configured properly, will always be running on the system, even when there is no user logged into the system. A system extension also runs with elevated privileges. The reason why I am mentioning this is because there is a slight difference in OS priority with the two extension and that may be why you are seeing difference in how the processes are re-spawned.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
ios dns proxy sys extension process not re-spawn automatically after crash
 
 
Q