Bug 1801834

Summary: Fix iptables-restore --noflush with empty lines in input
Product: Red Hat Enterprise Linux 8 Reporter: Phil Sutter <psutter>
Component: iptablesAssignee: Phil Sutter <psutter>
Status: CLOSED ERRATA QA Contact: Jiri Peska <jpeska>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2CC: iptables-maint-list, jpeska, todoleza
Target Milestone: rcKeywords: Regression
Target Release: 8.2Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: iptables-1.8.4-8.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 17:00:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Phil Sutter 2020-02-11 17:28:38 UTC
Same problem as described here:

https://bugzilla.netfilter.org/show_bug.cgi?id=1400

Fix sent upstream: 

https://lore.kernel.org/netfilter-devel/20200211170913.2374-1-phil@nwl.cc/

Comment 1 Phil Sutter 2020-02-12 14:19:23 UTC
Upstream commit to backport:

commit 8e76391096f12212985c401ee83a67990aa27a29 (HEAD -> upstream, origin-rw/master)
Author: Phil Sutter <phil>
Date:   Tue Feb 11 16:52:59 2020 +0100

    xtables-restore: fix for --noflush and empty lines
    
    Lookahead buffer used for cache requirements estimate in restore
    --noflush separates individual lines with nul-chars. Two consecutive
    nul-chars are interpreted as end of buffer and remaining buffer content
    is skipped.
    
    Sadly, reading an empty line (i.e., one containing a newline character
    only) caused double nul-chars to appear in buffer as well, leading to
    premature stop when reading cached lines from buffer.
    
    To fix that, make use of xtables_restore_parse_line() skipping empty
    lines without calling strtok() and just leave the newline character in
    place. A more intuitive approach, namely skipping empty lines while
    buffering, is deliberately not chosen as that would cause wrong values
    in 'line' variable.
    
    Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1400
    Fixes: 09cb517949e69 ("xtables-restore: Improve performance of --noflush operation")
    Signed-off-by: Phil Sutter <phil>
    Acked-by: Arturo Borrero Gonzalez <arturo>

Comment 8 errata-xmlrpc 2020-04-28 17:00:30 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.

https://access.redhat.com/errata/RHEA-2020:1889