Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3902201pxv; Mon, 28 Jun 2021 16:11:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3parnTmysnO9QN2Ukxl9xOSVZpdIVgzAUOAVb9lBiXzzDh4lw5f17l97mQjFgKd0zWXZf X-Received: by 2002:a17:906:8c1:: with SMTP id o1mr26754303eje.530.1624921879196; Mon, 28 Jun 2021 16:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624921879; cv=none; d=google.com; s=arc-20160816; b=QsWf5yqs6gm/PqHhhorhcAMYsxlMXTMmgneMUPkNaRx+JeTI67tx95/Eg4oj8KoiOJ ZGZlkqzt+B6wysKasEw4EGbrjD6c+y7elM4TUCSlNyIH4RggUGVawAZDbRE1JT348kST izBmd7fUfTFaj1L0tt9/ozPttbq5YALcTXc3Ue3H+zm827PKw7qW2NW5EfUNBEcyZwwK lxSoSl/BPOtxdluqxWOUvAVS2iqA6ki4Sd1sH624rW+MM67knzPfSqmJrQR+09W1xNiI L8a9YU7iRZnKh5ft0gKZ6VQLvMU3jctvEp2J/VeliOdwIAaEyrUIUB9/BymtYx2DLNPI WorQ== 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=7RLZjwVa2wYsQSQ+XT87PH8EhTz1cIIgkjx9b/Ah0hE=; b=xRMWatwJpWRA6kpXFkfzq5zYn9Lpv747oF6j8OCKXaD9vx4lNWnymjqaPPFHe4JEs9 WiCd1uukAbBfZz3+aUEvMUjTXvr8L3gmJ53XxtZrwq+WAZQIs0B/YOsbiGQcw/Ma/f4o 8uiZoib+MqN8xjlR6EWpXGS3EeJ1ANlkYXWUFzRb/i42LXIuDxnCfD4meOykW6EDbMx3 ILkeRwQIP3ZGvBVmJGbC8A+DLGLOrwm/D6D67Td0NaFtklTH/6vPdlTXvHTB9F9x46GF 7j+f/yyJCRf0XkxqrlYt+gUQoNoMt57DJRodgoN4kEVPblykUZ5WbKE1nnZZ0vJgoTUs VKFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=udJeungx; 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 5si14043307ejh.625.2021.06.28.16.10.53; Mon, 28 Jun 2021 16:11:19 -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=udJeungx; 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 S235349AbhF1Pa5 (ORCPT + 99 others); Mon, 28 Jun 2021 11:30:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:38868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237309AbhF1PFj (ORCPT ); Mon, 28 Jun 2021 11:05:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E7B2861D7B; Mon, 28 Jun 2021 14:43:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891417; bh=NfLd0CxEmiWCnfSYGMlgS5GtNaM6EQLJ2hNcN4KTWP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=udJeungxy84QzIsK2N/aKnXYdvCldMjCW4dnpREdLuY2SYx5CtYAt/YppJuxflVxq rcPLeRiJlocRyUt8/mNlrOZgYBz37UymOPcH6e1MoEteWDa27XlfXrRfnBluga1w+j dCnmQDqJBam2ePBjdZt5Fc/dQir+tjfThNb2Jdd4P0e9+7/hsjdugIoAJHQ4qXtmBD PKSMsaj6exNzSn+N14J/RX0nGQ9Z7YGrS/eKfyOl/L8mtIfTV5cDECz6CuZ28qudTZ pTy5JIDUWzKc1yApqx6sB1OMBFAA+07NGpijLl/k470xtVaoJ1Dq6JYY2xIeGyd2qm XEun7whn1136w== 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.4 46/57] cfg80211: call cfg80211_leave_ocb when switching away from OCB Date: Mon, 28 Jun 2021 10:42:45 -0400 Message-Id: <20210628144256.34524-47-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628144256.34524-1-sashal@kernel.org> References: <20210628144256.34524-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.274-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.4.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.4.274-rc1 X-KernelTest-Deadline: 2021-06-30T14:42+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 915f1fa881e4..73c361fd4a16 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -978,6 +978,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