From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89DF228ED for ; Mon, 12 Dec 2022 13:50:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB4B1C433EF; Mon, 12 Dec 2022 13:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670853027; bh=l34RYzRJlOQ3PfBKRt0eXnlIKAa4J6IZI+7/gcDgYzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rmNwYIsCzOAkNKVJmZq9q9yYZOHBn2hM235QU2jgok9Ypp66R0n9KrYxOT0/VZpaA epE3FW8+G0SZKzmXlUAREnA2zt3IuKsZUyM9JP3cWGW6DPbegPT2RZD9TtKaIWHtVy LBnyIF2Fu28YaRgFR6LNH9nzAafithK8v0IA5YDk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Liu Jian , Paolo Abeni , Sasha Levin Subject: [PATCH 4.19 42/49] net: hisilicon: Fix potential use-after-free in hix5hd2_rx() Date: Mon, 12 Dec 2022 14:19:20 +0100 Message-Id: <20221212130915.764188892@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212130913.666185567@linuxfoundation.org> References: <20221212130913.666185567@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Liu Jian [ Upstream commit 433c07a13f59856e4585e89e86b7d4cc59348fab ] The skb is delivered to napi_gro_receive() which may free it, after calling this, dereferencing skb may trigger use-after-free. Fixes: 57c5bc9ad7d7 ("net: hisilicon: add hix5hd2 mac driver") Signed-off-by: Liu Jian Link: https://lore.kernel.org/r/20221203094240.1240211-2-liujian56@huawei.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c index b63871ef8a40..e69a64a50127 100644 --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c @@ -554,7 +554,7 @@ static int hix5hd2_rx(struct net_device *dev, int limit) skb->protocol = eth_type_trans(skb, dev); napi_gro_receive(&priv->napi, skb); dev->stats.rx_packets++; - dev->stats.rx_bytes += skb->len; + dev->stats.rx_bytes += len; next: pos = dma_ring_incr(pos, RX_DESC_NUM); } -- 2.35.1