Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3914173pxv; Tue, 13 Jul 2021 06:48:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9wazL8XZAfzPmzXynCnWNtulL+Gt3M3BzPmHJCPvFmdp00W+98HLUkI69aSIzlx3CLQrU X-Received: by 2002:a05:6638:268d:: with SMTP id o13mr4180922jat.103.1626184120055; Tue, 13 Jul 2021 06:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626184120; cv=none; d=google.com; s=arc-20160816; b=VXPuE2n49DOJ6WxPhe6y05HcxeyFpBxrdVHfHtc/BOMhgR1Dz5Tg16o/5ujbVu4rsr GJqJYqnmH5TLZYyWKOXlrG1KW9a0iadlgqk8TWPhKR7aV84s9fTuJMEAi3/z+9KDDs2q 1euuvXEZnBeSZum6NX8j7gSAmRYgMKrAygJttd/RRXJYGPXZ7szrwMdhfmWQn/+hayVG QgmNrdlodwklI36lzYGzM9B+L9ZTfCtTLdlvwAcfJKbk2KoTocf24zHWzJ79eCrlIJuM yj/kcHscAyKbMpd5zkXj4onFhbWEZG1zOUoejeLZEfUCD5IOeV1EirlVy1vuyJQONCtS wYsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=X/AEnKgR35dch3/Dd4uftg3ppYbt85cCwHqG8mB8H40=; b=Evkq7g2Yi/ikE+sGZW1GBHXYawpJkB/FShW1fXnuhj02qGE8++BKvb53MVO2MaHPb3 Z5D4ns9roH/1wQXtqYhoflETHr9SxrMsrGdYhOjE0EzSE8Kx3ee6qaB2AtoCvXnZ/9tW 2CTTUo06rW+oBM/FBjAYz18l/ejLtEXCJ2GU8NOi28bPmXhRjfw2nHYqgq3B1Xto9Djp EW6DB9mqCDxknK71XamMwmWeTufiyz+R0VKrS7LLSuHSHNtj84JNo1Jgn/2WyLmM0puo 0bbGZEsN9SHuCy8DUN+CLSHxmjY8HzgAVxd8oQR21MNrrWVFhPeabV8vlK23kSDopYOZ J8rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hHPV0jO0; 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 p7si12480131iop.92.2021.07.13.06.48.03; Tue, 13 Jul 2021 06:48:40 -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=hHPV0jO0; 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 S236620AbhGMNuN (ORCPT + 99 others); Tue, 13 Jul 2021 09:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236222AbhGMNuN (ORCPT ); Tue, 13 Jul 2021 09:50:13 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3972FC0613DD; Tue, 13 Jul 2021 06:47:23 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id p8so30550186wrr.1; Tue, 13 Jul 2021 06:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X/AEnKgR35dch3/Dd4uftg3ppYbt85cCwHqG8mB8H40=; b=hHPV0jO0A53LsFdk1uIC2UDPRjwsgp6Khb9VjaAoaF31e/tfTM/VZeelFGvz4A1LhQ VqIsT7exIXTKWb635pIeS2si1JfsMbllUg1pTpFXsgyiobOVnFTfPr6Zdqub1qB0GL2p Z4K9vbagjhnMaI+y9VE2nbP/7Na7sf/NnDzveuSHKPfogbo11SPevbH3ZJauTo7nso/H 9gq4gSxmaXQ6I83ipChNMc3ow8UhHjeN1dtMvapBqI6quoHXubYjckkF0g8vlcQAa6OM zLrInzQEl/8ObWfTF2c4kPlyViBRTBLGzryI2xPP371Yz51cRxZIaVGkgTKH1JLbyv/w huFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X/AEnKgR35dch3/Dd4uftg3ppYbt85cCwHqG8mB8H40=; b=mEi5TdzyNO4XNJ44hfSfEnDO+B+32UYSmZ3lJkt9tJZ+yeFwevSRz4AIZ3NhbXg/8T FdjxHIn3Pnw1xpgVvKiWLBq2nulB7XnJHlvo9KBhxUg46UOOxCB8sgX9N2KB3jxf5lxw Oc75nj1SKDgzKvpvV0aXAVtZEsCcL9LhCpcqqOGWHKW2DDolIJxxA6f3+Jf+ClEt2jGr wkM0OvRUIUUBKKLSANv8Nh6/FXF7v8sE1G9Jj/YB6++7czQjLdb9rqfpdfa7YWjpIXyd mVg5BFDc7fUXdi6N7Ym7e5QXgUQoPoei/45AVh3+QVAAmdcnvIYARBam8/qGyZ6keFES daqA== X-Gm-Message-State: AOAM531kOCCaa0aE61+Wt1bE8wCJ7Z14y9p82EPceqMPVTF8gE2ooz6l zsZEsbo5HcanCgMEgLXOW5us3LMAceheG+EUfLg= X-Received: by 2002:a5d:530b:: with SMTP id e11mr2420650wrv.65.1626184041894; Tue, 13 Jul 2021 06:47:21 -0700 (PDT) MIME-Version: 1.0 References: <20210713054019.409273-1-mudongliangabcd@gmail.com> In-Reply-To: <20210713054019.409273-1-mudongliangabcd@gmail.com> From: Alexander Aring Date: Tue, 13 Jul 2021 09:47:10 -0400 Message-ID: Subject: Re: [PATCH] ieee802154: hwsim: fix memory leak in __pskb_copy_fclone To: Dongliang Mu Cc: Stefan Schmidt , "David S. Miller" , Jakub Kicinski , Alexander Aring , linux-wpan - ML , "open list:NETWORKING [GENERAL]" , kernel list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, 13 Jul 2021 at 01:40, Dongliang Mu wrote: > > 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 sorry, I don't get the fix. Is this a memory leak? I remember there was something reported by syzkaller [0] but I wasn't able yet to get into it. Is it what you referring to? __pskb_copy_fclone() shows "The returned buffer has a reference count of 1" and ieee802154_rx_irqsafe() will queue the skb for a tasklet. With your patch it will be immediately freed and a use after free will occur. I believe there is something wrong in the error path of 802.15.4 frame parsing and that's why we sometimes have a leaks there. I need to test this patch, but I don't get how this patch is supposed to fix the issue. - Alex [0] https://groups.google.com/g/syzkaller-bugs/c/EoIvZbk3Zfo/m/AlKUiErlAwAJ