Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3837098pxv; Mon, 28 Jun 2021 14:16:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+VRkmXiTivGo7AMD3Adgc1EB8euKPS+3y1cVbpTdtJJ/hOW7IdK8A+JheqTAz5Y9e7z0J X-Received: by 2002:a02:ce88:: with SMTP id y8mr1368559jaq.34.1624915005040; Mon, 28 Jun 2021 14:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624915005; cv=none; d=google.com; s=arc-20160816; b=0mHJmxER7Xm+EckL+jqT/n9rAncG0LWMdg2cqbJzAKKPsBWwgSDXESJGKRzBv+PsIb ItZVoFw/G44+Ezp2gv2GbcpHic/nvmS44/+1jeo2iDQ+SqGgCggjd0xVI+rMsZNf/RbG O2iPtJUaoWErjkd2TGxKiwL3c/uiEl7zgt+ErSbD6gqrpzkml+0gGZfEZr+W2OgxgEnQ CAZH6f9jtcuqF+FAaybXJuTCT4xBJLBMbkg3m09VxOPuZp16bVz89NbfysCQofVzqZhL L7r3sFBTHIaARuqa8Mz3YjattjPlW9PkFhFctH3qHwF3hckeB0ufDwHczZr9IhyREUmF lnPw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kIHHyCvWkMcykVA2vWqXZxDCY99WPDBZOTtc0o41bg4=; b=Oy842yeQXCnigW0ydJLQ2pzCfjypEkhDi/uX7IcK4+yxbxNg28r3k9dBi8iaYZsknU CEGlX1/MVEF/xvCgFSlIKUA+l5PxyPmzlve9ZPLmAKwOxC/WXWGMmcIn9uy439FfJer0 lz8fHaCJYL8IVZKqCM7jJ7Uh660jTEkzfnGFKmiGMcniL2xjb0SxjzAm9zr/FKF4z6Qw ftZnpBa/h/mYWLu407TCxIWWxR51m8tltQLGSKVrQuuMFfE6CwhEqXrXsz+77lAgijod IQGyJflIPV3hGcAvk1tuUV0o+35hCUpS0k6M2wZ20oNXKHbDw+o84kb+R5yMSP0Up64L OKRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TJSuQOMu; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si16302778ilv.105.2021.06.28.14.16.26; Mon, 28 Jun 2021 14:16:45 -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=@kernel.org header.s=k20201202 header.b=TJSuQOMu; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238119AbhF1PPZ (ORCPT + 99 others); Mon, 28 Jun 2021 11:15:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:33816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235979AbhF1OyZ (ORCPT ); Mon, 28 Jun 2021 10:54:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C17A861D40; Mon, 28 Jun 2021 14:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891053; bh=r8IWdIvS4jYced6+hLLBJTgjwwHA9tnMWBU3Rxhg9B8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TJSuQOMukc1/TXDl7DehJIY+q7N4LwGwtobIJFrtRlkvazPEz5FQQm2njZULvUSmV RPeLd5Jrv1n08yaIykuZXufRlDDo7D/3XjcNXV/YaALyjC4Kvw/itt/EByUZNE2/Ob 3qeV0WymbrE1RfXJ/UKQHd0H1WFIP+KswdtcvK2b/QP+zCvYumEMWX4KMLH3sKm+ZC 07AvkeeX/JHTI1C9RE77Y0OnIySZMtRDmjQWfBPgv2tu8CkLIlA8C6AbWDQbJkwwX9 ijP4T/0R6VQYYFidD+PhRpVxNU6XWEG0IzCHrFn9tWUTTKuXsaxkhxDMsnqcDxCqFy d5YMz7ELYLO8Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Du Cheng , syzbot+105896fac213f26056f9@syzkaller.appspotmail.com, Johannes Berg , Sasha Levin Subject: [PATCH 4.14 73/88] cfg80211: call cfg80211_leave_ocb when switching away from OCB Date: Mon, 28 Jun 2021 10:36:13 -0400 Message-Id: <20210628143628.33342-74-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Du Cheng [ Upstream commit a64b6a25dd9f984ed05fade603a00e2eae787d2f ] If the userland switches back-and-forth between NL80211_IFTYPE_OCB and NL80211_IFTYPE_ADHOC via send_msg(NL80211_CMD_SET_INTERFACE), there is a chance where the cleanup cfg80211_leave_ocb() is not called. This leads to initialization of in-use memory (e.g. init u.ibss while in-use by u.ocb) due to a shared struct/union within ieee80211_sub_if_data: struct ieee80211_sub_if_data { ... union { struct ieee80211_if_ap ap; struct ieee80211_if_vlan vlan; struct ieee80211_if_managed mgd; struct ieee80211_if_ibss ibss; // <- shares address struct ieee80211_if_mesh mesh; struct ieee80211_if_ocb ocb; // <- shares address struct ieee80211_if_mntr mntr; struct ieee80211_if_nan nan; } u; ... } Therefore add handling of otype == NL80211_IFTYPE_OCB, during cfg80211_change_iface() to perform cleanup when leaving OCB mode. link to syzkaller bug: https://syzkaller.appspot.com/bug?id=0612dbfa595bf4b9b680ff7b4948257b8e3732d5 Reported-by: syzbot+105896fac213f26056f9@syzkaller.appspotmail.com Signed-off-by: Du Cheng Link: https://lore.kernel.org/r/20210428063941.105161-1-ducheng2@gmail.com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/wireless/util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/wireless/util.c b/net/wireless/util.c index b3895a8a48ab..bf4dd297a4db 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1041,6 +1041,9 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, case NL80211_IFTYPE_MESH_POINT: /* mesh should be handled? */ break; + case NL80211_IFTYPE_OCB: + cfg80211_leave_ocb(rdev, dev); + break; default: break; } -- 2.30.2