[Bug 1271] New: iptables-restore may double-lock when using --table
bugzilla-daemon at netfilter.org
bugzilla-daemon at netfilter.org
Fri Jul 13 19:47:10 CEST 2018
https://bugzilla.netfilter.org/show_bug.cgi?id=1271
Bug ID: 1271
Summary: iptables-restore may double-lock when using --table
Product: iptables
Version: 1.6.x
Hardware: x86_64
OS: Fedora
Status: NEW
Severity: minor
Priority: P5
Component: iptables-restore
Assignee: netfilter-buglog at lists.netfilter.org
Reporter: contact+netfilter at jgoguen.ca
Created attachment 541
--> https://bugzilla.netfilter.org/attachment.cgi?id=541&action=edit
Path to free the lock when skipping a table
Currently, when running `iptables-restore --table=X`, where `X` is not the
first
table in the rules dump, the restore will fail when parsing the second table:
- a lock is acquird when parsing the first table name
- the table name does not match the parameter to `--table` so processing
continues until the next table
- when processing the next table a lock is acquired, which fails because a lock
is already held
This will release the lock as soon as it's decided the current table won't be
used.
With existing code:
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
# iptables-restore <iptables.dump
Another app is currently holding the xtables lock. Perhaps you want to use
the -w option?
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
With the change from the attached patch:
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
# iptables-restore <iptables.dump
# iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state
RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
REJECT tcp -- anywhere anywhere tcp
dpt:netbios-ns reject-with icmp-port-unreachable
REJECT udp -- anywhere anywhere udp
dpt:netbios-ns reject-with icmp-port-unreachable
And the test suite:
# ./iptables/tests/shell/run-tests.sh
I: [OK] ././iptables/tests/shell/testcases/chain/0001duplicate_1
I: [OK] ././iptables/tests/shell/testcases/chain/0002newchain_0
I: [OK] ././iptables/tests/shell/testcases/chain/0003rename_1
I: [OK] ././iptables/tests/shell/testcases/ebtables/0001-ebtables-
basic_0
I: [OK] ././iptables/tests/shell/testcases/firewalld-restore/0001-
firewalld_0
I: [OK] ././iptables/tests/shell/testcases/firewalld-restore/0002-
firewalld-restart_0
I: [OK] ././iptables/tests/shell/testcases/ipt-restore/0001load-
specific-table_0
I: [OK] ././iptables/tests/shell/testcases/ipt-save/0001load-
dumps_0
I: [OK] ././iptables/tests/shell/testcases/ipt-save/0002load-
fedora27-firewalld_0
I: legacy results: [OK] 9 [FAILED] 0 [TOTAL] 9
I: [OK] ././iptables/tests/shell/testcases/chain/0001duplicate_1
I: [OK] ././iptables/tests/shell/testcases/chain/0002newchain_0
I: [OK] ././iptables/tests/shell/testcases/chain/0003rename_1
I: [OK] ././iptables/tests/shell/testcases/ebtables/0001-ebtables-
basic_0
I: [OK] ././iptables/tests/shell/testcases/firewalld-restore/0001-
firewalld_0
I: [OK] ././iptables/tests/shell/testcases/firewalld-restore/0002-
firewalld-restart_0
I: [OK] ././iptables/tests/shell/testcases/ipt-restore/0001load-
specific-table_0
I: [OK] ././iptables/tests/shell/testcases/ipt-save/0001load-
dumps_0
I: [OK] ././iptables/tests/shell/testcases/ipt-save/0002load-
fedora27-firewalld_0
I: nft results: [OK] 9 [FAILED] 0 [TOTAL] 9
I: combined results: [OK] 18 [FAILED] 0 [TOTAL] 18
--
You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.netfilter.org/pipermail/netfilter-buglog/attachments/20180713/c8fea00a/attachment.html>
More information about the netfilter-buglog
mailing list