Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2454583imd; Fri, 2 Nov 2018 11:41:10 -0700 (PDT) X-Google-Smtp-Source: AJdET5cxC1ICB6Paw3U3IhX4Emji97dhrftDebEf4Nv2l0Wf5NWmTD0b8aYmTRSAx0iYK9Ibrqi2 X-Received: by 2002:aa7:828a:: with SMTP id s10-v6mr12577107pfm.63.1541184070888; Fri, 02 Nov 2018 11:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184070; cv=none; d=google.com; s=arc-20160816; b=eKzq21wy0N53IdVfXnvXhqjMvuKD+W+F8xiHRnLkBYr4fyQK3Un2ZfxLeL5DJ3UcP+ Yp1xfcarG6Rd94OxguMdMe9kCro/2qHguWN1FrnP6yHLkU+9DCLfYOJswHY2ljTpvcTW UV7a/2mraq+toxabX0lf56w1hGfp7hrLwWeu1ZoMs26c2+JW884+LwEAHjoooHtBF7UP AEUZC3bLNhbVL7QD94HFub4JJ62JXWHuBfwDH/PJ7AgiJJNQJipvp4jmXHmYGRVPY0yE mCOIBTBlK6m6Wjc+huzfmi77S9Dvj+7LHP1uewlzVwZ2QJUbpHRNRzwfagcxWg4LUDj1 kgvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=blC0QrrsYNg/4vxSsmL/qfjzK8rSKK+50W+7hD7Hm8w=; b=exLxkv55bSDA3HcnVwOjTuPvwh0Yk7AEC6eVjwz9MVnI8OysEziyPLJKY/a9YJlCTG UQ/IILukVKW2p76jul/KpWuVv4tWbsOyP90mxjAlD6Jm7cHJUbO0bnSfSyhmgGiuEYzw B8lpHJlsYealeQN8cZiKn+gv6jkIsJn3Ah5l/VotUfOZngMog2omoiQCuFg44PUcjiH8 bwSiiEoY2Lwqj/gbAr+IJxXh/kNOT2n3VhUQ6qB7I++tX93ejvpPTCqyp1zrBMRIb5J5 toFH/7gS6tz9y3+H5CGBsvmd7fQUehRF0ikY2DxejrENieqmAE0Wle7Jh/2aOIAMQ3u4 +qIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hvsd5Vhd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb2-v6si71176plb.227.2018.11.02.11.40.55; Fri, 02 Nov 2018 11:41:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hvsd5Vhd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729312AbeKCDsR (ORCPT + 99 others); Fri, 2 Nov 2018 23:48:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:42606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729303AbeKCDsR (ORCPT ); Fri, 2 Nov 2018 23:48:17 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE9402082E; Fri, 2 Nov 2018 18:40:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184005; bh=OL7UbhUGXCNLUeyF7pe4YUei0OxW9GDzlvlCMo6KLyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hvsd5Vhd3mr1N8ci0LiQlUzTPF5x+c2LzMepraGvNrhIm3F5EWvkfiK2tbXUDpNL8 5SBaeeAbYi20x2KZ+Y2h+kauE0LF8S3aZZPwl+6KxWIqyhuGsEmpstOW74sCxIITZv keBR8/wQdiWJilkzHKhMl9JQDqR/snlWPZN7avPA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yu Zhao , Johannes Berg , Sasha Levin Subject: [PATCH 4.18 049/150] cfg80211: fix use-after-free in reg_process_hint() Date: Fri, 2 Nov 2018 19:33:31 +0100 Message-Id: <20181102182906.900010598@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 1db58529454742f67ebd96e3588315e880b72837 ] reg_process_hint_country_ie() can free regulatory_request and return REG_REQ_ALREADY_SET. We shouldn't use regulatory_request after it's called. KASAN error was observed when this happens. BUG: KASAN: use-after-free in reg_process_hint+0x839/0x8aa [cfg80211] Read of size 4 at addr ffff8800c430d434 by task kworker/1:3/89 Workqueue: events reg_todo [cfg80211] Call Trace: dump_stack+0xc1/0x10c ? _atomic_dec_and_lock+0x1ad/0x1ad ? _raw_spin_lock_irqsave+0xa0/0xd2 print_address_description+0x86/0x26f ? reg_process_hint+0x839/0x8aa [cfg80211] kasan_report+0x241/0x29b reg_process_hint+0x839/0x8aa [cfg80211] reg_todo+0x204/0x5b9 [cfg80211] process_one_work+0x55f/0x8d0 ? worker_detach_from_pool+0x1b5/0x1b5 ? _raw_spin_unlock_irq+0x65/0xdd ? _raw_spin_unlock_irqrestore+0xf3/0xf3 worker_thread+0x5dd/0x841 ? kthread_parkme+0x1d/0x1d kthread+0x270/0x285 ? pr_cont_work+0xe3/0xe3 ? rcu_read_unlock_sched_notrace+0xca/0xca ret_from_fork+0x22/0x40 Allocated by task 2718: set_track+0x63/0xfa __kmalloc+0x119/0x1ac regulatory_hint_country_ie+0x38/0x329 [cfg80211] __cfg80211_connect_result+0x854/0xadd [cfg80211] cfg80211_rx_assoc_resp+0x3bc/0x4f0 [cfg80211] smsc95xx v1.0.6 ieee80211_sta_rx_queued_mgmt+0x1803/0x7ed5 [mac80211] ieee80211_iface_work+0x411/0x696 [mac80211] process_one_work+0x55f/0x8d0 worker_thread+0x5dd/0x841 kthread+0x270/0x285 ret_from_fork+0x22/0x40 Freed by task 89: set_track+0x63/0xfa kasan_slab_free+0x6a/0x87 kfree+0xdc/0x470 reg_process_hint+0x31e/0x8aa [cfg80211] reg_todo+0x204/0x5b9 [cfg80211] process_one_work+0x55f/0x8d0 worker_thread+0x5dd/0x841 kthread+0x270/0x285 ret_from_fork+0x22/0x40 Signed-off-by: Yu Zhao Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/wireless/reg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 765dedb12361..24cfa2776f50 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -2661,11 +2661,12 @@ static void reg_process_hint(struct regulatory_request *reg_request) { struct wiphy *wiphy = NULL; enum reg_request_treatment treatment; + enum nl80211_reg_initiator initiator = reg_request->initiator; if (reg_request->wiphy_idx != WIPHY_IDX_INVALID) wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); - switch (reg_request->initiator) { + switch (initiator) { case NL80211_REGDOM_SET_BY_CORE: treatment = reg_process_hint_core(reg_request); break; @@ -2683,7 +2684,7 @@ static void reg_process_hint(struct regulatory_request *reg_request) treatment = reg_process_hint_country_ie(wiphy, reg_request); break; default: - WARN(1, "invalid initiator %d\n", reg_request->initiator); + WARN(1, "invalid initiator %d\n", initiator); goto out_free; } @@ -2698,7 +2699,7 @@ static void reg_process_hint(struct regulatory_request *reg_request) */ if (treatment == REG_REQ_ALREADY_SET && wiphy && wiphy->regulatory_flags & REGULATORY_STRICT_REG) { - wiphy_update_regulatory(wiphy, reg_request->initiator); + wiphy_update_regulatory(wiphy, initiator); wiphy_all_share_dfs_chan_state(wiphy); reg_check_channels(); } -- 2.17.1