Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp642298ybz; Wed, 22 Apr 2020 05:20:46 -0700 (PDT) X-Google-Smtp-Source: APiQypJkYGCzz4ohw4tuXsnR+da5qMoo/vAa2UWnlYK2homA2SgLfC1PpKeAYCvWIHAXmE3oO99X X-Received: by 2002:a50:e0c9:: with SMTP id j9mr22567793edl.127.1587558046601; Wed, 22 Apr 2020 05:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587558046; cv=none; d=google.com; s=arc-20160816; b=UpDY5M00MtUc/ByrnV6W1Tzf/g3GYAbn2x/HgVF1B+qiU24LOr28603PMGzSjWndGq i0ToXRgJ9V2hi5EuaHM/nX8rHTEmNE2W66+QbiaTUpC5ltm7ubxYUB0q2lzd8cozEPHK 0nyMTus1fwCZIV8q1RxE8tXkL9kX1DiQFdjzXhCgDn6vLcGQGfxviOO00bWP61t22V6D SHy1xN3ocYQw+Z6Ny4lLSXc6j3ojexu/TOjnwH4TA8QowA7i9n+/v5yJSpP1TpIm114q pgIPyk0yUj5xTKVnX9rtOM52iRQjIHnNdnsP4xvEYT6OaZ+te5uTUUPNWA/qFvXI0Lhz c56Q== 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=MGz9SDU+MB26TFA9WLhchRnjBBfVyL9CDWhoCiyNIys=; b=goIgZRwXRT1gpVFBKBVGkYJm1eppQzR87RTFu6PUmVerebOpXfU84TINIQCP53fxB4 ur1CO6syiMLAPK0b7mRCf7PQ23B3Fz6RiUn5z/C4I2Ali2PI2IV7oz7dpQ8RDYh8JKLs Xz1uP4/ynhvpzO97SbutzxjSbsp4Q5VU+NADrI3l6SCruoMLmafMlJVswbizRyLUC+p1 iu4Yk0zij+zvcEdpXHhAOwnPvImxJ2jr3TZJaZ1yh+gvh9LPfJ1lFmNih0SZf/OMLSZK mRuTSJDA/opPPR0q1GXo32ACWJyB9enspA/AJxvR4XBOTOEvJg22JVbMXlnOEDUJJxdB thXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GvPn6ZoL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si3416400edq.89.2020.04.22.05.20.21; Wed, 22 Apr 2020 05:20:46 -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=default header.b=GvPn6ZoL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729212AbgDVKLf (ORCPT + 99 others); Wed, 22 Apr 2020 06:11:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:43412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729196AbgDVKL2 (ORCPT ); Wed, 22 Apr 2020 06:11:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 1EF5420575; Wed, 22 Apr 2020 10:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587550287; bh=w7Oe6kU8KeqaGTWQVW1K2a031A4Zc+I/XnQvs7lfw9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GvPn6ZoLb8o3AlTjpWdErvsZrH2ALVvPOb8yUjEzs0qgLBC1Mv4qALH984u1Og9Tm yOb0Z4Xlzwb7l+GJ4pe07xnqHI7iWJ8a4QRNJldDpcAlTIwDk0ioukmaxZVra4IOa1 QzqXzD18B0D2m37fynv2o/T/yAllcEuEjc2S5rXM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver OHalloran , "Gautham R. Shenoy" , Michael Ellerman Subject: [PATCH 4.14 084/199] cpufreq: powernv: Fix use-after-free Date: Wed, 22 Apr 2020 11:56:50 +0200 Message-Id: <20200422095106.499041584@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200422095057.806111593@linuxfoundation.org> References: <20200422095057.806111593@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Oliver O'Halloran commit d0a72efac89d1c35ac55197895201b7b94c5e6ef upstream. The cpufreq driver has a use-after-free that we can hit if: a) There's an OCC message pending when the notifier is registered, and b) The cpufreq driver fails to register with the core. When a) occurs the notifier schedules a workqueue item to handle the message. The backing work_struct is located on chips[].throttle and when b) happens we clean up by freeing the array. Once we get to the (now free) queued item and the kernel crashes. Fixes: c5e29ea7ac14 ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}") Cc: stable@vger.kernel.org # v4.6+ Signed-off-by: Oliver O'Halloran Reviewed-by: Gautham R. Shenoy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20200206062622.28235-1-oohall@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/powernv-cpufreq.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -1041,6 +1041,12 @@ free_and_return: static inline void clean_chip_info(void) { + int i; + + /* flush any pending work items */ + if (chips) + for (i = 0; i < nr_chips; i++) + cancel_work_sync(&chips[i].throttle); kfree(chips); }