From nobody Tue Sep 9 16:18:37 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57A44315D25 for ; Sat, 6 Sep 2025 22:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; cv=none; b=s56hQbbccDnThDqwQOKW92Ku5Jdzcv5zY1GlGp8dCBIYGWdhqKJmK6RicqTvJvbojC4uVOZ5lKB3GT0GMeqceSFcwpEuk+BsC4P+R02j7veTlOFwLYPIIQx0SC2mLR0lGegzB2uC+QYR88q+J+zO/M6A3HAVIRZvvfSEoZT31CE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; c=relaxed/simple; bh=GZ+SRovi3TbpnskH+xH5IP4NZZBwjh/8aZAcAf6WFSs=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=oLvAxdWIRoNIoLZy8AOI/D6g6e2VnaJezuq75+d6pRpLez7TGzM7So7FvYu0K69WNd4SwF42lmbSS72p9Bn+Dj5WO+9aMqFUwWDr6vx1Zvd4wvcfWxrGRe5quTd29yO9MCCH1HzFR5QuYruATTTnPtDMB/BFB0u4gL+PXsg1R/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Svm3i5FN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Svm3i5FN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E52D3C4CEE7; Sat, 6 Sep 2025 22:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757197051; bh=GZ+SRovi3TbpnskH+xH5IP4NZZBwjh/8aZAcAf6WFSs=; h=Date:From:To:Cc:Subject:References:From; b=Svm3i5FNpmcw3VIF3ot8F7wsJFTUI8qtsmZBm0bSGM5BejFgikE32OVdUK9WuLIyv 8uRVkNO6MAQXrzwfpI1mYGmSm+hrxrk/1TTkjfsHOnrNFfSmQ18t2Rkd8y5dq9wLau hhroAqwaWbNgGAKFtF81fDlHlatzzI4ece14Fs8C7JvWR47zJS4loSox27Bz9zwIRr gxol6jHQxVzV74qDWX/jJICEbJkYIS2zo66aXnePFtv1HWL37dWDexX3MFvufJ0Vt8 12gyFjoujYE/se8FouUTg/Q+zw5xa0Bq+X/9owWThb8eQ/8PfpmA2vqUmFZNXJ3trR n3MylbJ6sfWwQ== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1uv1Ea-00000006UhB-2gz3; Sat, 06 Sep 2025 18:18:12 -0400 Message-ID: <20250906221812.496673112@kernel.org> User-Agent: quilt/0.68 Date: Sat, 06 Sep 2025 18:17:52 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Qianfeng Rong Subject: [for-linus][PATCH 1/5] trace: Remove redundant __GFP_NOWARN References: <20250906221751.054623340@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Qianfeng Rong Commit 16f5dfbc851b ("gfp: include __GFP_NOWARN in GFP_NOWAIT") made GFP_NOWAIT implicitly include __GFP_NOWARN. Therefore, explicit __GFP_NOWARN combined with GFP_NOWAIT (e.g., `GFP_NOWAIT | __GFP_NOWARN`) is now redundant. Let's clean up these redundant flags across subsystems. No functional changes. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250805023630.335719-1-rongqianfeng@vivo.com Signed-off-by: Qianfeng Rong Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_u= ser.c index af42aaa3d172..2ab283fd3032 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -496,7 +496,7 @@ static bool user_event_enabler_queue_fault(struct user_= event_mm *mm, { struct user_event_enabler_fault *fault; =20 - fault =3D kmem_cache_zalloc(fault_cache, GFP_NOWAIT | __GFP_NOWARN); + fault =3D kmem_cache_zalloc(fault_cache, GFP_NOWAIT); =20 if (!fault) return false; --=20 2.50.1 From nobody Tue Sep 9 16:18:37 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69E2B2C15AF for ; Sat, 6 Sep 2025 22:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; cv=none; b=E6mRvEVuJXf9MKqaD3pHSP2XFKpGen3k2mcCWttMQ219evuuhNSHOpu6XBOqrH2Vb2FRtmxGacM2lX5iA7GPJrWUKmJ4+2LgqzjHAr0JKG3NGtk63kSnCI2AF/E/NfNY9cfj9NnMlT4Oa9Wo99WUylpMHYckDM2OQJMqSI+x4FY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; c=relaxed/simple; bh=jhgoq70j6joLqIm6PtVIcNMuSzY6X/5MBWdp1IUUcvI=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=AEA52cdrfuCF2RviAs54E1T31qB6nwwlsA1T13mxZLkyJ0m2P018AcPPwLW2kfA7jHHEKEYxqI+JHYjRQx426l28dpI4LXJNTl+t6n/nzSQVVJsj0DiQ66DRrcgpdp8l/3s/QzacNU3mpj0E7C67utd49PaJPoV9GtTlkmvnWnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iQRYWLzf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iQRYWLzf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB232C4CEF8; Sat, 6 Sep 2025 22:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757197051; bh=jhgoq70j6joLqIm6PtVIcNMuSzY6X/5MBWdp1IUUcvI=; h=Date:From:To:Cc:Subject:References:From; b=iQRYWLzfReKn7HOchhyYgRroRFxFMZdPpaxzDPLHC5W5DO+kIeD881iYOacbGhqnO Qf/4UjYEVVGMSQ7TRUh5zMZ9Kk4vyIG8FC+8VHz1+SQANPbfhxyuHvWNbaEhCL6gco K2jFv+XoamrWRcebZBI6Kw9sANzLv0gYGiHQ4U2BpgAbECWa49gP+pJKtlD8pablH7 CxXBfDGKubCiMfTiHsPzIg/Vn8oh94GzZAC0c1LtKWaCB4tbFSzRXlcYJECYesLrru biggGpdZgnqsglH2jxjayEKdqzyrQu1L4IEigd4MuO7LQOGz38uwpLKRk1bUKWISFq /Nw0HwLr032mA== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1uv1Ea-00000006Uhh-3Neq; Sat, 06 Sep 2025 18:18:12 -0400 Message-ID: <20250906221812.662279697@kernel.org> User-Agent: quilt/0.68 Date: Sat, 06 Sep 2025 18:17:53 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Luo Gengkun Subject: [for-linus][PATCH 2/5] tracing: Fix tracing_marker may trigger page fault during preempt_disable References: <20250906221751.054623340@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Luo Gengkun Both tracing_mark_write and tracing_mark_raw_write call __copy_from_user_inatomic during preempt_disable. But in some case, __copy_from_user_inatomic may trigger page fault, and will call schedule() subtly. And if a task is migrated to other cpu, the following warning will be trigger: if (RB_WARN_ON(cpu_buffer, !local_read(&cpu_buffer->committing))) An example can illustrate this issue: process flow CPU Reviewed-by: Masami Hiramatsu (Google) --------------------------------------------------------------------- tracing_mark_raw_write(): cpu:0 ... ring_buffer_lock_reserve(): cpu:0 ... cpu =3D raw_smp_processor_id() cpu:0 cpu_buffer =3D buffer->buffers[cpu] cpu:0 ... ... __copy_from_user_inatomic(): cpu:0 ... # page fault do_mem_abort(): cpu:0 ... # Call schedule schedule() cpu:0 ... # the task schedule to cpu1 __buffer_unlock_commit(): cpu:1 ... ring_buffer_unlock_commit(): cpu:1 ... cpu =3D raw_smp_processor_id() cpu:1 cpu_buffer =3D buffer->buffers[cpu] cpu:1 As shown above, the process will acquire cpuid twice and the return values are not the same. To fix this problem using copy_from_user_nofault instead of __copy_from_user_inatomic, as the former performs 'access_ok' before copying. Link: https://lore.kernel.org/20250819105152.2766363-1-luogengkun@huaweiclo= ud.com Fixes: 656c7f0d2d2b ("tracing: Replace kmap with copy_from_user() in trace_= marker writing") Signed-off-by: Luo Gengkun Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 1b7db732c0b1..2f1ae6c0ee81 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -7209,7 +7209,7 @@ static ssize_t write_marker_to_buffer(struct trace_ar= ray *tr, const char __user entry =3D ring_buffer_event_data(event); entry->ip =3D ip; =20 - len =3D __copy_from_user_inatomic(&entry->buf, ubuf, cnt); + len =3D copy_from_user_nofault(&entry->buf, ubuf, cnt); if (len) { memcpy(&entry->buf, FAULTED_STR, FAULTED_SIZE); cnt =3D FAULTED_SIZE; @@ -7306,7 +7306,7 @@ static ssize_t write_raw_marker_to_buffer(struct trac= e_array *tr, =20 entry =3D ring_buffer_event_data(event); =20 - len =3D __copy_from_user_inatomic(&entry->id, ubuf, cnt); + len =3D copy_from_user_nofault(&entry->id, ubuf, cnt); if (len) { entry->id =3D -1; memcpy(&entry->buf, FAULTED_STR, FAULTED_SIZE); --=20 2.50.1 From nobody Tue Sep 9 16:18:37 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69E982C3278 for ; Sat, 6 Sep 2025 22:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; cv=none; b=lasSZye2gm0dKb9z/8B5h7FlhWGl2uGjhDdYr7NHlccR3Wpg4kU73sxl3de4l3J9epzLEr7AhDe/fkkPoN3/UEoCly5wfvtmlq3W/ZGjhXJi8NEMn//halAU4fE6Cnq1QLfV1mpi4U3xLOY9Z/Mp5t91/YbWkvvxhhDAJNe8bMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; c=relaxed/simple; bh=uxyBJmKu5Z7jyOGwW7QMY4WrNpM+wcyW7pVuNd8Nsqo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Qdwpe0Drg3anTTGjXZQBoEFiwNChuTSQw18rjkJkk4fQiRA8GoZvPStuHKogSmVUr5bVqAKS+o9HkIflYPyCTGBowxFAvY1eqgvZSCQTDwBNonxX2QN0GIhdt0ti3YI15S2fBlRZBj4Y7ySx/SlNxXrRhky8v9SDsl6iM65CLjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Frc1MNwO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Frc1MNwO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F889C4CEFC; Sat, 6 Sep 2025 22:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757197051; bh=uxyBJmKu5Z7jyOGwW7QMY4WrNpM+wcyW7pVuNd8Nsqo=; h=Date:From:To:Cc:Subject:References:From; b=Frc1MNwOJTl7CDjhisJjkK+FfC7FCc0rssYMgnZ2kgVZYST6dzqQqRQYyU7Otk3kv 31wUE7RkxMip1M6dzsc4dSxBDdDaNmyiOEcXXTkqD7hkKMDFFI0iZxjqhswBTKi9Vm HjpBRA/6/n5l7Y3lXc9/iJQkPkmXYrJRS++peTmz5swUNQrRDOG95uppfV+Mqnen1j Mk9QvA428O7PhWA06Akfao03Qt1pIhvRM1tInNf7fosdM0j4vRAY8Lr6T4H6YML9gz zBdT7BoVH0dE4tA+4V2m44X/aN7pG/whMekHvkfbn4Gtewa/utUEtxx93gwj90yyd3 57sYgKn94nUXw== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1uv1Ea-00000006UiB-44IT; Sat, 06 Sep 2025 18:18:12 -0400 Message-ID: <20250906221812.826443565@kernel.org> User-Agent: quilt/0.68 Date: Sat, 06 Sep 2025 18:17:54 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vladimir Riabchun Subject: [for-linus][PATCH 3/5] ftrace/samples: Fix function size computation References: <20250906221751.054623340@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Riabchun In my_tramp1 function .size directive was placed above ASM_RET instruction, leading to a wrong function size. Link: https://lore.kernel.org/aK3d7vxNcO52kEmg@vova-pc Fixes: 9d907f1ae80b ("samples/ftrace: Fix asm function ELF annotations") Signed-off-by: Vladimir Riabchun Signed-off-by: Steven Rostedt (Google) --- samples/ftrace/ftrace-direct-modify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ftrace/ftrace-direct-modify.c b/samples/ftrace/ftrace-= direct-modify.c index cfea7a38befb..da3a9f2091f5 100644 --- a/samples/ftrace/ftrace-direct-modify.c +++ b/samples/ftrace/ftrace-direct-modify.c @@ -75,8 +75,8 @@ asm ( CALL_DEPTH_ACCOUNT " call my_direct_func1\n" " leave\n" -" .size my_tramp1, .-my_tramp1\n" ASM_RET +" .size my_tramp1, .-my_tramp1\n" =20 " .type my_tramp2, @function\n" " .globl my_tramp2\n" --=20 2.50.1 From nobody Tue Sep 9 16:18:37 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 960172D7387 for ; Sat, 6 Sep 2025 22:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; cv=none; b=tJ7TY10ClRunZMNHw080PgaUPSqtm85Q/OtWxTRZt+E7Bs7M9QdPFUhpY1UKoiKQpBQ/T+X63/gqn4SbxheSvFIJbJ/cko8Mge9H2i2Hzl5cGJx8ozlghK+5QKk8nb5XnA2Ev70Pmxf/g+Ze/M5+Xf5rcIfMO0lJp+v6Rf/O9GA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; c=relaxed/simple; bh=kCxjaRhQrulgH7THzNL87X3yTbI95vE/7f4gxrgb9pg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=o6rJWMZ9PDHczEFkywM130hVg8hpknapqgDUDzkfSt1HXx4kXfKs6roqMjmgod6aJ+j1eN6toE8Obu5cV2LXVecOTrNoaA/66mXegytr6iuzIHKTMvl+DyRmzw+XwY5JVETQbkjXrfD939LiuEzObo+95KEFL9zg6aH9HE9Ps+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sZpFh4+e; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sZpFh4+e" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B7EEC4CEFE; Sat, 6 Sep 2025 22:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757197051; bh=kCxjaRhQrulgH7THzNL87X3yTbI95vE/7f4gxrgb9pg=; h=Date:From:To:Cc:Subject:References:From; b=sZpFh4+elYlIttji3Nl6IEkM+YrxRAao/rAjbkmyMvsOhANwXM8WwgCu/wV8pZhyw G8cJugFP7vXsDpjFxKraFwZy0YqxS98IHGzYC9GxELiAcAW0LpG1cK93WrPqFJi+EW OkdY01DB9kHJP0w2glybniOITd1RQCAM9oMlkCVKP4Dz8IluNyeuj7uztBIOrkrSTr E4/qkGh3R/sXpMR1fNeVvpHs+qJXgdgtdUSTLrgjmJQWimrRvYZoc+y7fBvpkicF5A kGzflhaYZBW0cn4tfet1+nRY+CsuTxLpMAWuA1kdPQRhXH2jEi6m8xZ+pa0RM5XeG0 rrUTfcCMpdPuQ== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1uv1Eb-00000006Uif-0Zdw; Sat, 06 Sep 2025 18:18:13 -0400 Message-ID: <20250906221812.990978223@kernel.org> User-Agent: quilt/0.68 Date: Sat, 06 Sep 2025 18:17:55 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Ye Weihua , Guenter Roeck Subject: [for-linus][PATCH 4/5] trace/fgraph: Fix error handling References: <20250906221751.054623340@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guenter Roeck Commit edede7a6dcd7 ("trace/fgraph: Fix the warning caused by missing unregister notifier") added a call to unregister the PM notifier if register_ftrace_graph() failed. It does so unconditionally. However, the PM notifier is only registered with the first call to register_ftrace_graph(). If the first registration was successful and a subsequent registration failed, the notifier is now unregistered even if ftrace graphs are still registered. Fix the problem by only unregistering the PM notifier during error handling if there are no active fgraph registrations. Fixes: edede7a6dcd7 ("trace/fgraph: Fix the warning caused by missing unreg= ister notifier") Closes: https://lore.kernel.org/all/63b0ba5a-a928-438e-84f9-93028dd72e54@ro= eck-us.net/ Cc: Ye Weihua Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250906050618.2634078-1-linux@roeck-us.net Signed-off-by: Guenter Roeck Signed-off-by: Steven Rostedt (Google) --- kernel/trace/fgraph.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 2a42c1036ea8..1e3b32b1e82c 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -1397,7 +1397,8 @@ int register_ftrace_graph(struct fgraph_ops *gops) ftrace_graph_active--; gops->saved_func =3D NULL; fgraph_lru_release_index(i); - unregister_pm_notifier(&ftrace_suspend_notifier); + if (!ftrace_graph_active) + unregister_pm_notifier(&ftrace_suspend_notifier); } return ret; } --=20 2.50.1 From nobody Tue Sep 9 16:18:37 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDFE82D7DD5 for ; Sat, 6 Sep 2025 22:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; cv=none; b=YdtB8soS6kekxkAqPXNg6kM8kn6UcqR/zGl45lPpyQ7e07NVSlvkiN9lrpoaVpx6HHr9PfE4z435Z8lsZUqOyeoOuwvfSIvfY76xCNAYOpMvo14WhoQE+Qch3QlV8S6cNqv04lAHCIwFL85IwgQYp/vblkCbSCF+wQVh4A5ilW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757197051; c=relaxed/simple; bh=r4x5U9mBOCyJQpMNl8PcYf/G+baGUxDY9xHx07V6xVM=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=p6cFS61GbM7gwMIt7VBbYJJekDPeXaGHXB7P/Tw+6Q56WHll/ItiURsdzu7QVWc6UH+1EgOuArJ+Tss+/zpWLvWqTuBh8ubHJ2NRI5cC+k98VQcibYd7YNta9+mSkjwhbDvniKBFGK5xtf5d3tmHtIx94sFwkcsdPgq8Y8JYMeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s+u/DdSe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s+u/DdSe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65FB4C113D0; Sat, 6 Sep 2025 22:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757197051; bh=r4x5U9mBOCyJQpMNl8PcYf/G+baGUxDY9xHx07V6xVM=; h=Date:From:To:Cc:Subject:References:From; b=s+u/DdSesrSs+WrhDFQdR0/GjQVQKi27CoZ7UUcnFcwEGC+EvKSLV00ePWn3YlIya tUiF6lyXRWo7kCsbuDDGIZpHhgaty8tgC8h1PY2bXJoDMGv1hy36F6DhtOCNmLlBLG MtBWeP3JXURvXnmtZ1bdC3UlpFDkuG05QDrINdxG/OH0s8Msq11Qd53ePXqegXCnAP a3RGIq5NWSPfjJ0z0oZM/LA/++7IMIuNtYiS6WVAhzzq6xR61VnOYLzzj6tf0fn7vz BwLnDVCzTjFe8xs2zL75Ac4kzBXpRYd7fX68ihHWPhPb4lCOhsf4kSytmMnErdfaPl 3Pgf2oWWS1GsQ== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1uv1Eb-00000006Uj9-1H1i; Sat, 06 Sep 2025 18:18:13 -0400 Message-ID: <20250906221813.158065018@kernel.org> User-Agent: quilt/0.68 Date: Sat, 06 Sep 2025 18:17:56 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , , Wang Liang Subject: [for-linus][PATCH 5/5] tracing/osnoise: Fix null-ptr-deref in bitmap_parselist() References: <20250906221751.054623340@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Wang Liang A crash was observed with the following output: BUG: kernel NULL pointer dereference, address: 0000000000000010 Oops: Oops: 0000 [#1] SMP NOPTI CPU: 2 UID: 0 PID: 92 Comm: osnoise_cpus Not tainted 6.17.0-rc4-00201-gd69e= b204c255 #138 PREEMPT(voluntary) RIP: 0010:bitmap_parselist+0x53/0x3e0 Call Trace: osnoise_cpus_write+0x7a/0x190 vfs_write+0xf8/0x410 ? do_sys_openat2+0x88/0xd0 ksys_write+0x60/0xd0 do_syscall_64+0xa4/0x260 entry_SYSCALL_64_after_hwframe+0x77/0x7f This issue can be reproduced by below code: fd=3Dopen("/sys/kernel/debug/tracing/osnoise/cpus", O_WRONLY); write(fd, "0-2", 0); When user pass 'count=3D0' to osnoise_cpus_write(), kmalloc() will return ZERO_SIZE_PTR (16) and cpulist_parse() treat it as a normal value, which trigger the null pointer dereference. Add check for the parameter 'count'. Cc: Cc: Cc: Link: https://lore.kernel.org/20250906035610.3880282-1-wangliang74@huawei.c= om Fixes: 17f89102fe23 ("tracing/osnoise: Allow arbitrarily long CPU string") Signed-off-by: Wang Liang Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_osnoise.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index fd259da0aa64..337bc0eb5d71 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -2322,6 +2322,9 @@ osnoise_cpus_write(struct file *filp, const char __us= er *ubuf, size_t count, int running, err; char *buf __free(kfree) =3D NULL; =20 + if (count < 1) + return 0; + buf =3D kmalloc(count, GFP_KERNEL); if (!buf) return -ENOMEM; --=20 2.50.1