Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3413290pxf; Mon, 29 Mar 2021 01:17:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFPCXZmgqWRb6UFpunEUcLGzj3hTCBH/rs9WF67cPilU9UtnFVoLZhvDpSNImIyoNoPCVZ X-Received: by 2002:a17:906:5e01:: with SMTP id n1mr27501277eju.359.1617005859708; Mon, 29 Mar 2021 01:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617005859; cv=none; d=google.com; s=arc-20160816; b=gT7BKhn7mchSQ/dIrQXvUoV6KPhpHTDOPcPNXPwwdw3B+0f4jzCOEpKIt/8D6XugNC bci0PXN85MR3aIdvQ9QW48bYlVmofFWK1WWvXCbl8DcbUidRiEIWNK7+VxfLRQiOxqwz oUJ5WISrn+gTlQ3M00N7AfgI7gTkcxLZGc13GCo5YCmCX/XSQ/NShKGwE2xy3HyZ7bEV NTv4GzLWiFRtCJP9lBcLBDP6guFWVORMmOXz9yDJVjlGjpCxQi6IZPqQhu1ohlIjnST1 T/L6H6ze9C6nZrODcsiPzPMgWAlQRxFHJqQTxzQxdUHyCUOu/NvzyQc1gvitLpxbj5yN VRqA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RVbEKcankGjNnKI6L1MblbZpdgqO/vcjMnWf4FyKC5M=; b=FQEk8XIY91alvSo97spD/6xHUKQ4Qp5HOzVQuIiVbG+gmYOpSH04uB6VmExED4ydhX LNssg9sZWhp8JoG2FMRE/6xodYyvSKbI99qnPUCflhOfplFk8XwIf4kqk5NQ4rT1/wiB xh9W6snxITElUlO9n25ajQ83eWtq7TBvNy6CM96p1zlRtcfhSuWlahjcCMENc77/qjbl kn6JwaLJiWe60aQNT8olECuMEWVFqf6cGyLLKnZaQpWsHewmRqHSxAf2J5eL3tT/2GKT VOGJqQ4x9s5zpUdv22aG/Nd/CRlAX+1k/mCthL8cfSYn/6I3Ik4jFqmpHaGzQzrAsWS3 hipQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q6fsWwSH; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si12610919edt.553.2021.03.29.01.17.17; Mon, 29 Mar 2021 01:17:39 -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=@linuxfoundation.org header.s=korg header.b=Q6fsWwSH; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233104AbhC2IQ0 (ORCPT + 99 others); Mon, 29 Mar 2021 04:16:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:52992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231657AbhC2IKL (ORCPT ); Mon, 29 Mar 2021 04:10:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F24AB61997; Mon, 29 Mar 2021 08:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005411; bh=zNWJ3S6ipAU6dbDVMKFDhWmunigq6V3cEmVjjZAnHXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6fsWwSH6Miw6vt20gboBPV217t70CyXfQW0btqSLFSt/mQc8o+Hk8q14ks63iJp3 Cx3dR2TWuNWHbt0s/mZWmIvVxy1LToAgQEdfOUvU8+LYevpYaSaHOsuy3R68er+PiF XChfmsjmZJWjxVPaKdnIHQvCexMNhmTyPhsbeDuo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+93976391bf299d425f44@syzkaller.appspotmail.com, Markus Theil , Johannes Berg Subject: [PATCH 4.19 70/72] mac80211: fix double free in ibss_leave Date: Mon, 29 Mar 2021 09:58:46 +0200 Message-Id: <20210329075612.592902253@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075610.300795746@linuxfoundation.org> References: <20210329075610.300795746@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Theil commit 3bd801b14e0c5d29eeddc7336558beb3344efaa3 upstream. Clear beacon ie pointer and ie length after free in order to prevent double free. ================================================================== BUG: KASAN: double-free or invalid-free \ in ieee80211_ibss_leave+0x83/0xe0 net/mac80211/ibss.c:1876 CPU: 0 PID: 8472 Comm: syz-executor100 Not tainted 5.11.0-rc6-syzkaller #0 Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x107/0x163 lib/dump_stack.c:120 print_address_description.constprop.0.cold+0x5b/0x2c6 mm/kasan/report.c:230 kasan_report_invalid_free+0x51/0x80 mm/kasan/report.c:355 ____kasan_slab_free+0xcc/0xe0 mm/kasan/common.c:341 kasan_slab_free include/linux/kasan.h:192 [inline] __cache_free mm/slab.c:3424 [inline] kfree+0xed/0x270 mm/slab.c:3760 ieee80211_ibss_leave+0x83/0xe0 net/mac80211/ibss.c:1876 rdev_leave_ibss net/wireless/rdev-ops.h:545 [inline] __cfg80211_leave_ibss+0x19a/0x4c0 net/wireless/ibss.c:212 __cfg80211_leave+0x327/0x430 net/wireless/core.c:1172 cfg80211_leave net/wireless/core.c:1221 [inline] cfg80211_netdev_notifier_call+0x9e8/0x12c0 net/wireless/core.c:1335 notifier_call_chain+0xb5/0x200 kernel/notifier.c:83 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:2040 call_netdevice_notifiers_extack net/core/dev.c:2052 [inline] call_netdevice_notifiers net/core/dev.c:2066 [inline] __dev_close_many+0xee/0x2e0 net/core/dev.c:1586 __dev_close net/core/dev.c:1624 [inline] __dev_change_flags+0x2cb/0x730 net/core/dev.c:8476 dev_change_flags+0x8a/0x160 net/core/dev.c:8549 dev_ifsioc+0x210/0xa70 net/core/dev_ioctl.c:265 dev_ioctl+0x1b1/0xc40 net/core/dev_ioctl.c:511 sock_do_ioctl+0x148/0x2d0 net/socket.c:1060 sock_ioctl+0x477/0x6a0 net/socket.c:1177 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl fs/ioctl.c:739 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:739 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Reported-by: syzbot+93976391bf299d425f44@syzkaller.appspotmail.com Signed-off-by: Markus Theil Link: https://lore.kernel.org/r/20210213133653.367130-1-markus.theil@tu-ilmenau.de Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/ibss.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -1861,6 +1861,8 @@ int ieee80211_ibss_leave(struct ieee8021 /* remove beacon */ kfree(sdata->u.ibss.ie); + sdata->u.ibss.ie = NULL; + sdata->u.ibss.ie_len = 0; /* on the next join, re-program HT parameters */ memset(&ifibss->ht_capa, 0, sizeof(ifibss->ht_capa));