RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1749698 - TestOnly: iptables-restore fails if comment contains '-' and 't'
Summary: TestOnly: iptables-restore fails if comment contains '-' and 't'
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: iptables
Version: 8.2
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: 8.0
Assignee: Phil Sutter
QA Contact: Jiri Peska
Depends On:
Blocks: 1749700
TreeView+ depends on / blocked
Reported: 2019-09-06 09:14 UTC by Phil Sutter
Modified: 2023-03-26 09:06 UTC (History)
4 users (show)

Fixed In Version: iptables-1.8.4-4.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1749700 (view as bug list)
Last Closed: 2020-04-28 17:00:25 UTC
Type: Bug
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-28553 0 None None None 2023-03-26 09:06:30 UTC
Red Hat Product Errata RHEA-2020:1889 0 None None None 2020-04-28 17:00:45 UTC

Description Phil Sutter 2019-09-06 09:14:59 UTC
Seems like iptables-restore parser is buggy:

# iptables -A FORWARD -m comment --comment "-t foo bar" -j ACCEPT
# iptables-save >/tmp/ipt.dump
# grep -v '^#' /tmp/ipt.dump
-A FORWARD -m comment --comment "-t foo bar" -j ACCEPT
# iptables-restore </tmp/ipt.dump
iptables-nft-restore v1.8.3 (nf_tables): The -t option (seen in line 7) cannot be used in iptables-nft-restore.

Error occurred at line: 7
Try `iptables-nft-restore -h' or 'iptables-nft-restore --help' for more information.

The Problem is consistent with upstream and happens with legacy as well as nft
variant. RHEL7 iptables-1.4.21-28.el7.x86_64 is reported to work correctly, so
this is a regression.

Comment 1 Phil Sutter 2019-09-20 15:52:22 UTC
Correction: The actual bug (and regression) is rejecting of comments starting
with dash and having a 't' somewhere, not '-t' itself (this was never allowed).

A testcase for this is:

| *filter
| -A FORWARD -m comment --comment "- allow this" -j ACCEPT

Fix sent upstream: https://lore.kernel.org/netfilter-devel/20190920154920.7927-1-phil@nwl.cc/T/#u

Comment 2 Phil Sutter 2019-10-21 17:17:16 UTC
Upstream commit to backport:

commit 3dc433b55bbfaf9df3ee408aaa6282742f377864
Author: Phil Sutter <phil>
Date:   Fri Sep 20 17:31:58 2019 +0200

    xtables-restore: Fix --table parameter check
    Xtables-restore tries to reject rule commands in input which contain a
    --table parameter (since it is adding this itself based on the previous
    table line). The manual check was not perfect though as it caught any
    parameter starting with a dash and containing a 't' somewhere, even in
    rule comments:
    | *filter
    | -A FORWARD -m comment --comment "- allow this one" -j ACCEPT
    | COMMIT
    Instead of error-prone manual checking, go a much simpler route: All
    do_command callbacks are passed a boolean indicating they're called from
    *tables-restore. React upon this when handling a table parameter and
    error out if it's not the first one.
    Fixes: f8e5ebc5986bf ("iptables: Fix crash on malformed iptables-restore")
    Signed-off-by: Phil Sutter <phil>
    Acked-by: Florian Westphal <fw>

Comment 3 Phil Sutter 2019-10-28 07:00:12 UTC
Follow-up of above commit which also needs backporting:

commit 4e470fa34761085144640fb561a9ad26b2cde382
Author: Phil Sutter <phil>
Date:   Tue Oct 22 12:25:28 2019 +0200

    xtables-restore: Unbreak *tables-restore
    Commit 3dc433b55bbfa ("xtables-restore: Fix --table parameter check")
    installed an error check which evaluated true in all cases as all
    callers of do_command callbacks pass a pointer to a table name already.
    Attached test case passed as it tested error condition only.
    Fix the whole mess by introducing a boolean to indicate whether a table
    parameter was seen already. Extend the test case to cover positive as
    well as negative behaviour and to test ebtables-restore and
    ip6tables-restore as well. Also add the required checking code to the
    latter since the original commit missed it.
    Fixes: 3dc433b55bbfa ("xtables-restore: Fix --table parameter check")
    Signed-off-by: Phil Sutter <phil>
    Acked-by: Pablo Neira Ayuso <pablo>

Comment 4 Phil Sutter 2019-12-05 10:13:47 UTC
Fixed implicitly by rebase to 1.8.4 release.

Comment 7 errata-xmlrpc 2020-04-28 17:00:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.