Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5613824rwp; Mon, 17 Jul 2023 07:02:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlFvENpBlOzju2ppfGiTSPlPo1e8tofPEEMibdZKRh2PLdXdtwIWAtD9aenJc00HFWOOUV7v X-Received: by 2002:a17:902:7004:b0:1b8:5735:2850 with SMTP id y4-20020a170902700400b001b857352850mr9170281plk.32.1689602535110; Mon, 17 Jul 2023 07:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689602535; cv=none; d=google.com; s=arc-20160816; b=XKl4wKQfRAmetSsL50T4QkSgriiZhV6s9oOW3HauurouoP4DuDpQxbqu9k7Db4r7tn MxZoi8ldFwX9dWAc88gDiFeW5TYgy7kPJf827XIzI5OSrLzfEpIy5knBNxMikEUKfPif d5j8lcwAvTP3VtxH1c9p0QuPiaMC12y0DJbHutCZxLw31bzM6rDm8H7oY6wThln1CI4E kQUAkjnItAxai/F29r87C8UkeLxV0hdH7mN3hxM50lW65LxkiEOLx5z5FBbJevxa00sC SbgpqppB9pR3O2iZ4T/UWmFuxNj5GsCzBszMMUMcVQiUk4OyPNZQ7uIpHdO9uEvdW94I R8BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=/+2fKpKak3dEDNHpfOdM6IYHAorF5pHgnmFEr0Z1M3U=; fh=Qhjb8kKwjCZhT8Wp9ZUaEfxW/KjdcAG90xcF4tg6KkI=; b=DXy8ZIBX3GyQo7AE0wNkwVBA6SRxziKns9uyZ5G6Pev0JytKwBBR5HVUtPUaLRtdoV 8DLyjRGgR18a8YDi0+E5tmQVltRHTyOIvAjoamZYU7iSzyk9MHfaLxnzJsXlh2zdiOGQ 8PC3ShWPEpMwiOig2a/BKZHk3hpK81aUA36GwH7JD0BLf82KwdiIV5xbU5/Tnu/PAmv0 QR2T3ITOulxBK4d2MzbIVS6aRgNmFlboYtda4LrATAAnkXw4z0fXE1Cljx7481H8xYq9 rg1sXow5b8x4m7mKSUMGTcpqVvsMw2bWQQ5ukfneB4WS0w8VkNk0UEtwpqjKyh58u/na PdEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a170902ce8400b001b8c6890612si11875739plg.594.2023.07.17.07.02.00; Mon, 17 Jul 2023 07:02:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229861AbjGQNmI convert rfc822-to-8bit (ORCPT + 58 others); Mon, 17 Jul 2023 09:42:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231349AbjGQNmE (ORCPT ); Mon, 17 Jul 2023 09:42:04 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A30A94 for ; Mon, 17 Jul 2023 06:42:01 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-231-n4hzKPGVPluEj2EyIQGAbw-1; Mon, 17 Jul 2023 14:41:59 +0100 X-MC-Unique: n4hzKPGVPluEj2EyIQGAbw-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 17 Jul 2023 14:41:58 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Mon, 17 Jul 2023 14:41:58 +0100 From: David Laight To: 'Polaris Pi' , "kuba@kernel.org" , "amitkarwar@gmail.com" , "kvalo@kernel.org" , "ganapathi017@gmail.com" , "sharvari.harisangam@nxp.com" , "huxinming820@gmail.com" CC: "linux-wireless@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v5] wifi: mwifiex: Fix OOB and integer underflow when rx packets Thread-Topic: [PATCH v5] wifi: mwifiex: Fix OOB and integer underflow when rx packets Thread-Index: AQHZtksXz+mc/wmP/kK+sAkKEpAEMa+9+sHw Date: Mon, 17 Jul 2023 13:41:58 +0000 Message-ID: <8aacfa081d3f4bc3a3ea8359e610fa3e@AcuMS.aculab.com> References: <20230714120222.3920248-1-pinkperfect2021@gmail.com> In-Reply-To: <20230714120222.3920248-1-pinkperfect2021@gmail.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,PDS_BAD_THREAD_QP_64, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Polaris Pi > Sent: 14 July 2023 13:02 > > Make sure mwifiex_process_mgmt_packet and its callers > mwifiex_process_sta_rx_packet and mwifiex_process_uap_rx_packet > not out-of-bounds access the skb->data buffer. > ... > diff --git a/drivers/net/wireless/marvell/mwifiex/sta_rx.c > b/drivers/net/wireless/marvell/mwifiex/sta_rx.c > index 13659b02ba88..88aaec645291 100644 > --- a/drivers/net/wireless/marvell/mwifiex/sta_rx.c > +++ b/drivers/net/wireless/marvell/mwifiex/sta_rx.c > @@ -194,7 +194,8 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_private *priv, > > rx_pkt_hdr = (void *)local_rx_pd + rx_pkt_offset; > > - if ((rx_pkt_offset + rx_pkt_length) > (u16) skb->len) { > + if ((rx_pkt_offset + rx_pkt_length) > (u16)skb->len || > + skb->len - rx_pkt_offset < sizeof(*rx_pkt_hdr)) { What is the (u16) cast for? The domain of both tx_pkt_offset and rx_pkt_length is 16bits. Their sum is of type 'int', masking skb->len to 16 bits just discards high bits (which are probably zero). The second test should probably be: rx_pkt_offset + sizeof(*rx_pkt_hdr) > skb->len although the first test includes the 'offset > len' check. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)