Blame SOURCES/extensions-libxt_tcpmss-Detect-invalid-ranges.patch

388998
From 12852e5c973ef9e5d33c1dc1a21c659f4dc6227b Mon Sep 17 00:00:00 2001
388998
From: Phil Sutter <psutter@redhat.com>
388998
Date: Fri, 11 May 2018 15:28:07 +0200
388998
Subject: [PATCH] extensions: libxt_tcpmss: Detect invalid ranges
388998
388998
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1128510
388998
Upstream Status: iptables commit dbbab0aa328f1
388998
388998
commit dbbab0aa328f136502373a1031e64eb53fa113e5
388998
Author: Phil Sutter <phil@nwl.cc>
388998
Date:   Mon Oct 9 15:47:39 2017 +0200
388998
388998
    extensions: libxt_tcpmss: Detect invalid ranges
388998
388998
    Previously, an MSS range of e.g. 65535:1000 was silently accepted but
388998
    would then never match a packet since the kernel checks whether the MSS
388998
    value is greater than or equal to the first *and* less than or equal to
388998
    the second value.
388998
388998
    Detect this as a parameter problem and update the man page accordingly.
388998
388998
    Signed-off-by: Phil Sutter <phil@nwl.cc>
388998
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
388998
388998
Signed-off-by: Phil Sutter <psutter@redhat.com>
388998
---
388998
 extensions/libxt_tcpmss.c   | 6 +++++-
388998
 extensions/libxt_tcpmss.man | 2 +-
388998
 2 files changed, 6 insertions(+), 2 deletions(-)
388998
388998
diff --git a/extensions/libxt_tcpmss.c b/extensions/libxt_tcpmss.c
388998
index c7c5971716294..bcd357aa3d8e2 100644
388998
--- a/extensions/libxt_tcpmss.c
388998
+++ b/extensions/libxt_tcpmss.c
388998
@@ -27,8 +27,12 @@ static void tcpmss_parse(struct xt_option_call *cb)
388998
 	xtables_option_parse(cb);
388998
 	mssinfo->mss_min = cb->val.u16_range[0];
388998
 	mssinfo->mss_max = mssinfo->mss_min;
388998
-	if (cb->nvals == 2)
388998
+	if (cb->nvals == 2) {
388998
 		mssinfo->mss_max = cb->val.u16_range[1];
388998
+		if (mssinfo->mss_max < mssinfo->mss_min)
388998
+			xtables_error(PARAMETER_PROBLEM,
388998
+				      "tcpmss: invalid range given");
388998
+	}
388998
 	if (cb->invert)
388998
 		mssinfo->invert = 1;
388998
 }
388998
diff --git a/extensions/libxt_tcpmss.man b/extensions/libxt_tcpmss.man
388998
index 8ee715cdbfb07..8253c363418f8 100644
388998
--- a/extensions/libxt_tcpmss.man
388998
+++ b/extensions/libxt_tcpmss.man
388998
@@ -1,4 +1,4 @@
388998
 This matches the TCP MSS (maximum segment size) field of the TCP header.  You can only use this on TCP SYN or SYN/ACK packets, since the MSS is only negotiated during the TCP handshake at connection startup time.
388998
 .TP
388998
 [\fB!\fP] \fB\-\-mss\fP \fIvalue\fP[\fB:\fP\fIvalue\fP]
388998
-Match a given TCP MSS value or range.
388998
+Match a given TCP MSS value or range. If a range is given, the second \fIvalue\fP must be greater than or equal to the first \fIvalue\fP.
388998
-- 
388998
2.17.0
388998