Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3550027ybl; Sun, 8 Dec 2019 17:42:34 -0800 (PST) X-Google-Smtp-Source: APXvYqyTg2WdoBkrxqn76VK+qII3TJnnVnxQKDOPYRfEK9n+NY4hcz0/BnUjBDj5K9T882GXG8Mx X-Received: by 2002:a05:6830:2001:: with SMTP id e1mr18299252otp.97.1575855754917; Sun, 08 Dec 2019 17:42:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575855754; cv=none; d=google.com; s=arc-20160816; b=t1dmW2nPjWDusMiXObWoAK4WxoMXPPmucTCRUI4yGs1GBxsj+xqV7yUi3ep24iFvEA 2OcvQz0FwUTACcUZ9d03Z6K6idlRd96d3C1kS7dhEQAw868kGoMxnSS6Cfujh7Lg4TTc 221fSpSFFz94jkYAfFoTLTZWf3rSRkjk1+D3myCC4jSoS5+wCtIU6hX8wBgN/sjTS+A+ kfAQq579buM4BhcWjCeuqqCtqdz3rPfuEbklscb1KFwEaXLXHoGboe0PvGjAVHB4rNps TRzLnNeW7RuPFevylTm+VBFAv19lADjc22RQ8AA/hFlh53b+/HqUDHopWi4fv0j+kK8B r4pA== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=ihTuW0S0PLHgzpqHwaLSCw/gAxGC5PRrMoL9l3iqkpk=; b=00qCQmzpvjoEZNGjRS0lI7+JPJvFQOg+99tC8TLbbbPufw7Hi42SHcTuc0eQn+oSmL gkxA4jQkiKnoZ/vWNiMM39VrmxbVn73sPTvTjq1fnzJjXucPVWoAO+qAqLLtfc5RD8Ao TKXtefdGuZnuMO6CZchxUc47AhhZkWfB1X+rZq4e286Aa03gDVC/0e2gSqIfXSQnGbBW TPgA8cshuewra0ZPFierMz9k8GMGz/JTkW9Yxps+tx6cU0TE+9GIRCh/luLF+vchvuhM csS0WEer0bLaM6qyyQIStuYibcUQp60GR6klauVK2F4QXb0uD1NZ0Zizk3bUT/Ku+Xqw yVvw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18si11301619otn.257.2019.12.08.17.42.23; Sun, 08 Dec 2019 17:42:34 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726845AbfLIBkn (ORCPT + 99 others); Sun, 8 Dec 2019 20:40:43 -0500 Received: from mga17.intel.com ([192.55.52.151]:45255 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726635AbfLIBkn (ORCPT ); Sun, 8 Dec 2019 20:40:43 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Dec 2019 17:40:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,293,1571727600"; d="scan'208";a="206735287" Received: from rzhang1-mobile.sh.intel.com ([10.239.195.243]) by orsmga008.jf.intel.com with ESMTP; 08 Dec 2019 17:40:32 -0800 Message-ID: <2a37f59cd86d75258ac7257a23132d6ebfbcea70.camel@intel.com> Subject: Re: [PATCH 3.16 43/72] thermal: Fix use-after-free when unregistering thermal zone device From: Zhang Rui To: Ben Hutchings , Ido Schimmel Cc: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , "akpm@linux-foundation.org" , Denis Kirjanov , Jiri Pirko , "wvw@google.com" Date: Mon, 09 Dec 2019 09:40:37 +0800 In-Reply-To: <92faedffaa625da9d385a6af2e554d8e4744fa7a.camel@decadent.org.uk> References: <20191208162216.GA330015@splinter> <92faedffaa625da9d385a6af2e554d8e4744fa7a.camel@decadent.org.uk> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2019-12-08 at 18:09 +0000, Ben Hutchings wrote: > On Sun, 2019-12-08 at 16:22 +0000, Ido Schimmel wrote: > > On Sun, Dec 08, 2019 at 01:53:27PM +0000, Ben Hutchings wrote: > > > 3.16.79-rc1 review patch. If anyone has any objections, please > > > let me know. > > > > > > ------------------ > > > > > > From: Ido Schimmel > > > > > > commit 1851799e1d2978f68eea5d9dff322e121dcf59c1 upstream. > > > > > > thermal_zone_device_unregister() cancels the delayed work that > > > polls the > > > thermal zone, but it does not wait for it to finish. This is racy > > > with > > > respect to the freeing of the thermal zone device, which can > > > result in a > > > use-after-free [1]. > > > > > > Fix this by waiting for the delayed work to finish before freeing > > > the > > > thermal zone device. Note that thermal_zone_device_set_polling() > > > is > > > never invoked from an atomic context, so it is safe to call > > > cancel_delayed_work_sync() that can block. > > > > Ben, > > > > Wei Wang (copied) found a problem with this patch and fixed it: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=163b00cde7cf2206e248789d2780121ad5e6a70b > > > > I believe you should take both patches to your tree. > > Thanks, I will add that now that it is in Linus's tree. > yes, please do, thanks! -rui > Ben. >