Systemcrash by using procd_add_jail

I wrote a procd-init-script to start my own application in a jail. After the service is started, the system will crashes. After this crash, the system is irreparable and must be reinstalled.

I have searched and read the documentation but cannot find a solution…

I am using OpenWRT 18.06.1 for the “Embedded Wireless Dorin Platform”.

The script is located under /etc/init.d/myservice

#!/bin/sh /etc/rc.common

START=99

USE_PROCD=1

start_service(){

        procd_open_instance

        procd_set_param command /opt/sbox/bin/sbox_app
        procd_set_param stdout 1
        procd_set_param stderr 1

        procd_add_jail app ubus log
        procd_add_jail_mount_rw /opt/ /lib/ /etc/passwd

        procd_close_instance
}

The service can be start without an error message.

root@OpenWrt:/etc/init.d# service myservice start

From this moment, all bash commands produce the following error message:

root@OpenWrt:/etc/init.d# ls
/bin/ash: ls: I/O error

It is also not possible to boot the device. The same error message appears:

[    6.477412] eth0: link up (1000Mbps/Full duplex)
[    6.480611] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    8.109234] jffs2: notice: (368) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[    8.125566] mount_root: switching to jffs2 overlay
[    8.173413] urandom-seed: Seeding with /etc/urandom.seed
/etc/preinit: line 1: cat: I/O error
/etc/preinit: line 1: uci: I/O error
/etc/preinit: line 1: cat: I/O error
/etc/preinit: line 1: grep: I/O error

However, without the line “procd_add_jail” the script works fine.

I can rule out that my own application damaged the system. It looks like the jail corrupted the root file system.

To be able to use the jail, I selected the property on OpenWrt-Build.

Furthermore, I read the OpenWrt documentation:

https://openwrt.org/docs/guide-developer/procd-init-scripts

https://openwrt.org/docs/techref/procd

https://openwrt.org/docs/techref/initscripts

The dnsmasq service also uses a jail, which seems to work. I have also considered this code, but I cannot detect a difference or missing code.

I have looked at the code of procd, but could not find any solution. The openwrt-devel mailing list also does not include some information about this topic.

Any ideas on how to use the jail?