Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3928328pxv; Tue, 13 Jul 2021 07:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYmS6KO12RZ60a0Iugy/4u6g8z1pHgCN+J1JBwzD+XwThewWlUdbFsMV+5wpXTJiRta4c2 X-Received: by 2002:a05:6000:551:: with SMTP id b17mr5939593wrf.32.1626185227455; Tue, 13 Jul 2021 07:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626185227; cv=none; d=google.com; s=arc-20160816; b=kUsUHLITUQ/+GCpiSsRKGtEKjR8idih+7EjIiuCL5pDrkrUEVIUYyDDb0zptDEAfZS HZAtk+4690UxFh7zrJBXnvzOrcC2/2SqTjfHowLCo+7SJkBMjEmIpd7ASQpqXlkfeC2y Zz9Rab3z9wNze4+CMDrZShdYa3qQ3qnHQB3Q88pqFWotYmj16cHtj/PiJJW5zQvvGuyx EbWqkuCHM4Yja3TRPitquzsOvdA1brT3MdXozjScRE+OLdcQfR1em1P3O5uA0YGQuC2z PFslBykVRNWp3P61zyDg3uChc/htasL8LfaoYUZPq2CE2HZRScRlGvPSSw5JHWoVHl8r Bw9A== 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=arUYuAy2PN4/feE5llijqQYwxfh81atG4dBl/yi0Yrc=; b=IOND9A3XDyO620AFCd8tDZj/2GM+M7YN52t9h6CyXVup7x3EBLbC3pD2EjzsrBAm8d pWJWoz9dBnfOOqT/3MNAdzC+cTrq8lNGRKs6aznHDpgrfzPNW6iMAwsf5nsq6Z+yz3T3 3B+koT4aHSilDk98qWR2DaAFUTSjMszDWl39q1dmNJJqexec0i2lCfVUAGapuu8sBAKF aG8X/6bqF23++fWcbtiTaC1Tzy0PvCn/MVrFJiDzCI4dNr5wfiq4vqvfPvzjW+moyWoD QA+yCPOwlEbpJwuvB0tFSnENAA23t/J4gbm+oWKkGRyW8uVd7KFVrfjLvAPDTmaixmRO rEBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qbcg0RVj; 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 v13si20529373edc.210.2021.07.13.07.06.24; Tue, 13 Jul 2021 07:07:07 -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=Qbcg0RVj; 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 S236765AbhGMOHF (ORCPT + 99 others); Tue, 13 Jul 2021 10:07:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236721AbhGMOHF (ORCPT ); Tue, 13 Jul 2021 10:07:05 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ADADC0613DD; Tue, 13 Jul 2021 07:04:14 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id l1so11535895edr.11; Tue, 13 Jul 2021 07:04:14 -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=arUYuAy2PN4/feE5llijqQYwxfh81atG4dBl/yi0Yrc=; b=Qbcg0RVjBLBhe4in65MsZo8Itjh7iHNOFBSeAIXck14Ga87IMfIcv/An5nl2Tc8Loq YuS3FN/XuAJnxd1S0mBfSMcHGzhJdVfBaOXP8DqGDSMWqPLgB+pYQRSmd0G2mi7O4WnW /8VAD114iWB3/gr9CjAFkl3GtQ38FdsrfKcfe9wmyXnz8fvGuTw6bAAin5qUDQyFq+Sw Zz2h9v1YanLFiVAWc/N4vhd31D+B5S5hH2ySzaaPXiA6QiEaxsoZ5nj9dIntDp/UGh/P ZQzlZNovrou6iVI1MudTvuwyY6c+bQ2+vypD54l504Sjd4u6ojxskWQNv1KM9ffDdkTj 7PUw== 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=arUYuAy2PN4/feE5llijqQYwxfh81atG4dBl/yi0Yrc=; b=eLBWUdxqfzZba//2wRy6E3TPql0LmW4A7taZjxZ9Ni1nZNN3b1p/wSPIJrssQAf7Jv JtD0p9OpICmMjHQ57+B0xpUdvkTIIAJ/QFuvccwUbrd3srzeAVq8I3E98kerApQij2Ze PAtlGpHZVPNm3LibG6gE87XlAxtEad5Mz+pexkOYtgAT7sCsIAQl2x7muQcBYrOEYplw pwucZY9OnNGhQhmhPBkjPpLHHuIL0eDy2zoZmBuVWHRkd6Sx//hvAzn7RQ4h2ngBdOVu 6oyDq7Z0mOOXGCtLbcEAvnek9229jP9zP+P4Fmu/xq+li7wVVVvq86Hy5HwGIlMb331M Z/tA== X-Gm-Message-State: AOAM531n++ZP+dF5rjz/Pnib7tuTJ0Vag8B/McmF7SVaMFLTVMykT7Jk JFuoSPj4EIuZ8dblRGuejpy/NGt/grl4iS8PLls= X-Received: by 2002:a05:6402:270d:: with SMTP id y13mr6035528edd.66.1626185051561; Tue, 13 Jul 2021 07:04:11 -0700 (PDT) MIME-Version: 1.0 References: <20210713054019.409273-1-mudongliangabcd@gmail.com> In-Reply-To: From: Dongliang Mu Date: Tue, 13 Jul 2021 22:03:45 +0800 Message-ID: Subject: Re: [PATCH] ieee802154: hwsim: fix memory leak in __pskb_copy_fclone To: Alexander Aring 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 On Tue, Jul 13, 2021 at 9:47 PM Alexander Aring wrote: > > 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? Yes, you're right. I get this memory leak many times in my local syzkaller instance but do not recognize there is already a bug report in the syzbot dashboard. > __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. Thanks for your feedback. I am sorry about this fix since I did not observe UAF in my testing. I will keep learning more materials about socket in Linux kernel. :) > 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. Should be yes, it occurs many times in my local syzkaller instance. > > I need to test this patch, but I don't get how this patch is supposed > to fix the issue. This patch should be incorrect. Please directly focus on bug reports on the syzbot dashboard. If possible, please cc me your final patch about this bug. I can learn something from this bug. Best regards Dongliang Mu > > - Alex > > [0] https://groups.google.com/g/syzkaller-bugs/c/EoIvZbk3Zfo/m/AlKUiErlAwAJ