From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 641C2C27C55 for ; Mon, 10 Jun 2024 13:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J3zRsYu+zu5ebKAMg0YVGkeUo47dIZ7h6cPbooCu6Mw=; b=HI+6kVm6SinTqk avPTh9vco7rEIvgZwC4Vn2/noYqOoH9wbrt04MXCdJdREMtHwN8nJflP5f5tKJBuCqBKQPljUFFWo rM01Yi3qJWhmzaRfF2Nn1vN+ZTZQBoknwBPUgwISeXaHyY+bj0jiP9fwcU9UkV78MKW+ZSrUcvDv9 ryR8QqGO49C/fltXateLH7fotXP3Hd3YlKiGzfyDF/VkCMLJ6r2I2Qm9XbQuru1e8yziKSZnmPBle YgfTHqb4C8BI7LxEioXTcgxisdFlpKzNajXWJXxd+eHajb3tp4EOLMNbocYnbeyVY13eOpLmGEdDU ItRUPZd02anXjEApg1+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGfHR-00000005CxA-0NPe; Mon, 10 Jun 2024 13:41:49 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGfHO-00000005Cvc-35G0 for linux-arm-kernel@lists.infradead.org; Mon, 10 Jun 2024 13:41:48 +0000 X-UUID: 2aed78f0272f11efba8bfb22b0451c12-20240610 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=VQGZ1zUp5zV8bRtMR4KUV+3pZEPO+/wvOdVlhuvTtRE=; b=dvG3r7o995lrPyz1k85Aa1K5MWfHzVR00zD8kxEdes1ntKzgIR5CxijoR/bpAheAJ2lZpbbgO5BgeWI/8ad9n1I2XL5jZlqN/FotckxhJfOb7vdcx8Ok3SXXlGI/W/2mZESlBvEZppRhqLNrvHqbf7dvlevKnZdr8qJxoALZunA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.39,REQID:f4393fb3-edf2-4e84-bfc9-8ed4122cdf4f,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:393d96e,CLOUDID:e33e6988-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 2aed78f0272f11efba8bfb22b0451c12-20240610 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 109792585; Mon, 10 Jun 2024 06:41:40 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 10 Jun 2024 21:31:38 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 10 Jun 2024 21:31:37 +0800 From: Phil Chang To: CC: , , , , , , , , Subject: [PATCH v3] hrtimer: check hrtimer with a NULL function Date: Mon, 10 Jun 2024 21:31:36 +0800 Message-ID: <20240610133136.327-1-phil.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <87bk496seb.fsf@somnus> References: <87bk496seb.fsf@somnus> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240610_064146_789420_BB90B286 X-CRM114-Status: GOOD ( 11.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To prevent improper usage of hrtimers and avoid potential kernel crashes, this commit introduces a validation check for hrtimers with a valid function callback, discard the hrtimers that have a NULL callback. The `run_hrtimer` executes callbacks for every hrtimer, and these callbacks must not be NULL. A NULL callback can lead to a kernel crash. This update ensures that all hrtimers have properly initialized callbacks before execution. Signed-off-by: Phil Chang --- kernel/time/hrtimer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 492c14aac642..b8ee320208d4 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1285,6 +1285,8 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, struct hrtimer_clock_base *base; unsigned long flags; + if (WARN_ON_ONCE(!timer->function)) + return; /* * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel