From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796283827; b=4YIGPFyoVA2OJ4ima+DSgUxFasUFnY/GQ+dMy/z4Kcxo+4sGAMHC2XbzhCQwEn4lt3fz zTUc4aOwv14VVXGWxKAfE66XbPUUQzmO+3kx4NExardnv8dZrbgwzZVQPn64Ax5Ri+32p KRTktquMEJe5uwYpJausDVkpCSPxPb4/uCaUn/Xw+4Aa/qyRV/qE7QEK6eZ3tlnk4u3Xi l+C9qfargxINqgD93Cb3ul9tP884adAFR9/kqdK27e3XQcn+ooPV4o8gQFfVD5HWErmto y8zSX92toV65jg6/5iIDEWDanG1FYTbDEh3zZ4SH1Lqb/Kj/Fyn0145F2WcQmTePHaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283827; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=asQSmDyL/WXgj4m7nS6if/TVgMbGix/J6CiBN1OwQe0=; b=Mu//BQRLojhtshGLQdrdrSbmoODi8r/RGJm3DNp8f6LJN28pwBAXHG4eChaDVxlyGAcy FWD6HHR9eXE3w4QI5k6s6K1z68SSsQ2kD6PZgosn9cdHPsiDkGvIn4z3ihLBdPf0UMwRP YKaz2RjVgwTaICGHSiUZfg2fdG8xZ+1CxHNHIDMU6v/tNCoLHFsJWYugV0Q1USONYjAA+ OEnRutOb4P4U6evX/HadMeqhknDtiIlKeM5pys0XttCK0djFp5X/FNzXiqEOIqp4UgOCY P9s0zAvRQEZ11S5xTY1JiGpTpn041T7tVM7z5pRAY2O2p7VjH6/qFU6bodjLqbCXXcg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=od6OhtG5; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E84BD606A32C for ; Thu, 3 Dec 2026 07:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=od6OhtG5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 518E31F000C1; Thu, 3 Dec 2026 07:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796283826; bh=asQSmDyL/WXgj4m7nS6if/TVgMbGix/J6CiBN1OwQe0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=od6OhtG5vWVIKpndS2Py1jq+PcErRAfg2e+4Ghgowa3ATYZbtAttcB7NacHepQqYN tkjqfRxZL37U5u5QEkJvC5vfqxh+3psSZVmBdCkZ0BWgClSaay3zeTZOeXCPnE2OuL 0QYQ8qguSbK//SZCL3En2LwQe2VgPCfg64LaJQDOxMBU2HNL67l/djCswyXliyqlhL RNSX1iBr1iemEa1eSF2wrV95lBYAPvB0qYIqB37whZRq9kHecZFq1KIM8eWHoJ/lEa kfHpZOH2CC0Y3xKYTjDXDhtBKsyS0fcta1gwcXlzm2aNuzL4pBHYGxgMlxdAd5Bqsy PYZ2kYhEsPZpg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] perf/core: Check for a NULL cpc before cancelling its hrtimer Reply-To: sashiko-reviews@lists.linux.dev To: "Hang Zhengyang" Cc: linux-perf-users@vger.kernel.org In-Reply-To: <20261203073728.2470032-1-hang.zhengyang1010@gmail.com> References: <20261203073728.2470032-1-hang.zhengyang1010@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:43:45 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > perf_pmu_register() allocates the per-CPU contexts one CPU at a time. > When one of these allocations fails, it returns -ENOMEM and > perf_pmu_free() runs with NULL entries for the CPUs that are not > allocated yet. The loop in perf_pmu_free() skips those entries, but > commit 35fbc5a85891 ("perf/core: Cancel hrtimer on > perf_pmu_unregister()") put the hrtimer_cancel() before the NULL check. > Such a failure then oopses instead of returning -ENOMEM: >=20 > KASAN: null-ptr-deref in range [0x0000000000000108-0x000000000000010f] > RIP: 0010:hrtimer_active+0xc1/0x350 > Call Trace: > hrtimer_cancel+0x15/0x40 > perf_pmu_free+0x1cd/0x320 > perf_pmu_register+0x4e1/0xb40 >=20 > The allocations are small GFP_KERNEL ones, so this needs fault injection > or a registering task that the OOM killer has picked. Found with failslab > fault injection on the allocations in perf_pmu_register(). >=20 > Cancel the hrtimer after the NULL check. >=20 > Fixes: 35fbc5a85891 ("perf/core: Cancel hrtimer on perf_pmu_unregister()") > Cc: stable@vger.kernel.org > Signed-off-by: Hang Zhengyang Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203073728.2470= 032-1-hang.zhengyang1010@gmail.com?part=3D1