Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11962916rwd; Thu, 22 Jun 2023 22:41:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4L61wWmcEB0gNn8cXDNfRdczMKYOPwxuPtc00nBQ6Xn6uvR1HULdDZOM/EHpBPJDiwuf18 X-Received: by 2002:a54:4802:0:b0:39a:664c:9761 with SMTP id j2-20020a544802000000b0039a664c9761mr20921926oij.29.1687498914899; Thu, 22 Jun 2023 22:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687498914; cv=none; d=google.com; s=arc-20160816; b=oklGnmGvxKS/hrcHY+ySTphGAUmvzeDPAV5LMsIulQqm/eEAmM7u/tExgmmZeI/Q1v a3rpTfq6GOLyThO5bM0Qj6eT7Qj3k0VUsV5YB4h+MbMgTpAYKardV+cShgOiZnNs1P8U WfOspLsgQIbf/dPpu05XpH2x/7NJ5F/IX2/wtvy5sAO/FX+/GpH3CmuyEDIofld1tJGM kW7IVnBvW+8FpkEIMxRlVKUIzvYviTkBZVCfT12Ol0hlVmkjNEoEXV2vNf6u1f6tV0y6 gIHmg832NbZSiN5KUMxHOZJPSPz2Ss6Q//zozJ6XHqxGj/A2jK9m4IRPGkFWmtP/foY8 bv6g== 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:date :subject:cc:to:from:message-id:dkim-signature; bh=NDFiwj2jmnIltHpVBQdpLmWhqFLwjPdlk5qSTa6ONks=; b=CQZ79vxVNqanYhaSjvjdhesnr15ZXnckpq9eWu0M+ypuhOU/eQnXmIr01QYZ6rcJHe W50QgeFCnNzOYDr8L6ou7A6HG3knmlgH5nUhKodwMDxxnImf98asAlwCW66QrXkvjn6L m6Cp4P5+aBzB3RHits7yPyNNS7JfhW5gNkKlGbI/udy/dY86/MThwlnx/T1CVsNW61xZ w6XdezBYuEeOc2hX5Asm/EwIyzHyUZgqXU7a0PFXlRhkplaZqWEORif/zGkYV8EjUCuR mwvCmPQe5YHK14GEXGsn4iajkfoKdBuyOdNTRz/6EKhzhywzYirLweBbz+pG6PMO+y5o 6Vjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=KbcBfqpz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk13-20020a056a02028d00b005440dcf6d1asi1007591pgb.175.2023.06.22.22.41.42; Thu, 22 Jun 2023 22:41:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=KbcBfqpz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231209AbjFWFjz (ORCPT + 99 others); Fri, 23 Jun 2023 01:39:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbjFWFjs (ORCPT ); Fri, 23 Jun 2023 01:39:48 -0400 Received: from out162-62-57-49.mail.qq.com (out162-62-57-49.mail.qq.com [162.62.57.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 913DE1A4 for ; Thu, 22 Jun 2023 22:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1687498782; bh=NDFiwj2jmnIltHpVBQdpLmWhqFLwjPdlk5qSTa6ONks=; h=From:To:Cc:Subject:Date; b=KbcBfqpzkI+OH1meha/++gUwKhibpeblZ4vmivRENr15Z5cG2JEUvhDSSsytAadsu sKEwDBSuo+Q0mdsEMvnNAwVA3aeCJoa1xILQ+Rb1X6pnXFKJGSlGRfYG9xowbmTOB9 Zi1U4uvXd9DFjYy9O5FSjqpSECCX5cbo6x6t1xeE= Received: from localhost.localdomain ([122.14.229.248]) by newxmesmtplogicsvrsza10-0.qq.com (NewEsmtp) with SMTP id 9E7042E7; Fri, 23 Jun 2023 13:39:39 +0800 X-QQ-mid: xmsmtpt1687498779t9pdo2mqh Message-ID: X-QQ-XMAILINFO: M0PjjqbLT90wUvlVOqntVEtkil74jGwBvxgJe2fQVtjXbypDeJWI8jCgYSFeh7 0U4ZBin3+OK1JVC06M+Wm4I4BuJGdJx8NKskaGBXmfqSz1zfgicJYCx0c021ykZr2u0ssl4LTIci PZFA7jqARgi4++2aTlMVCUHgO3ODOVKtE4H25OGPa/+wgIAZlbRH1JaG29hzuURr0hLdY36qVLQn c2K7C5JhVdkSjlGO3TKBAeyFHjTvENtzKc6ZlsdxiH2tjkSGgc/55jTV6+1whV+pIjnOlPpKJVv0 tlT7BZdOW4Hr9LJaM6P/+uF2ZrO8FjGfFg8Xs/jZqK7VR2yinRGtZySiqD2A/HAcKV9ba+56LuiD T5Q3COUSbdfTg2SogDpUZA60lZu1YMHPLPKdG81FM5h3EU/9p5PWYfzzX55Gf+a706PjwO+8upk1 cQmpJsmKMo2uQUcffwK9jdMVHU23IP9ji4ZIgmmgn+dRKgTaR05fsE1Z+zPt0Wj1RxedPajP8Fud l2TDQiUCMA1qiuW7+bYnhWbPX+z1o+05CMJXROWCYv51Wmx9x+ojrzD3TVckZOffsnf9++GEFdZn 6xveQt5aQM+ORILiUDM62tucyv48DjpS9Ly6ZZh955SMn7gyFPbCezmrB07+KyM/dXF3XDdlaLVs fPJGJ2/I96MIf66EM23VqWXp6hHC9L/vwmf9zpsuACdYFdZDtCR7guTQn4l6/EcJP9E/i2lejzPW GBr+3p5DRigqoQ721AefloZRitqSG+StWewFrSinIefjhJ5/K0eJR05kf0Ix/aInjLKUMWPGKTTd W5feUVnDpmQn6X1pM9NUi9mwDlE7QidAiEZVvbu0qPv4h4stVCVklCu3dSmVdn5w5ipYH68o3o9p Nzk/8Uo/enYeUZCfiywl0P8gRHsv+a8yAXE1dukTHSlPUN8PKhZfKur4kcIu+m3TX2O+jZWnkxzJ pIibPgAMJyYoEEYt9LIQ9pX3PKS4nedIejddIf+PeGo0Rl5gcLFO2UHVmf0lcW X-QQ-XMRINFO: Mu10XATLq/IERfXGovp1cJndKWH8Kl+aSQ== From: Zhang Shurong To: o-takashi@sakamocchi.jp Cc: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Zhang Shurong Subject: [PATCH] firewire: net: fix use after free in fwnet_finish_incoming_packet() Date: Fri, 23 Jun 2023 13:39:35 +0800 X-OQ-MSGID: <20230623053935.4192-1-zhang_shurong@foxmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org The netif_rx() function frees the skb so we can't dereference it to save the skb->len. Signed-off-by: Zhang Shurong --- drivers/firewire/net.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index 538bd677c254..7a4d1a478e33 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c @@ -479,7 +479,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net, struct sk_buff *skb, u16 source_node_id, bool is_broadcast, u16 ether_type) { - int status; + int status, len; switch (ether_type) { case ETH_P_ARP: @@ -533,13 +533,15 @@ static int fwnet_finish_incoming_packet(struct net_device *net, } skb->protocol = protocol; } + + len = skb->len; status = netif_rx(skb); if (status == NET_RX_DROP) { net->stats.rx_errors++; net->stats.rx_dropped++; } else { net->stats.rx_packets++; - net->stats.rx_bytes += skb->len; + net->stats.rx_bytes += len; } return 0; -- 2.41.0