mbox series

[LEDE-DEV,0/3] protect init scripts from races

Message ID 20171214215317.4724-1-roman@advem.lv
Headers show
Series protect init scripts from races | expand

Message

Roman Yeryomin Dec. 14, 2017, 9:53 p.m. UTC
There is a potential race condition when init scripts are executed
from different contexts, e.g. procd and hotplug. Easiest way to reproduce
is to run restart/reload in background one after another several times.
This may result in generation of corrupted native config.

Originally this was noticed for dnsmasq, when init was generating duplicate
host entries and dnsmasq refused to start [1]. This was fixed with init
script reworks by using instance ids and temporary files, e.g. [2].

But it appeared the problem is not limited to dnsmasq and was noticed
also with other init scripts which generate native config files.

Thus, instead of fixing every init script separately, we can fix this
race in procd/base-files for everyone, using flock.


[1] https://dev.openwrt.org/ticket/19205
[2] 712b6fdc5c1d56287e1f4eae5724590b241b5674

Roman Yeryomin (3):
  busybox: enable flock by default
  procd: introduce procd_lock for init script protection
  base-files: protect stop and reload actions with procd_lock

 package/base-files/files/etc/rc.common   |  2 ++
 package/system/procd/files/procd.sh      | 15 +++++++++++++++
 package/utils/busybox/Config-defaults.in |  2 +-
 3 files changed, 18 insertions(+), 1 deletion(-)