Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp727941rwl; Wed, 29 Mar 2023 07:44:35 -0700 (PDT) X-Google-Smtp-Source: AKy350Zgs+B0PCUxKmbJfPzNmuh+Sg/872NfQ3sQSPOWL62xoQAzT/wI/c6b5EZ0yuq4AUH3ViiN X-Received: by 2002:a62:52ce:0:b0:629:fae0:d96a with SMTP id g197-20020a6252ce000000b00629fae0d96amr2636410pfb.16.1680101075080; Wed, 29 Mar 2023 07:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680101075; cv=none; d=google.com; s=arc-20160816; b=q/PO2593rGe5MWhwNt787flnVDwe8/5PhdWqNvymZ0YDgxsiyIpE7DWxslUoNGHLER PULZIrJORN1/PX/6fDlEXh4scxul4mvWaPonUl3FYv2+09IlLLMb+aYa4O1EJFkbSbUe 3BMjDEHRkyCVy5JmKuffbNnPgS9EOMGrv/+1a15hAt+EoZMwvweQm3a3pWTopUXq61Px DFGrwqmmPVkbutjM0LUoTk/0af6FfjDXx1Pgz3u4iaNVeti5Rj1OvudJKBvpTfdyeVYb 9jWaez2mYMSiaD+v/JeT2A5XRNC5tMBN0P9AXe6bwamMIRS9EAO7+2eveZY28nViH8Jk 2Kfw== 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=vcnHFyyzObu1K4aU3fRPJ88ctwAAhuJXFFjFAJYt9rE=; b=i1h3YBRyLqyv6jMkS+7caZKWvw6qmei+vEopxcSHr66ggrApWmEUedVB6Hf9FkUjz8 yNyY1sNQGGgUdE4TsCeacmWYnEWBJfk3396R6che0p8usoiScCV15f2gw+9xX8ORruBP vWJqVH93z/tgeSOI4nqbPWvn1FwhhX4RfuJUNpcI0MY7Ot1evWUgKa4GbkD9ajCwGpfv 6Etlx5C61itPauYo8kxsqz38DxfVYgmXGe8z10xNhSVnq+9ypqnqJlHcyUcTzB09FdVL 5tlQl4VqCoZSDpTXXME5Id9+5HDTb6brbF6f46Uf6ECEFMd1pPLSo1PzAgeiFxfobllm 2y7w== 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 b37-20020a631b25000000b0050be2388723si32883649pgb.686.2023.03.29.07.44.22; Wed, 29 Mar 2023 07:44:35 -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 S229990AbjC2OmM convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Mar 2023 10:42:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbjC2Ols (ORCPT ); Wed, 29 Mar 2023 10:41:48 -0400 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93B1E4EC1; Wed, 29 Mar 2023 07:39:08 -0700 (PDT) Received: by mail-ed1-f45.google.com with SMTP id ew6so64215487edb.7; Wed, 29 Mar 2023 07:39:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680100747; 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=mNiF0TAEnjTwFsCRZZ5me++D62yLeN4frM4I1Vw9ZcM=; b=i85Qg4yXfOunE2MWtPAiJuMfi5zrjmDUiHo9+OgENCui5hZqe5CvGMw1eO2u6iljuY 3eCxEJRuTAUmoAdKXQHV1kJXd6tJslKr9K2w5SkrHhIVU0B0FS/JTgLR1grm0IOKSJCW kudMh+cPZUU195N5JIYQtqTFO2O2LTxNXO2wxZx6yZUj1C5MLrKQZtHgEpoxhowayGOi WGzL5fs/ddPHdecCWYlfMY99aB1DBlIEpm06i2zrn7Veyr1AZiXrhI5zFKjtQPKvRAu+ b+2frm56PcLmFYDm2gRtq/u/9w6EahdNYdYVIjpJBDH4jHQU91QJJZZivSUmEcfrsrI4 Q1NQ== X-Gm-Message-State: AAQBX9ecKDpJrIw57O7X8ZAUrbdpwPfVoqPPYUOsQRhy3zc72V0hnXIL LoVtsv29yOzZgDpL5ZIOdsJhE+uoQv7AfaOm66c= X-Received: by 2002:a50:cbc1:0:b0:4fb:e069:77ac with SMTP id l1-20020a50cbc1000000b004fbe06977acmr1547826edi.0.1680100746930; Wed, 29 Mar 2023 07:39:06 -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: <016dc073-c9a3-4b96-6c58-7b21e0f998a5@linaro.org> From: "Rafael J. Wysocki" Date: Wed, 29 Mar 2023 16:38:55 +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 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? > 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.