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=1796307477; b=xlDj76eVYCDtO2CLfmx4Mf53fd3fDaU3khFIRBj0TmLzyYbAfEVV+IRthdauxGTzG7Gc kthLMHmQTy64svHjp6Ty01zRtsgQ/OH83dX2UTrvD2nW8Pi11DqMb2pM3CsVLDW57P9RC dG3U3hb+yFjQjDJDfbvK2L7yZGE6sW46o2+iAj5WE3iG15LLOoHfjlB/x3YB0hKF9eAKJ Gb7Cw3NEz5fz/cEbBtg7dqIhcyR2WxVZ2MGYhiLAayRtE7UuYdn48U9YW8CL/0IBEmCJw SXYRNwq/X0uyoJtPkLWts2gkvE1lDP+I6Hz1OuowEoYqPqfND+p72gi2COUaIg+peXw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307477; h=Received:DKIM-Signature:Received:Message-ID:User-Agent:Date:From:To: Cc:Subject:References:MIME-Version:Content-Type; bh=H+18jKoxRxU/qbE2KiQ7zNu8zBYgXQWWDqoLAlEd5Cw=; b=xm94gpnAST2BHDmjxwoHXSemwtjAGnFq6au1iXe95M9itieb3fGFtplXUoFBF8dwZhe1 AHAlASGgh7lN0JU/CA2CtPq0bnxEMxOs8ABMV5i3hI+xftXhsTWGmEMzj0W38h1Xq0SI4 ZYaBBdkuPZy7MmRLpUwSOQM+3yCW7gDSEb5CYtNiUWUXvalPIeW6bqWwfYS4TfrjcQHm8 HdiNYriqAfs55SOLLSs4Uioz0pr+oqeBUIHrD3GENFxQWFHzRt1/LkLUao2jHGwA36ZkR nBkmlvSe+s3sywzjHbYWtJHtDixsk1Sd8xpI6G5w4Hkkut1ipgK6gByPD3Ph8WDEPeA== 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=L8dZvilV; 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 22BCE606A322; Thu, 3 Dec 2026 14:17:57 +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=L8dZvilV Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1C551F00896; Thu, 3 Dec 2026 14:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796307477; bh=H+18jKoxRxU/qbE2KiQ7zNu8zBYgXQWWDqoLAlEd5Cw=; h=Date:From:To:Cc:Subject:References; b=L8dZvilVi8QmKFMZWwaU5rftsOGf8aUDjKlBN/wOMTtmtypD+Zgdt46e69GswcvIk o/OUJbkRq3mcBjQWfY5b7NlblMmI4aHi6+ymsQ8wUivB16GyLjhrL3vUX4rIscJ5nJ OtkX6guY7Q+PMyRLDgv12BNSJJfnW5KmVBVSqe3RNOf4bLhDqC1CtS8RJ0JtERfH+Y an5uhTpBmju3yeAo+NGf6zDdB+L/piLOZiJ0k8WX/utET6V1kopGJw8is0sDx4dffD y0SxS5XjUjvsH+0Hqe/x2Fklhs1GgbWPg3n1mr8lsV8Iy/PE62JVrDmfEyBxX5iQiY XgrAoHHktqwxg== Received: from rostedt by gandalf with local (Exim 4.100.1) (envelope-from ) id 1xZ7dE-0000000C21v-1LrB; Thu, 03 Dec 2026 09:17:56 -0500 Message-ID: <20261203141756.126494816@kernel.org> User-Agent: quilt/0.69 Date: Thu, 03 Dec 2026 09:17:26 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, sashiko-bot@kernel.org Subject: [for-linus][PATCH 1/8] tracing: Fix crash on lseek of recursed_functions file in WRONLY mode References: <20261203141725.845506016@kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Steven Rostedt The lseek method for the "recursed_functions" file only handles seq_lseek() which is for when the file is opened for reading. If the file is opened for WRONLY, it will cause a NULL pointer dereferenced: Oops: general protection fault, probably for non-canonical address 0xdffffc0000000012: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000090-0x0000000000000097] CPU: 5 UID: 0 PID: 1100 Comm: lseek Not tainted 7.4.0-rc4-test-00006-g4dca8a8ee893 #36 PREEMPT(lazy) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 RIP: 0010:__mutex_lock+0x162/0x2550 Code: 08 84 d2 0f 85 a1 1c 00 00 44 8b 0d 38 cb df 03 45 85 c9 75 29 48 b8 00 00 00 00 00 fc ff df 48 8d 7b 58 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 a6 1c 00 00 48 3b 5b 58 0f 85 3f 0e 00 00 bf 01 RSP: 0018:ffff8881211afd10 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: 0000000000000038 RCX: 8000000000000000 RDX: 0000000000000012 RSI: ffffffff8588bdfb RDI: 0000000000000090 RBP: ffff8881211afe70 R08: 0000000000000001 R09: 0000000000000000 R10: ffff8881083f8000 R11: ffffed10247ebc54 R12: 0000000000000000 R13: 0000000000000000 R14: dffffc0000000000 R15: 1ffff11024235fac FS: 00007fb27d236780(0000) GS:ffff8882b4581000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055fb6eb6e008 CR3: 000000011d26e006 CR4: 0000000000172ef0 Call Trace: ? seq_lseek+0x60/0x3d0 ? kmem_cache_free+0x14b/0x610 ? __pfx___mutex_lock+0x10/0x10 ? do_sys_openat2+0xd8/0x180 ? seq_lseek+0x60/0x3d0 seq_lseek+0x60/0x3d0 ? __pfx___x64_sys_openat+0x10/0x10 ksys_lseek+0x3c/0xb0 do_syscall_64+0xcd/0x6f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7fb27d33fa17 Code: 8b 05 fd 03 0e 00 64 c7 00 0d 00 00 00 eb b2 e8 ef 98 01 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 08 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 8b 15 c9 03 0e 00 f7 d8 64 89 02 48 RSP: 002b:00007ffd486d0258 EFLAGS: 00000202 ORIG_RAX: 0000000000000008 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fb27d33fa17 RDX: 0000000000000002 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007ffd486d0280 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000002 R13: 00007fb27d482000 R14: 00007ffd486d03b0 R15: 000055fb6eb6cdd8 Modules linked in: ---[ end trace 0000000000000000 ]--- A helper function "tracing_lseek()" already exists for this use case. Have the file_operations for the recursed_functions file use that. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261125162834.2df4c684@gandalf.local.home Fixes: 773c16705058e ("ftrace: Add recording of functions that caused recursion") Reported-by: sashiko-bot@kernel.org Closes: https://sashiko.dev/?list=org.kernel.vger.linux-trace-kernel#/patchset/20260502174741.39636-1-yashsuthar983%40gmail.com Signed-off-by: Steven Rostedt --- kernel/trace/trace_recursion_record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_recursion_record.c b/kernel/trace/trace_recursion_record.c index 4f63bec052fc..0452c9c4c558 100644 --- a/kernel/trace/trace_recursion_record.c +++ b/kernel/trace/trace_recursion_record.c @@ -217,7 +217,7 @@ static const struct file_operations recursed_functions_fops = { .open = recursed_function_open, .write = recursed_function_write, .read = seq_read, - .llseek = seq_lseek, + .llseek = tracing_lseek, .release = recursed_function_release, }; -- 2.53.0