Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3427057pxf; Mon, 29 Mar 2021 01:47:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpLyPcZmXHD+E4JAuGRXh8y3Ki56ZggdC4dKAT6BABUp78su9+la7nzR1C746BVIDM5KBK X-Received: by 2002:a17:906:2dc1:: with SMTP id h1mr27784416eji.460.1617007627595; Mon, 29 Mar 2021 01:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007627; cv=none; d=google.com; s=arc-20160816; b=n+A4Q2iYG3XqwOKSvWYlScSEmw590g1UbgT6tBa5uYCW5JXTccyOStcKvcBcfsbQTm LRxThGxuAmrS2U+9rx9lQ6Hb3+ERyKhUqir0ip9aGEavEcC0b4Ptj2N60ZEjeI2YGKYB x0ztf8UCEwBoNH3LpkFgJ3300BOfHMxwWx+YrBrXaG8lEbb4KbS8bMqb75mU/i6ulQSW 1LQmHSeBmCYcvp8mW0x6v9K5lra/D8xKGsVuD5thxBZswqd1oraMfrRTaJ0ZHYfxjYFI gp28VKHRijLeZpCM9EMpyOkizsmx9fRiSeBNxaUe5tMQ4ioplJvthD7l+Wms0ALo0+pG ASpg== 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=d/qy+atZtlmNt6VjgHQMcOTRq/rjcNnZ9/dy/0rOaAI=; b=lwGu9z8+uYVlaCltTmjhVv7H8hrHU4yQJbL6tahGA9D9WJ4Bd/Z8ei9EnDiRCweXKt HtvbayOBg0gK4+r7yIX+zr9XPfN0W737VFgM7DZo4fkJAgAOjRgIVfMWtYLCcyU7ktDX CqCX6qGYDFTzhJshwEXN79R5gIxsd0lnLEi8uBmav1DesoQH8hJhHkojTsiaybQIZTo+ UOnyn5bpZ4npKTlaGv+YW31JnBoVZFIZGJTM6xVQKbJThs4RypHns6zTqAAmDX+Ncamo jqEx82DAba3bqJy6s+0W89Btc2D/nsd+IvwyMsqgPGg2tSizESDe/bdhbq7ybLXzFhx9 CuqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DzksEFc+; 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 gv29si12093459ejc.61.2021.03.29.01.46.45; Mon, 29 Mar 2021 01:47: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=@linuxfoundation.org header.s=korg header.b=DzksEFc+; 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 S235189AbhC2IpA (ORCPT + 99 others); Mon, 29 Mar 2021 04:45:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:42762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233982AbhC2I1i (ORCPT ); Mon, 29 Mar 2021 04:27:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 12279619B7; Mon, 29 Mar 2021 08:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006386; bh=aB1bPERZL4+MDJO/eREvx5Ils2tqtNCkAXer8rKSNvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzksEFc+jIxJ+QuE8DDu6POzGV75KiQt8dq1gD9vh60l0aXVAFO4nkgE1UcyM4re9 wEUn5Ua+4hBlJq0gh+DNkLnScY9CpJExmxk9qQited+1IfBq61r2eceJfFTRXma4Lu hJxttWyVlB5fypORAznXl3zk0nnaO/ACmuMgwrTA= 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 5.10 215/221] mac80211: fix double free in ibss_leave Date: Mon, 29 Mar 2021 09:59:06 +0200 Message-Id: <20210329075636.309352939@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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 @@ -1874,6 +1874,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));