Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3602328pxv; Mon, 12 Jul 2021 22:41:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf2EtDkRJsWDHcVXfdF58YIayhzXeb0srBhPjEMjCyYXWyASZIklTTtLOHIzzs0QkTeITy X-Received: by 2002:a02:9648:: with SMTP id c66mr2463593jai.73.1626154876185; Mon, 12 Jul 2021 22:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626154876; cv=none; d=google.com; s=arc-20160816; b=DS5h+ov1V3oTOYKvMR9Y5wnTdD3DbDh+099AZuzXbmePip78LzZz23obm7uJGFPFZO xJHoLzKLpRNEClgDgs/YTEKiW4JgbIcv+PlJRzY1yiQP+EEFaUPB1CMRa/PEVpdZvpZf 4iLlT5A/4qiHk3jPfU7AztMw2C6T8TNSPBHh37+R7IBynJpJTwgEXiBxGfz2Y4XEv3n0 h1z4w3dJZ/xhX8wr4l+0k4qZjjnTrd41SaJ6OGgA8/oAU0eGBhLHQU1kd4V+DPNRfLiT DH2hQAM/fJS+cQ9S5dozlQnNh5SHgK3GLygWN60geCa59baNIjIioJvOi56yTtmHdIWA hBew== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=nCoykUfAeCmm7EweIlj2EVckVQsnC0tULaDKLSufM14=; b=x2bUmNwxua5top1SLRp6YYe2tgXX40aFQ1Lbs3zz2rVg+3lLatmxDMsgEvdjtVNlXe V93ROPzC+p6KV+JgYbq0dX3NMiNrLCyXwZgge8v4OsxurXzn4aMdn7qxhwAKCqo7nX// O+jA4tsPBk9Fl3fuFCybGg65pGrmKGLM5jBCD0AlGmkoNqNMVEGTtAoBjpSfVSvRAjoH 1/+MmsGodF8DQ6Wrb6f6hxMPszc9u+sYdjMfQxIRttTZr1VWkByCgAuDQ0VEjtjrdkqe odDiDd0TCnrMY92voJ2dhpTa9pKJAhfptyrg3L2cZkxXr0EbnM6EM5AvJhMKqLKNvliM 5u0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IQcarGJN; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b16si5794500ile.135.2021.07.12.22.41.04; Mon, 12 Jul 2021 22:41:16 -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=@gmail.com header.s=20161025 header.b=IQcarGJN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231859AbhGMFnZ (ORCPT + 99 others); Tue, 13 Jul 2021 01:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbhGMFnY (ORCPT ); Tue, 13 Jul 2021 01:43:24 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A22D8C0613DD; Mon, 12 Jul 2021 22:40:34 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id h4so20626699pgp.5; Mon, 12 Jul 2021 22:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nCoykUfAeCmm7EweIlj2EVckVQsnC0tULaDKLSufM14=; b=IQcarGJNgxbM+9PEbA2hjgnAzguOJ6Fl8BtlwbD+QiGIWR2QMTzdNYqfV8/O5RePMu jc+dxLQtSRSvJd5BvPgOvvLJ5OeW0woWRuZQVOXF5jGWBxWJsiXTQcKd+XRV+mHg8sqx +w4nFQh3mtoYFNWwMqwL8aDxwxO4NBFoHE6iVr0d9Lwm7Ec2Q2hRYnlojrMdxLu9ICzW s8ZMU++QeEBFGBOF2ZFYYlhO8fjIHEh3A8gHxCjvIPXDq2/yN6wwBKOfr/SJGk4gR6Uy p38QX2Gm7WcgYXi5HiI76B0oFzTiPA+hGlMBBmhSccKY5AEKuaI5ZTtidS9bx/RVvo9U BW/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nCoykUfAeCmm7EweIlj2EVckVQsnC0tULaDKLSufM14=; b=Cw03a2WLrpqM6m+bEDPC1IFezzTr1a7sc4RthRIIqxB1G2RRmhuSBjKTKtdrRXIoza zxQCuED1luUn4oeEGHAbGEc62/ZjkbL8VQ1SykEfpdn3NmL1BAx0/IJtfaFKLZ85QPBQ ULwDO6lCgK7FFY0mlURc+mO7i7ywSC5XWd7/RzC44DWTUM8JQN8JTKRWBDcMrLe/1lp3 DTRII50GK6x2lbHDAOPk6j07CViCIMnfEtst5c2q4SFnJtCt1wHKkPL6sAf/lhVJpQTN FpIFBpXIVbhAfDH9Mc9U3oPXKmbc2ivZ8g2g9z1xqBysY12ealUlA3neDqAqP3Ie04k/ 6GeA== X-Gm-Message-State: AOAM530cjOuxCeajUDdNiehurLAum6K2PoOALOlBCelU2p4gcHZ0y3Xb XMJ2cQw8KRYh49qs9dsZkS4= X-Received: by 2002:a62:cd47:0:b029:329:714e:cce2 with SMTP id o68-20020a62cd470000b0290329714ecce2mr2925551pfg.22.1626154834013; Mon, 12 Jul 2021 22:40:34 -0700 (PDT) Received: from localhost.localdomain ([154.16.166.164]) by smtp.gmail.com with ESMTPSA id q14sm9232593pff.209.2021.07.12.22.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 22:40:33 -0700 (PDT) From: Dongliang Mu To: Alexander Aring , Stefan Schmidt , "David S. Miller" , Jakub Kicinski Cc: Dongliang Mu , Alexander Aring , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ieee802154: hwsim: fix memory leak in __pskb_copy_fclone Date: Tue, 13 Jul 2021 13:40:18 +0800 Message-Id: <20210713054019.409273-1-mudongliangabcd@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hwsim_hw_xmit fails to deallocate the newskb copied by pskb_copy. Fix this by adding kfree_skb after ieee802154_rx_irqsafe. [] __alloc_skb+0x22b/0x250 net/core/skbuff.c:414 [] __pskb_copy_fclone+0x75/0x360 net/core/skbuff.c:1609 [] __pskb_copy include/linux/skbuff.h:1176 [inline] [] pskb_copy include/linux/skbuff.h:3207 [inline] [] hwsim_hw_xmit+0xd3/0x140 drivers/net/ieee802154/mac802154_hwsim.c:132 [] drv_xmit_async net/mac802154/driver-ops.h:16 [inline] [] ieee802154_tx+0xc7/0x190 net/mac802154/tx.c:83 [] ieee802154_subif_start_xmit+0x58/0x70 net/mac802154/tx.c:132 [] __netdev_start_xmit include/linux/netdevice.h:4944 [inline] [] netdev_start_xmit include/linux/netdevice.h:4958 [inline] [] xmit_one net/core/dev.c:3658 [inline] [] dev_hard_start_xmit+0xe2/0x330 net/core/dev.c:3674 [] sch_direct_xmit+0xf8/0x520 net/sched/sch_generic.c:342 [] __dev_xmit_skb net/core/dev.c:3874 [inline] [] __dev_queue_xmit+0xa3b/0x1360 net/core/dev.c:4241 [] dgram_sendmsg+0x437/0x570 net/ieee802154/socket.c:682 [] sock_sendmsg_nosec net/socket.c:702 [inline] [] sock_sendmsg+0x56/0x80 net/socket.c:722 Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb") Signed-off-by: Dongliang Mu --- drivers/net/ieee802154/mac802154_hwsim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index ebc976b7fcc2..d97ed033ac77 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -132,9 +132,11 @@ static int hwsim_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) struct sk_buff *newskb = pskb_copy(skb, GFP_ATOMIC); einfo = rcu_dereference(e->info); - if (newskb) + if (newskb) { ieee802154_rx_irqsafe(e->endpoint->hw, newskb, einfo->lqi); + kfree_skb(newskb); + } } } rcu_read_unlock(); -- 2.25.1