Skip to contentSkip to conversation

FAILED: patch "[PATCH] tracing: Fix ignored return value of" failed to apply to 6.18-stable tree

PATCH New [email protected] 2 participants 2 messages Oct 21 – Oct 22

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 3110d09bb98e3ac66482a7b257548a1683ec6c1a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026102126-obtuse-trimness-c3cc@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 3110d09bb98e3ac66482a7b257548a1683ec6c1a Mon Sep 17 00:00:00 2001
From: Dmitry Kandybka <[email protected]>
Date: Mon, 28 Sep 2026 18:26:32 +0300
Subject: [PATCH] tracing: Fix ignored return value of
resize_buffer_duplicate_size()

When tr->allocated_snapshot is true, resize_buffer_duplicate_size() is called to update the snapshot buffer size. However, its return value was not checked. In case of a failed resize this could lead next snapshot being incomplete.

Add resize_buffer_duplicate_size() result check and return error if resize fails.

Compile tested only.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

kernel/trace/trace_snapshot.c +4 -1
index 07b43c9863a2..4731ef7325a5 100644
@@ -675,9 +675,12 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
 		if (iter->cpu_file != RING_BUFFER_ALL_CPUS)
 			return -EINVAL;
 #endif
-		if (tr->allocated_snapshot)
+		if (tr->allocated_snapshot) {
 			ret = resize_buffer_duplicate_size(&tr->snapshot_buffer,
 					&tr->array_buffer, iter->cpu_file);
+			if (ret < 0)
+				return ret;
+		}
 
 		ret = tracing_arm_snapshot_locked(tr);
 		if (ret)
maintainer
#1 lore raw

PATCH 1/1 tracing: Fix ignored return value of resize_buffer_duplicate_size()

From: Dmitry Kandybka <[email protected]>

[ Upstream commit 3110d09bb98e3ac66482a7b257548a1683ec6c1a ]

When tr->allocated_snapshot is true, resize_buffer_duplicate_size() is called to update the snapshot buffer size. However, its return value was not checked. In case of a failed resize this could lead next snapshot being incomplete.

Add resize_buffer_duplicate_size() result check and return error if resize fails.

Compile tested only.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 180e4e390978 ("tracing: Add snapshot refcount")
[ sashal: Adapted snapshot_buffer access to max_buffer in the existing snapshot handler. ]
---
 kernel/trace/trace.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/trace/trace.c +4 -1
index 45b24fe040ad8..a76743475e9f4 100644
@@ -7811,9 +7811,12 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
 		if (iter->cpu_file != RING_BUFFER_ALL_CPUS)
 			return -EINVAL;
 #endif
-		if (tr->allocated_snapshot)
+		if (tr->allocated_snapshot) {
 			ret = resize_buffer_duplicate_size(&tr->max_buffer,
 					&tr->array_buffer, iter->cpu_file);
+			if (ret < 0)
+				return ret;
+		}
 
 		ret = tracing_arm_snapshot_locked(tr);
 		if (ret)
Signature · 1 line
2.53.0