From 20d042025bd8e1f91bb1fec20ae1509a08bfa4ef Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 6 Mar 2024 14:47:02 +0100 Subject: sys/linux: clone args before mutation Not cloning the argument results in replaceArg() replacing a union argument with itself, which may lead to inconsistent resource references. Add an assertion to detect such cases in the future. --- sys/linux/init_iptables.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/linux/init_iptables.go') diff --git a/sys/linux/init_iptables.go b/sys/linux/init_iptables.go index 7e96662fb..95825d33c 100644 --- a/sys/linux/init_iptables.go +++ b/sys/linux/init_iptables.go @@ -31,7 +31,7 @@ func (arch *arch) generateNetfilterTable(g *prog.Gen, typ prog.Type, dir prog.Di } else { // TODO(dvyukov): try to restore original hook order after mutation // instead of assigning brand new offsets. - arg = old + arg = prog.CloneArg(old) calls = g.MutateArg(arg) } var tableArg *prog.GroupArg @@ -113,7 +113,7 @@ func (arch *arch) generateEbtables(g *prog.Gen, typ prog.Type, dir prog.Dir, old } else { // TODO(dvyukov): try to restore original hook order after mutation // instead of assigning brand new offsets. - arg = old + arg = prog.CloneArg(old) calls = g.MutateArg(arg) } if g.Target().ArgContainsAny(arg) { -- cgit mrf-deployment