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

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