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 1818117 - assertion fails printed instead of error messages
Summary: assertion fails printed instead of error messages
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: nftables
Version: 8.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 8.0
Assignee: Phil Sutter
QA Contact: Štěpán Němec
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-03-27 18:45 UTC by Jiri Peska
Modified: 2021-11-10 09:40 UTC (History)
1 user (show)

Fixed In Version: nftables-0.9.3-19.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-09 19:53:44 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1763652 0 medium CLOSED nft core dumps with "netlink_gen_raw_data: Assertion `len > 0' failed" messages when interface name "*" is used. 2023-09-07 20:54:22 UTC
Red Hat Product Errata RHBA-2021:4465 0 None None None 2021-11-09 19:53:53 UTC

Internal Links: 1763652

Description Jiri Peska 2020-03-27 18:45:57 UTC
Description of problem:
When star (*) is used for iifname, failed assertion is shown. It should give an error, since the rule does not make much sense, but printed error should be more explanatory. 


Version-Release number of selected component (if applicable):
nftables-0.9.3-11.el8.x86_64


How reproducible:
always


Steps to Reproduce:
1. Create following file 
#cat ruleset.nft
add rule ip filter input iifname "*" ct state new accept

2. load ruleset from file
#nft -f ruleset.nft


Actual results:
nft: expression.c:394: constant_expr_alloc: Assertion `(((len) + (8) - 1) / (8)) > 0' failed.
Aborted (core dumped)


Expected results:
Explanatory error message instead of assertion.


Additional info:

Comment 1 Tomas Dolezal 2020-09-04 18:12:35 UTC
Adding Regression keyword. from nftables-0.9.3-12.el8 to nftables-0.9.3-16.el8 the output for following ruleset changed in a way that '\' before '*' in iifname is omitted thus cannot be saved and loaded again.

cropped output 1 (valid):
iifname "\*" meta l4proto tcp tcp dport 80 counter
cropped output 1 (invalid):
iifname "*" tcp dport 80 counter

cat > nft-a.rules <<EOF
flush ruleset
table ip filter {
	chain INPUT {
		type filter hook input priority filter; policy accept;
		iifname "\*" tcp dport 80 counter accept
	}
}
EOF
nft 'flush ruleset; include "./nft-a.rules"'
nft -s list ruleset > nft-b.rules
nft 'flush ruleset; include "./nft-b.rules"'
nft: expression.c:394: constant_expr_alloc: Assertion `(((len) + (8) - 1) / (8)) > 0' failed.
Aborted (core dumped)

cat nft-b.rules
table ip filter {
	chain INPUT {
		type filter hook input priority filter; policy accept;
		iifname "*" tcp dport 80 counter accept
	}
}

Comment 3 Phil Sutter 2020-10-06 13:02:32 UTC
(In reply to Tomas Dolezal from comment #1)
> Adding Regression keyword. from nftables-0.9.3-12.el8 to
> nftables-0.9.3-16.el8 the output for following ruleset changed in a way that
> '\' before '*' in iifname is omitted thus cannot be saved and loaded again.
> 
> cropped output 1 (valid):
> iifname "\*" meta l4proto tcp tcp dport 80 counter
> cropped output 1 (invalid):
> iifname "*" tcp dport 80 counter
> 
> cat > nft-a.rules <<EOF
> flush ruleset
> table ip filter {
> 	chain INPUT {
> 		type filter hook input priority filter; policy accept;
> 		iifname "\*" tcp dport 80 counter accept
> 	}
> }
> EOF
> nft 'flush ruleset; include "./nft-a.rules"'
> nft -s list ruleset > nft-b.rules
> nft 'flush ruleset; include "./nft-b.rules"'
> nft: expression.c:394: constant_expr_alloc: Assertion `(((len) + (8) - 1) /
> (8)) > 0' failed.
> Aborted (core dumped)
> 
> cat nft-b.rules
> table ip filter {
> 	chain INPUT {
> 		type filter hook input priority filter; policy accept;
> 		iifname "*" tcp dport 80 counter accept
> 	}
> }

For unknown reasons, I can't reproduce this on a machine with
nftables-0.9.3-16.el8.x86_64 installed. If nft-a.rules contains 'iifname "\*"',
so does 'nft list ruleset'.

Comment 4 Phil Sutter 2020-10-06 15:37:13 UTC
A fix for the first issue was submitted upstream: https://lore.kernel.org/netfilter-devel/20200924170639.15842-1-phil@nwl.cc/

Comment 5 Phil Sutter 2020-12-17 16:20:01 UTC
Upstream commit to backport:

commit 032c9f745c6daab8c27176a95963b1c32b0a5d12
Author: Phil Sutter <phil>
Date:   Thu Sep 24 17:38:45 2020 +0200

    evaluate: Reject quoted strings containing only wildcard
    
    Fix for an assertion fail when trying to match against an all-wildcard
    interface name:
    
    | % nft add rule t c iifname '"*"'
    | nft: expression.c:402: constant_expr_alloc: Assertion `(((len) + (8) - 1) / (8)) > 0' failed.
    | zsh: abort      nft add rule t c iifname '"*"'
    
    Fix this by detecting the string in expr_evaluate_string() and returning
    an error message:
    
    | % nft add rule t c iifname '"*"'
    | Error: All-wildcard strings are not supported
    | add rule t c iifname "*"
    |                      ^^^
    
    While being at it, drop the 'datalen >= 1' clause from the following
    conditional as together with the added check for 'datalen == 0', all
    possible other values have been caught already.

Comment 6 Tomas Dolezal 2021-05-14 18:56:02 UTC
(In reply to Phil Sutter from comment #3)
> (In reply to Tomas Dolezal from comment #1)
> > Adding Regression keyword. from nftables-0.9.3-12.el8 to
> > nftables-0.9.3-16.el8 the output for following ruleset changed in a way that
> > '\' before '*' in iifname is omitted thus cannot be saved and loaded again.
> For unknown reasons, I can't reproduce this on a machine with
> nftables-0.9.3-16.el8.x86_64 installed. If nft-a.rules contains 'iifname
> "\*"',
> so does 'nft list ruleset'.

I am sorry to be unable to reproduce this one as well. I can't explain it better than as a badly described environment or a mistake when observing versions. I also tried upgrading from nftables-0.9.3-12.el8 to R-16 with no success in reproducing on 8.2.1's kernel

Comment 14 errata-xmlrpc 2021-11-09 19:53:44 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 (nftables bug fix and enhancement update), and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHBA-2021:4465


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