Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3322086pxf; Mon, 15 Mar 2021 07:07:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziNbA4yvcZ9gJjwggTrIJdHLnUGKXaNYOxKDkI/wxKNmwEW7bbSlbS+SiU+82D/vCyjUgF X-Received: by 2002:a05:6402:1004:: with SMTP id c4mr30317561edu.364.1615817230055; Mon, 15 Mar 2021 07:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817230; cv=none; d=google.com; s=arc-20160816; b=xR4hL1xL/mk+TX3QqSPOAQD7QnHURl/jX89DYQaEKRrtIVXtJwNhyI7cbTxYyJuOh3 wH6NqwVgYDXz1qoIxdsUhd7vHdlO7Q8ASLRMOewIbpxoQGJaZBMQT1DZ3n77VzrC3GC2 y/4XGeW3klXAPxATO11ac+jajnAoFm6HUy5grVjo5vSIseIH/wB070WTllgLE9DRC9tU Qf53u10Jq4jDCOaccrWjsVe4CrVJcPw+Bi8CApwcsQflnBb1hJPexHzYiCTQOIyBzBfJ diR4jcRftwSwjjzYtpbJH6BI0dMMBm98nojDnCvYSOJrFZ/PIg5oYNEwQ07FUfbncfYl qpsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uelv/XaOnlbRnsNJt2h0vmH1kgVSQrkIIXbjNS7+Uuc=; b=ErWJ47M2nbTKo1BfNZ1ibEe9UMMjL9nRytXJL2VXkjDBRnad2rJE9tSLd1PP4OTFsd LmvcPo3kwy6uTZ6HLZvx3IP5QMh5Z8dLf97XFT5L4gkEa4kUAr6oMNShqdeA9fTwzVNT 0b2YHvFtaNm4IzqrSaLYDnmMjgX1blnNI1e1S7WBx8gO8t5bbHlAaqdYyd/bHMaeWVYd f+Gwc4iBfX7FxwKvJSiQZii0Ma0dxJAFP2bgaQi2vkx5lygD/EXzciRGSsb8jzScBcic IohVZ67drdUr8Gvgl+UygIr8WlxMAT/2DNRjn7le2dPZQBeEZeTNumSQUx9LRThu/oA0 tJ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Fbo1/6Qj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si11042970ejf.52.2021.03.15.07.06.46; Mon, 15 Mar 2021 07:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Fbo1/6Qj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234774AbhCOOFW (ORCPT + 99 others); Mon, 15 Mar 2021 10:05:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231955AbhCON5W (ORCPT ); Mon, 15 Mar 2021 09:57:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 24EC864F23; Mon, 15 Mar 2021 13:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816642; bh=EKtIuy4eeUOiHRfT7UaTpUYKs9fNuUweBxtdgRGO6yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fbo1/6QjkjpdKoJqKzo/Htz1ZLOGfOmHo0pqncnMSu/NIZPA6g2xg8Bs4h78p2saM ae3CO/CUaUbqg4Jjex53iJ/XeCLFfcrgOBQ30uzlmolTo43iqY0boT7po7EndFD4MZ ZRuMs/HbkTD+v0O1Pv6KjfoX+eEcl08GqXPVGPFI= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Kalle Valo Subject: [PATCH 5.10 029/290] mt76: dma: do not report truncated frames to mac80211 Date: Mon, 15 Mar 2021 14:52:02 +0100 Message-Id: <20210315135542.910378015@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Lorenzo Bianconi commit d0bd52c591a1070c54dc428e926660eb4f981099 upstream. Commit b102f0c522cf6 ("mt76: fix array overflow on receiving too many fragments for a packet") fixes a possible OOB access but it introduces a memory leak since the pending frame is not released to page_frag_cache if the frag array of skb_shared_info is full. Commit 93a1d4791c10 ("mt76: dma: fix a possible memory leak in mt76_add_fragment()") fixes the issue but does not free the truncated skb that is forwarded to mac80211 layer. Fix the leftover issue discarding even truncated skbs. Fixes: 93a1d4791c10 ("mt76: dma: fix a possible memory leak in mt76_add_fragment()") Signed-off-by: Lorenzo Bianconi Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/a03166fcc8214644333c68674a781836e0f57576.1612697217.git.lorenzo@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/mediatek/mt76/dma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -521,13 +521,13 @@ mt76_add_fragment(struct mt76_dev *dev, { struct sk_buff *skb = q->rx_head; struct skb_shared_info *shinfo = skb_shinfo(skb); + int nr_frags = shinfo->nr_frags; - if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) { + if (nr_frags < ARRAY_SIZE(shinfo->frags)) { struct page *page = virt_to_head_page(data); int offset = data - page_address(page) + q->buf_offset; - skb_add_rx_frag(skb, shinfo->nr_frags, page, offset, len, - q->buf_size); + skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size); } else { skb_free_frag(data); } @@ -536,7 +536,10 @@ mt76_add_fragment(struct mt76_dev *dev, return; q->rx_head = NULL; - dev->drv->rx_skb(dev, q - dev->q_rx, skb); + if (nr_frags < ARRAY_SIZE(shinfo->frags)) + dev->drv->rx_skb(dev, q - dev->q_rx, skb); + else + dev_kfree_skb(skb); } static int