Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3210976pxb; Fri, 5 Nov 2021 11:36:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDlz8dmauzAwqb6/9oEnZ5RVeM8hyKVQwmx1MBN8NeUVG0b9r4rjQos4OBvldzA0ic4+yl X-Received: by 2002:a92:c983:: with SMTP id y3mr40149872iln.24.1636137400859; Fri, 05 Nov 2021 11:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636137400; cv=none; d=google.com; s=arc-20160816; b=dQVNUfWiO5JBb7a31sj41zo2+1SsI1r0mJPprK4Ai16PNKtseFn7kGwzF69JufjoVw 1sEmjVcmGmYgQ9D6TkxFBrOWPXBcV7/CQXTb1unm6lPQnQaQxBEGZuvvfNOWQLLMpbMe WKPlW0wPLcZJREnSZ+t8Xfw/2ZXWr6MucV3fILTFTY2ecaKWcIXrFRnDCUdKkwJwA2Qa UN0NnE5ykC1Dbo96HtMYyVlepNe7LH0+0F1NeF3V2ipapZ6xYEGRQDCkaSIIWQlIP/nn 2M7mKgNqyvs1z7DlEy9KL/PBjD6uPLW/SM/o3ybi8a/8ZLf3rjpYsceeMN7MU3NuFOl5 1MgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=P1Gp0/MAdFAvXBeRj35bImIZhx/EFHupa8h4iwZFEeg=; b=bCi2w8NOOS1e1gI0IomHbMJvzk4bUn+aEWQRY9tnfkQt77dPZFsNm8NMxn9Z/m6XqP WLypZHI8Uw/cGylysKz7bE7W60XQnr1K+BBjLE8Xy8E2hfwLPTFj0YBvL9YawZGalbB6 dBlC4A/A6lNiGiwa3THo24nnl32qxpQDDiSLlK7wrfhuTaIpNe+LtOsEZ7wqscn6bfmJ kMEnAus/v8jg0cTTuClnW5yZFZsrjzv8S6YwjbmEGBTgx8Er7+MEF8TGg9jPKKQx/U+H k3V5Q3vXLlfadxUWRrqUI49+MZWGYvARwVXi/qDEoW9Vfj2rA0Wd2sqXvvkE0XST46Wh eJkQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si15771720ilu.91.2021.11.05.11.36.28; Fri, 05 Nov 2021 11:36:40 -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; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233785AbhKEQkZ (ORCPT + 99 others); Fri, 5 Nov 2021 12:40:25 -0400 Received: from mail-oo1-f41.google.com ([209.85.161.41]:36746 "EHLO mail-oo1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233382AbhKEQkY (ORCPT ); Fri, 5 Nov 2021 12:40:24 -0400 Received: by mail-oo1-f41.google.com with SMTP id t7-20020a4aadc7000000b002b8733ab498so3210118oon.3; Fri, 05 Nov 2021 09:37:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=P1Gp0/MAdFAvXBeRj35bImIZhx/EFHupa8h4iwZFEeg=; b=WNo4yOW/fr/VGFaAidZB97Q23JxqT7NeepXrOaVTku/HvdmPrMiaOmLTdZxDJotuib VPbrpWGa4ty44MmyRPL3hxCCqyO+ZNKGVLcVOih06WdGHB3k2mFvruiftY7dKtclarjo fpzIZKDf9UU37J/oHtZ7KpR9ZbxK3r/C85UZzLSpmm4bclOE2dy3ABQMjl28tdqAPXY0 9DXiOezPsLlGDPYIyJkgX0/dlTR7c22Sp4ngZClY4/vX2YGhj9InyyQ8/o+Ygrjd+Hh0 itDowhTH0zaUC77qSSTjSN6WVs72j7gVvrX1TbYCUZ44FwP3jv6DovCd/TSol2VGuyst Yeuw== X-Gm-Message-State: AOAM53378VE8s8aP3cFUYFKWYyrk79zfQ13jpCjLHgvhzFPnMCeXnlx1 zFymDF7/14NdMNC2AYusCI88KcqtImcP9oSpzKQ= X-Received: by 2002:a4a:e544:: with SMTP id s4mr9557867oot.0.1636130264293; Fri, 05 Nov 2021 09:37:44 -0700 (PDT) MIME-Version: 1.0 References: <1636070227-15909-1-git-send-email-quic_subbaram@quicinc.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 5 Nov 2021 17:37:33 +0100 Message-ID: Subject: Re: [RESEND PATCH v2] thermal: Fix a NULL pointer dereference To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Subbaraman Narayanamurthy , Amit Kucheria , Zhang Rui , Nick Desaulniers , Linux PM , Linux Kernel Mailing List , David Collins , Manaf Meethalavalappu Pallikunhi , Stable Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 5, 2021 at 5:19 PM Daniel Lezcano wrote: > > On 05/11/2021 16:14, Rafael J. Wysocki wrote: > > On Fri, Nov 5, 2021 at 12:57 AM Subbaraman Narayanamurthy > > wrote: > >> > >> of_parse_thermal_zones() parses the thermal-zones node and registers a > >> thermal_zone device for each subnode. However, if a thermal zone is > >> consuming a thermal sensor and that thermal sensor device hasn't probed > >> yet, an attempt to set trip_point_*_temp for that thermal zone device > >> can cause a NULL pointer dereference. Fix it. > >> > >> console:/sys/class/thermal/thermal_zone87 # echo 120000 > trip_point_0_temp > >> ... > >> Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020 > >> ... > >> Call trace: > >> of_thermal_set_trip_temp+0x40/0xc4 > >> trip_point_temp_store+0xc0/0x1dc > >> dev_attr_store+0x38/0x88 > >> sysfs_kf_write+0x64/0xc0 > >> kernfs_fop_write_iter+0x108/0x1d0 > >> vfs_write+0x2f4/0x368 > >> ksys_write+0x7c/0xec > >> __arm64_sys_write+0x20/0x30 > >> el0_svc_common.llvm.7279915941325364641+0xbc/0x1bc > >> do_el0_svc+0x28/0xa0 > >> el0_svc+0x14/0x24 > >> el0_sync_handler+0x88/0xec > >> el0_sync+0x1c0/0x200 > >> > >> While at it, fix the possible NULL pointer dereference in other > >> functions as well: of_thermal_get_temp(), of_thermal_set_emul_temp(), > >> of_thermal_get_trend(). > > > > Can the subject be more specific, please? > > > > The issue appears to be limited to the of_thermal_ family of > > functions, but the subject doesn't reflect that at all. > > > >> Suggested-by: David Collins > >> Signed-off-by: Subbaraman Narayanamurthy > > > > Daniel, any concerns regarding the code changes below? > > I've a concern about the root cause but I did not have time to > investigate how to fix it nicely. > > thermal_of is responsible of introducing itself between the thermal core > code and the backend. So it defines the ops which in turn call the > sensor ops leading us to this problem. > > So, without a better solution, this fix can be applied until we rethink > the thermal_of approach. > > Acked-by: Daniel Lezcano Thanks! I've queued it up for 5.16-rc as "thermal: Fix NULL pointer dereferences in of_thermal_ functions".