balena-os / meta-balena

A collection of Yocto layers used to build balenaOS images
https://www.balena.io/os
971 stars 115 forks source link

NetworkManager: do not use FW rule numbers in shared dispatcher script #3429

Closed mtoman closed 1 month ago

mtoman commented 1 month ago

Manipulating the firewall rules by index introduces a race condition. Both NetworkManager and balenaEngine add the rules to the top of the FORWARD chain instead of appending, so if we first look up a rule by number and then use the number to refer to it, we can not guarantee that the rule number has not changed (iow the rule has not been moved down) in the meantime.

This patch removes the use of rule numbers completely and makes the "shared" dispatcher script refer to the rules by definition.


Contributor checklist

Reviewer Guidelines

mtoman commented 1 month ago

@resin-jenkins retest this please