Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp840756rwl; Wed, 29 Mar 2023 09:07:18 -0700 (PDT) X-Google-Smtp-Source: AKy350YIb32idPyLNHPy2a5E+ig2x/GLUR3J+Rg2M8z82jnyGozy/rmFducx7TtPc+pFsbNEeIoZ X-Received: by 2002:a17:90b:1d8e:b0:23f:37b6:48f4 with SMTP id pf14-20020a17090b1d8e00b0023f37b648f4mr21229222pjb.43.1680106038017; Wed, 29 Mar 2023 09:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680106038; cv=none; d=google.com; s=arc-20160816; b=pmJju7BHUYM7HMRAZhLFzDi61jICNjyM3UUsOizGIbIHuAY2RllCk/+pI5jlLysYAp amFqdZMtQ773m0UJfq4ki6xq7Nab40K2tkm4hX6P0monjeMPgrcN0zj16X0jYv/4VgdR x4XdR9/Am45RdBCZOD5SG2KTruM6WNLYcyH9T74fV6XrE8yDMKVzWRS4aY9KWSFSFY8m Yksan97/zjUYK0Q/TvpMxb627sj6N5jDiKdnYMTDXheF22rey/8joFS8z0SLgxyukBtM +b8C4hRyufN+SxGQsLMwQVTYD+l25DEQl4ETJ8EnVldap7tH2Z2ofEuzWrkJIg18b3fu 4RTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=AIqIA9MMKSE2Yct64EsC7fjtfIOopEbYlLS/NmL+W4A=; b=sQVHwHeV2oT46Jcq/ZgGc+FW3T6T65LVt9WYSeOMxF+wV4XskZJMF2XPlpDoY7b13A FTzW/A40qj1Eubq1Za9TV8QNZ2Y4oGKaomJ1vl9VQ3rNHL7BBqidXBKuOC8WgfB3h2+3 OGVAZjlyrTNSiFAq/D9iKjLzCtGrMBSgoRqtSETDRm3cj65LOyyut2tJRnEEynoBkFL+ N64uNJ+6pcDmNXTvp+zkCkrsKBjhQHNYZtbBNnkBVK+HIHffB5blm+CugVJyxVrhjEl0 6IA4Nr19PbWTh0KHM2ZrZlrzPH98vF+Hzjzg0eAmS4W0P1zuqp8JaDaouBEn5WRKWY66 HWGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a17090301d000b001a1799a0db6si7513326plh.63.2023.03.29.09.07.06; Wed, 29 Mar 2023 09:07:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230345AbjC2QGI convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Mar 2023 12:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbjC2QFs (ORCPT ); Wed, 29 Mar 2023 12:05:48 -0400 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2485E65B4; Wed, 29 Mar 2023 09:04:49 -0700 (PDT) Received: by mail-ed1-f42.google.com with SMTP id eg48so65292785edb.13; Wed, 29 Mar 2023 09:04:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680105818; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T06f8oc4KixBkG6GFlvqArSOU9shv9azMw2lKiK7zrw=; b=uF+gd3kVF1bTnItzDEqIPNDssSaTkxAKeFyy0Wt5cIIm7g10whWShyqPx884oWrivL xWFrj7FJdZZLjlkyuBzHJtN4MOrQb8FkRKCJQsqnTZqGbE2XtE4pnPythx+gcaSHEhvX mDDNdKajDIeb3LMDGw+E58o+8hRo+q6kvX3r9hDEtMdUyKAwMAw128ARTT+SqIzH0iHR /Zq0JWzJW3itCo2Ak6PrDWFwIN8nF2LJQAGR/QGRhXl1YJWRDoOV0qE2N7rvIWIYKhDB 6iTphzJtIFvtaD8pcQrVkTe2NKu+JWpJcQeHfksoqYOF60oz3ttXUeIerRQ7L4gGDDbt B4Ig== X-Gm-Message-State: AAQBX9eKiV/Prbw/R6N2Fb+rFO0q6uCjHl3vc3XsVtnqSSlWpTUnTtny wH0t3t3Tujv/9L2j46chTnOOboSa9qiQDZKbiac= X-Received: by 2002:a50:9f82:0:b0:4fa:3c0b:74b with SMTP id c2-20020a509f82000000b004fa3c0b074bmr10183827edf.3.1680105818183; Wed, 29 Mar 2023 09:03:38 -0700 (PDT) MIME-Version: 1.0 References: <20230329090055.7537-1-rui.zhang@intel.com> <08aee7fe-eddc-7841-2539-16ae43fd8d66@linaro.org> <016dc073-c9a3-4b96-6c58-7b21e0f998a5@linaro.org> In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 29 Mar 2023 18:03:26 +0200 Message-ID: Subject: Re: [PATCH -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Zhang Rui , linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 29, 2023 at 5:59 PM Daniel Lezcano wrote: > > On 29/03/2023 16:38, Rafael J. Wysocki wrote: > > On Wed, Mar 29, 2023 at 4:16 PM Daniel Lezcano > > wrote: > >> > >> On 29/03/2023 14:06, Rafael J. Wysocki wrote: > >>> On Wed, Mar 29, 2023 at 11:57 AM Daniel Lezcano > >>> wrote: > >>>> > >>>> On 29/03/2023 11:00, Zhang Rui wrote: > >>>>> When the hwmon device node of a thermal zone device is not found, > >>>>> using hwmon->device causes a kernel NULL pointer dereference. > >>>>> > >>>>> Reported-by: Preble Adam C > >>>>> Signed-off-by: Zhang Rui > >>>>> --- > >>>>> Fixes: dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field") > >>>>> dec07d399cc8 is a commit in the linux-next branch of linux-pm repo. > >>>>> I'm not sure if the Fix tag applies to such commit or not. > >>>> > >>>> Actually it reverts the work done to encapsulate the thermal zone device > >>>> structure. > >>> > >>> So maybe instead of the wholesale switch to using "driver-specific" > >>> device pointers for printing messages, something like > >>> thermal_zone_debug/info/warn/error() taking a thermal zone pointer as > >>> the first argument can be defined? > >>> > >>> At least this particular bug could be avoided this way. > >> > >> Actually we previously said the thermal_hwmon can be considered as part > >> of the thermal core code, so we can keep using tz->device. > >> > >> I'll drop this change from the series. > > > > But it's there in my thermal branch already. > > > > Do you want to revert the thermal_hwmon.c part of commit dec07d399cc8? > > Oh, right. Fair enough. > > I think Rui's patch is fine then. I guess you mean the $subject one, that is: https://patchwork.kernel.org/project/linux-pm/patch/20230329090055.7537-1-rui.zhang@intel.com What about the message printed when temp is NULL. Should the original form of it be restored too? > >> On the other side, adding more thermal_zone_debug/info.. gives > >> opportunities to external components of the core thermal framework to > >> write thermal zone device related message. I'm not sure that is a good > >> thing, each writer should stay in its namespace, no ? > > > > IMV whoever is allowed to use a thermal zone pointer should also be > > allowed to print messages related to its use, especially debug ones. > > > > "Encapsulation" means that the members of a thermal zone device object > > should not be accessed directly by its users other than the core, not > > that it cannot be used as a message tag. > > Actually it is not about the encapsulation but the namespace of the > messages. If a driver has an issue, IMO it is better it uses the device > related messages and let thermal zone messages to be related to what is > happening in the thermal framework, not in the back end. > > > > -- > Linaro.org │ Open source software for ARM SoCs > > Follow Linaro: Facebook | > Twitter | > Blog >