From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1324AC48BCF for ; Thu, 10 Jun 2021 00:07:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5DDD613F1 for ; Thu, 10 Jun 2021 00:07:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbhFJAJs (ORCPT ); Wed, 9 Jun 2021 20:09:48 -0400 Received: from mga04.intel.com ([192.55.52.120]:44249 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbhFJAJr (ORCPT ); Wed, 9 Jun 2021 20:09:47 -0400 IronPort-SDR: S6GrR9aF+vLfF9a+QaT4b2eU/n8HEXIbp8piiwk9rHfkrcn75iSZqP3BEWG5Vey+0osjqWIdnw 8AVPL8hJKo8A== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="203345821" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="203345821" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 17:07:51 -0700 IronPort-SDR: N8e0OSUPsbGLqpPqVp1VmrkM7Myp6ilHT1DOM3nmLSyF+o8NsYWH0v0Czm/HRdbgtBYzuS2K5Y Bf8t10832G2w== X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="448491309" Received: from kcsherwo-mobl1.amr.corp.intel.com ([10.212.135.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 17:07:33 -0700 Date: Wed, 9 Jun 2021 17:07:14 -0700 (PDT) From: Mat Martineau To: Maxim Mikityanskiy cc: Matthieu Baerts , Jakub Kicinski , "David S. Miller" , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , =?ISO-8859-15?Q?Toke_H=F8iland-J=F8rgensen?= , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Patrick McHardy , Jesper Dangaard Brouer , Paolo Abeni , Christoph Paasch , Peter Krystad , Young Xiao <92siuyang@gmail.com>, netdev@vger.kernel.org Subject: Re: [PATCH net 2/3] mptcp: Fix out of bounds when parsing TCP options In-Reply-To: <20210609142212.3096691-3-maximmi@nvidia.com> Message-ID: References: <20210609142212.3096691-1-maximmi@nvidia.com> <20210609142212.3096691-3-maximmi@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 9 Jun 2021, Maxim Mikityanskiy wrote: > The TCP option parser in mptcp (mptcp_get_options) could read one byte > out of bounds. When the length is 1, the execution flow gets into the > loop, reads one byte of the opcode, and if the opcode is neither > TCPOPT_EOL nor TCPOPT_NOP, it reads one more byte, which exceeds the > length of 1. > > This fix is inspired by commit 9609dad263f8 ("ipv4: tcp_input: fix stack > out of bounds when parsing TCP options."). > > Cc: Young Xiao <92siuyang@gmail.com> > Fixes: cec37a6e41aa ("mptcp: Handle MP_CAPABLE options for outgoing connections") > Signed-off-by: Maxim Mikityanskiy > --- > net/mptcp/options.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/mptcp/options.c b/net/mptcp/options.c > index 6b825fb3fa83..9b263f27ce9b 100644 > --- a/net/mptcp/options.c > +++ b/net/mptcp/options.c > @@ -356,6 +356,8 @@ void mptcp_get_options(const struct sk_buff *skb, > length--; > continue; > default: > + if (length < 2) > + return; > opsize = *ptr++; > if (opsize < 2) /* "silly options" */ > return; > -- > 2.25.1 Florian's comment on patch 1 prompted me to double-check th->doff validation, and for MPTCP we're covered by the check in tcp_v4_rcv(). So this patch looks good: Reviewed-by: Mat Martineau If you send a v2 series, please also cc: mptcp@lists.linux.dev Thanks! -- Mat Martineau Intel