Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp833596rwl; Wed, 29 Mar 2023 09:03:21 -0700 (PDT) X-Google-Smtp-Source: AKy350asiIjO7PByZaNT/JGAwsoIsbARxasmAK0AIZTpEtNAc3oQ5Wb42jq24zzUWcQv2fCxGfwn X-Received: by 2002:a17:907:7d8b:b0:93f:82cb:fe42 with SMTP id oz11-20020a1709077d8b00b0093f82cbfe42mr17674064ejc.58.1680105801222; Wed, 29 Mar 2023 09:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680105801; cv=none; d=google.com; s=arc-20160816; b=VJGiImEf8ZILniKXHJPb8AWtwpE+O4vO0j/LvRVCPaBTBEMvDUzvv5Zj4AZI62emAq N+JJLi+Ms62RHhCfzbmYD7NYExmJrtttr+aUmh0exgv/ty5b+UG9Km8EAO5Qf7IRh8t3 jT7QrYg/1qYHufHiGXRDCjmTACF0D02odch3oQxDTORuEqIOzswVfavBQaSZXDQ1RHs5 THe6hShFV3G2TNcjyReOlQKY92WaDKyvKsvKKsRxnPLj1bIc97C5QiYiNTsb50tdL//H SUJyu+rBltg7uwigi0rQdhbLSQmEablNeBsZCamM/R84mdVwGMMYrqbHMENKQtQpanf7 qddw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=zBJkXabIUFXjdoz3ymumlCy03vftbPDEKeNtnyEkrz8=; b=u8P9CYn48rX5ylIjSl3HUfkswWZPnWjae7LtHf3GyPYMctlHgDuZvsRioj3Qs9bcY7 bFYFEo0zYyI7lixFIw/Z4nXpImMBGALkJT4gRVjMySYUAX/QB+fqAFZtXA+M0on/j1Dr g+iY69TqKd/KokVw4RVw87wnLoQie3YvfEKJhH7hKX6mUYsknD/87U8Jg36lrRAJy2Ia NCFzov19f2mq54see/IORbmkYS1xWFfrRSoWX5TEtGF5NezFyvyriebDYNGsZYP1Fhmf qOj/PnwvI6NkmzgXm+g8tchL3asq60MPeESaIpxZeSJzt5zlWDtryOCQ0kj99KlkCzkP JvlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YdpfQk27; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a17090686c700b008b17e1a54edsi12391514ejy.788.2023.03.29.09.02.54; Wed, 29 Mar 2023 09:03:21 -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; dkim=pass header.i=@linaro.org header.s=google header.b=YdpfQk27; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbjC2QAj (ORCPT + 99 others); Wed, 29 Mar 2023 12:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231638AbjC2P74 (ORCPT ); Wed, 29 Mar 2023 11:59:56 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D74FE59EB for ; Wed, 29 Mar 2023 08:59:29 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id v1so16288026wrv.1 for ; Wed, 29 Mar 2023 08:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680105565; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zBJkXabIUFXjdoz3ymumlCy03vftbPDEKeNtnyEkrz8=; b=YdpfQk27kKNVYmWdxp/LTVIpL9/Vlb9z8P04OSPiTEBLZiAg8hINsKbJvWjGMQu38+ VsF5S6kmYNBG8R3BlrvDWxdd60oHj8KvJ8AtLzOyVpUUPEkp/aqmKIZwITpd9UnZ9hgg tVJLyE2hbIYhPCFHpmFpwBfY/wibcSVGXRPa1fFWkF/SQ68kNXFv2W5TbzGE3Y8w1wA9 SKEbKkEptThZMsDVhs7KhfSUnZRwpncmEfxBv+YdKPsNnS65c/BtNfRHLuxL0TlY1LFg 9TBqqaVm6LyF8vju9vovFEAZELJVSX9FSL6gAn+pIxeag4Zuis4kiwDebgdTkhfx6oqw URSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680105565; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zBJkXabIUFXjdoz3ymumlCy03vftbPDEKeNtnyEkrz8=; b=5WhSwlwEolZpBVA8irFwGO5sAP5JQCqYgWsTVIkOetrLxRlnvUfnE4LNK6gz+In7yl nkcKgYieAJ/Nhge07FD2Hv9qTqX2LPNBxf8LABNyi51qSduvoKObiXOmJUkv2XCj8+9w zcs+Mg75F6/q/oZeoJ8dNJmF/ZEKinA6AyVuG83pvXzbXft88DaZNDgDOKRFRGtuMNs2 wxP9F/Ex5ZnstPRbEf8x60ulRO2jHjqucMSTjOJhJTn7P/c/0SIpzNXjyMYiCtqNHjFM MizE+NxYeae8/tNQCz9QefoBKRVVe7lXh75IKvJIORvnHHXACxQmyxNYSNcmCTBfgbLN q42g== X-Gm-Message-State: AAQBX9fDFUj46SiZfO3Q4buisWR35Klzn2S2xLT/kTtHnCD2jV787qVE qWNrEPqK2ppG/d8AH0QvnLptxg== X-Received: by 2002:adf:db4b:0:b0:2d9:eb77:90d2 with SMTP id f11-20020adfdb4b000000b002d9eb7790d2mr14716100wrj.70.1680105565439; Wed, 29 Mar 2023 08:59:25 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:7c0e:2838:74e9:d05? ([2a05:6e02:1041:c10:7c0e:2838:74e9:d05]) by smtp.googlemail.com with ESMTPSA id q1-20020a5d61c1000000b002e463bd49e3sm506904wrv.66.2023.03.29.08.59.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 08:59:25 -0700 (PDT) Message-ID: Date: Wed, 29 Mar 2023 17:59:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference Content-Language: en-US To: "Rafael J. Wysocki" Cc: Zhang Rui , linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org References: <20230329090055.7537-1-rui.zhang@intel.com> <08aee7fe-eddc-7841-2539-16ae43fd8d66@linaro.org> <016dc073-c9a3-4b96-6c58-7b21e0f998a5@linaro.org> From: Daniel Lezcano In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 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. >> 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