From nobody Thu Apr 16 02:13:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 175B3C4332F for ; Wed, 23 Nov 2022 08:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236368AbiKWIPv (ORCPT ); Wed, 23 Nov 2022 03:15:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235969AbiKWIPr (ORCPT ); Wed, 23 Nov 2022 03:15:47 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A2F9F1DBC for ; Wed, 23 Nov 2022 00:15:46 -0800 (PST) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NHDSy10wxzRpR7; Wed, 23 Nov 2022 16:15:14 +0800 (CST) Received: from localhost (10.174.179.215) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 23 Nov 2022 16:15:43 +0800 From: YueHaibing To: , CC: , , YueHaibing Subject: [PATCH] firewire: Fix potential use-after-free in fwnet_finish_incoming_packet() Date: Wed, 23 Nov 2022 16:15:11 +0800 Message-ID: <20221123081511.28684-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The skb is delivered to netif_rx() which may free it, after calling this, dereferencing skb may trigger use-after-free. Signed-off-by: YueHaibing --- drivers/firewire/net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index af22be84034b..9e19f942a545 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c @@ -479,7 +479,7 @@ static int fwnet_finish_incoming_packet(struct net_devi= ce *net, struct sk_buff *skb, u16 source_node_id, bool is_broadcast, u16 ether_type) { - int status; + int status, recv_len; =20 switch (ether_type) { case ETH_P_ARP: @@ -533,13 +533,14 @@ static int fwnet_finish_incoming_packet(struct net_de= vice *net, } skb->protocol =3D protocol; } + recv_len =3D skb->len; status =3D netif_rx(skb); if (status =3D=3D NET_RX_DROP) { net->stats.rx_errors++; net->stats.rx_dropped++; } else { net->stats.rx_packets++; - net->stats.rx_bytes +=3D skb->len; + net->stats.rx_bytes +=3D recv_len; } =20 return 0; --=20 2.17.1