Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3510129pxf; Mon, 15 Mar 2021 11:07:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3HDlnLmifUAASM6ND/9Fb9yfZafaxsqoZZ8/r6ebnAvlFxWCvDfcm73GMbxZ3qZG4GcTY X-Received: by 2002:a05:6402:4242:: with SMTP id g2mr31185923edb.329.1615831674853; Mon, 15 Mar 2021 11:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615831674; cv=none; d=google.com; s=arc-20160816; b=OkxdHGq/U0BbFFxHU2wkwYr2viT20OrEd8zHo6weZSnmA1X9rD5BDycSiYDXJWIPQF qmxBU907OXiZaDjBAuscdqZzOOLqgerazLFY2G3bhUSJcm/FchGo7AXLYdviTxlTyo+L AWibJFGTPkQjqBAL87jvpRG/mwRNwTo3sXSg5dn+jCOC3WnMifWVcEkgt9Men+8SvkbJ skEszgC9qYB7suj52DRBU4UiOvIBpvYfziv/0YIJWxDH4hKc/GfMOeHETOK403KUKpfn IadsjaKcq016nu9GGGCoypolM5M6r1wYZOWBPbWnADY/T1G2hi2MEjw6hSoobuwz5GQi 32+w== 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=DFQTAXQ7O86o3SpzV03NESCYQDovihdCYmIBqKsOmxM=; b=hxV0Ek1snAZb0YdXYJaIkQ+PLdyV4e+/8hGMzqks7V5bx3PVUabtA6z1/WKywoLdD4 7RIYSpnXt3snxbOhR2uDpQujWXCuFxL8K697LNdjJruatXxyhjeHPiZqjD6V4i66JVDy MVqDym9T76fIYRh0KPvCI2oV0xoChWtz2ROctY53Uyq/q8hyoquNgO6ugpphssS/3MXs R21EAcjdYSA36rHVhxdVhG256sDG1bJoHycc/2/qbhnlq86v1rRpHTPLbMYW72fTN4y6 J1pUTX71SCbPTagd9xtFJXplSxncbCxEUahVTTH60gcn7lB5cQ6oAC9fG+DKFarmpkbS Ut+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eeB5IO8x; 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 r25si11355025ejs.195.2021.03.15.11.07.27; Mon, 15 Mar 2021 11:07:54 -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=eeB5IO8x; 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 S235159AbhCOOI3 (ORCPT + 99 others); Mon, 15 Mar 2021 10:08:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:37522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbhCON6N (ORCPT ); Mon, 15 Mar 2021 09:58:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A704364F34; Mon, 15 Mar 2021 13:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816692; bh=/MXVebiUsSQTlklZvgXeCiIsC9ubuyLXYbpwzzT86SU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eeB5IO8xzx6zlSmhgwUsne64cpkn043b6T9lrlClplP+kOiY4x09MH2RBG++x4npk f6jBPqsalM0UM4HCl7Tkcsje/t0b+oBhuTs2GKOycT5Le3/QnJAaPx59HGe1jZBycv Tnxt8R8g0BbNnYbztoQp3OLlYj+PPcS9LQttuuz8= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Kalle Valo Subject: [PATCH 4.19 010/120] mt76: dma: do not report truncated frames to mac80211 Date: Mon, 15 Mar 2021 14:56:01 +0100 Message-Id: <20210315135720.353823572@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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 @@ -395,13 +395,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); } @@ -410,7 +410,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