]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.14
authorSasha Levin <sashal@kernel.org>
Sat, 30 Oct 2021 20:33:20 +0000 (16:33 -0400)
committerSasha Levin <sashal@kernel.org>
Sat, 30 Oct 2021 20:33:20 +0000 (16:33 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.14/sctp-add-vtag-check-in-sctp_sf_do_8_5_1_e_sa.patch [new file with mode: 0644]
queue-4.14/sctp-add-vtag-check-in-sctp_sf_ootb.patch [new file with mode: 0644]
queue-4.14/sctp-add-vtag-check-in-sctp_sf_violation.patch [new file with mode: 0644]
queue-4.14/sctp-fix-the-processing-for-cookie_echo-chunk.patch [new file with mode: 0644]
queue-4.14/sctp-use-init_tag-from-inithdr-for-abort-chunk.patch [new file with mode: 0644]
queue-4.14/series

diff --git a/queue-4.14/sctp-add-vtag-check-in-sctp_sf_do_8_5_1_e_sa.patch b/queue-4.14/sctp-add-vtag-check-in-sctp_sf_do_8_5_1_e_sa.patch
new file mode 100644 (file)
index 0000000..eb856b8
--- /dev/null
@@ -0,0 +1,65 @@
+From 8984051f6dcbba3adc391be0e939ef0e3f809380 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 20 Oct 2021 07:42:46 -0400
+Subject: sctp: add vtag check in sctp_sf_do_8_5_1_E_sa
+
+From: Xin Long <lucien.xin@gmail.com>
+
+[ Upstream commit ef16b1734f0a176277b7bb9c71a6d977a6ef3998 ]
+
+sctp_sf_do_8_5_1_E_sa() is called when processing SHUTDOWN_ACK chunk
+in cookie_wait and cookie_echoed state.
+
+The vtag in the chunk's sctphdr should be verified, otherwise, as
+later in chunk length check, it may send abort with the existent
+asoc's vtag, which can be exploited by one to cook a malicious
+chunk to terminate a SCTP asoc.
+
+Note that when fails to verify the vtag from SHUTDOWN-ACK chunk,
+SHUTDOWN COMPLETE message will still be sent back to peer, but
+with the vtag from SHUTDOWN-ACK chunk, as said in 5) of
+rfc4960#section-8.4.
+
+While at it, also remove the unnecessary chunk length check from
+sctp_sf_shut_8_4_5(), as it's already done in both places where
+it calls sctp_sf_shut_8_4_5().
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Xin Long <lucien.xin@gmail.com>
+Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sctp/sm_statefuns.c | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
+index e6260946eafe..c3cb0ae7df2b 100644
+--- a/net/sctp/sm_statefuns.c
++++ b/net/sctp/sm_statefuns.c
+@@ -3613,12 +3613,6 @@ static enum sctp_disposition sctp_sf_shut_8_4_5(
+       SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
+-      /* If the chunk length is invalid, we don't want to process
+-       * the reset of the packet.
+-       */
+-      if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
+-              return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+-
+       /* We need to discard the rest of the packet to prevent
+        * potential bomming attacks from additional bundled chunks.
+        * This is documented in SCTP Threats ID.
+@@ -3646,6 +3640,9 @@ enum sctp_disposition sctp_sf_do_8_5_1_E_sa(struct net *net,
+ {
+       struct sctp_chunk *chunk = arg;
++      if (!sctp_vtag_verify(chunk, asoc))
++              asoc = NULL;
++
+       /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */
+       if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
+               return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
+-- 
+2.33.0
+
diff --git a/queue-4.14/sctp-add-vtag-check-in-sctp_sf_ootb.patch b/queue-4.14/sctp-add-vtag-check-in-sctp_sf_ootb.patch
new file mode 100644 (file)
index 0000000..6686ec9
--- /dev/null
@@ -0,0 +1,47 @@
+From 9391962c3bcd4d73bddb377a094542c8a2051463 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 20 Oct 2021 07:42:47 -0400
+Subject: sctp: add vtag check in sctp_sf_ootb
+
+From: Xin Long <lucien.xin@gmail.com>
+
+[ Upstream commit 9d02831e517aa36ee6bdb453a0eb47bd49923fe3 ]
+
+sctp_sf_ootb() is called when processing DATA chunk in closed state,
+and many other places are also using it.
+
+The vtag in the chunk's sctphdr should be verified, otherwise, as
+later in chunk length check, it may send abort with the existent
+asoc's vtag, which can be exploited by one to cook a malicious
+chunk to terminate a SCTP asoc.
+
+When fails to verify the vtag from the chunk, this patch sets asoc
+to NULL, so that the abort will be made with the vtag from the
+received chunk later.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Xin Long <lucien.xin@gmail.com>
+Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sctp/sm_statefuns.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
+index c3cb0ae7df2b..b26067798dbf 100644
+--- a/net/sctp/sm_statefuns.c
++++ b/net/sctp/sm_statefuns.c
+@@ -3498,6 +3498,9 @@ enum sctp_disposition sctp_sf_ootb(struct net *net,
+       SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES);
++      if (asoc && !sctp_vtag_verify(chunk, asoc))
++              asoc = NULL;
++
+       ch = (struct sctp_chunkhdr *)chunk->chunk_hdr;
+       do {
+               /* Report violation if the chunk is less then minimal */
+-- 
+2.33.0
+
diff --git a/queue-4.14/sctp-add-vtag-check-in-sctp_sf_violation.patch b/queue-4.14/sctp-add-vtag-check-in-sctp_sf_violation.patch
new file mode 100644 (file)
index 0000000..329c744
--- /dev/null
@@ -0,0 +1,43 @@
+From 0e0c1ec7df927ced394282ff2dbc4da4fd2ffc6f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 20 Oct 2021 07:42:45 -0400
+Subject: sctp: add vtag check in sctp_sf_violation
+
+From: Xin Long <lucien.xin@gmail.com>
+
+[ Upstream commit aa0f697e45286a6b5f0ceca9418acf54b9099d99 ]
+
+sctp_sf_violation() is called when processing HEARTBEAT_ACK chunk
+in cookie_wait state, and some other places are also using it.
+
+The vtag in the chunk's sctphdr should be verified, otherwise, as
+later in chunk length check, it may send abort with the existent
+asoc's vtag, which can be exploited by one to cook a malicious
+chunk to terminate a SCTP asoc.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Xin Long <lucien.xin@gmail.com>
+Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sctp/sm_statefuns.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
+index 4b519ec35ab7..e6260946eafe 100644
+--- a/net/sctp/sm_statefuns.c
++++ b/net/sctp/sm_statefuns.c
+@@ -4481,6 +4481,9 @@ enum sctp_disposition sctp_sf_violation(struct net *net,
+ {
+       struct sctp_chunk *chunk = arg;
++      if (!sctp_vtag_verify(chunk, asoc))
++              return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
++
+       /* Make sure that the chunk has a valid length. */
+       if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
+               return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
+-- 
+2.33.0
+
diff --git a/queue-4.14/sctp-fix-the-processing-for-cookie_echo-chunk.patch b/queue-4.14/sctp-fix-the-processing-for-cookie_echo-chunk.patch
new file mode 100644 (file)
index 0000000..6d0cbcc
--- /dev/null
@@ -0,0 +1,75 @@
+From 27c0f0612d2b48167c312f4b21e6e197409de69d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 20 Oct 2021 07:42:44 -0400
+Subject: sctp: fix the processing for COOKIE_ECHO chunk
+
+From: Xin Long <lucien.xin@gmail.com>
+
+[ Upstream commit a64b341b8695e1c744dd972b39868371b4f68f83 ]
+
+1. In closed state: in sctp_sf_do_5_1D_ce():
+
+  When asoc is NULL, making packet for abort will use chunk's vtag
+  in sctp_ootb_pkt_new(). But when asoc exists, vtag from the chunk
+  should be verified before using peer.i.init_tag to make packet
+  for abort in sctp_ootb_pkt_new(), and just discard it if vtag is
+  not correct.
+
+2. In the other states: in sctp_sf_do_5_2_4_dupcook():
+
+  asoc always exists, but duplicate cookie_echo's vtag will be
+  handled by sctp_tietags_compare() and then take actions, so before
+  that we only verify the vtag for the abort sent for invalid chunk
+  length.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Xin Long <lucien.xin@gmail.com>
+Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sctp/sm_statefuns.c | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
+index b1200c4122b0..4b519ec35ab7 100644
+--- a/net/sctp/sm_statefuns.c
++++ b/net/sctp/sm_statefuns.c
+@@ -704,6 +704,9 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
+       struct sock *sk;
+       int error = 0;
++      if (asoc && !sctp_vtag_verify(chunk, asoc))
++              return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
++
+       /* If the packet is an OOTB packet which is temporarily on the
+        * control endpoint, respond with an ABORT.
+        */
+@@ -718,7 +721,8 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
+        * in sctp_unpack_cookie().
+        */
+       if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
+-              return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
++              return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
++                                                commands);
+       /* If the endpoint is not listening or if the number of associations
+        * on the TCP-style socket exceed the max backlog, respond with an
+@@ -2080,9 +2084,11 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook(
+        * enough for the chunk header.  Cookie length verification is
+        * done later.
+        */
+-      if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
+-              return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
+-                                                commands);
++      if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) {
++              if (!sctp_vtag_verify(chunk, asoc))
++                      asoc = NULL;
++              return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, commands);
++      }
+       /* "Decode" the chunk.  We have no optional parameters so we
+        * are in good shape.
+-- 
+2.33.0
+
diff --git a/queue-4.14/sctp-use-init_tag-from-inithdr-for-abort-chunk.patch b/queue-4.14/sctp-use-init_tag-from-inithdr-for-abort-chunk.patch
new file mode 100644 (file)
index 0000000..88a8feb
--- /dev/null
@@ -0,0 +1,42 @@
+From 69a3225c4df333c956e71115696237a22ded9da6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 20 Oct 2021 07:42:41 -0400
+Subject: sctp: use init_tag from inithdr for ABORT chunk
+
+From: Xin Long <lucien.xin@gmail.com>
+
+[ Upstream commit 4f7019c7eb33967eb87766e0e4602b5576873680 ]
+
+Currently Linux SCTP uses the verification tag of the existing SCTP
+asoc when failing to process and sending the packet with the ABORT
+chunk. This will result in the peer accepting the ABORT chunk and
+removing the SCTP asoc. One could exploit this to terminate a SCTP
+asoc.
+
+This patch is to fix it by always using the initiate tag of the
+received INIT chunk for the ABORT chunk to be sent.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Xin Long <lucien.xin@gmail.com>
+Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sctp/sm_statefuns.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
+index e943fb28f581..b1200c4122b0 100644
+--- a/net/sctp/sm_statefuns.c
++++ b/net/sctp/sm_statefuns.c
+@@ -6181,6 +6181,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(
+                * yet.
+                */
+               switch (chunk->chunk_hdr->type) {
++              case SCTP_CID_INIT:
+               case SCTP_CID_INIT_ACK:
+               {
+                       struct sctp_initack_chunk *initack;
+-- 
+2.33.0
+
index aaadaff5a32462981af2ad14609b81a30cf8f583..0cfa53ab8969d5592c6242e0d59285fea1d74b7a 100644 (file)
@@ -18,3 +18,8 @@ regmap-fix-possible-double-free-in-regcache_rbtree_exit.patch
 net-batman-adv-fix-error-handling.patch
 nios2-make-nios2_dtb_source_bool-depend-on-compile_test.patch
 net-nxp-lpc_eth.c-avoid-hang-when-bringing-interface-down.patch
+sctp-use-init_tag-from-inithdr-for-abort-chunk.patch
+sctp-fix-the-processing-for-cookie_echo-chunk.patch
+sctp-add-vtag-check-in-sctp_sf_violation.patch
+sctp-add-vtag-check-in-sctp_sf_do_8_5_1_e_sa.patch
+sctp-add-vtag-check-in-sctp_sf_ootb.patch