From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F41887083C for ; Mon, 8 Dec 2025 08:59:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765184381; cv=none; b=nf/WxEw7PM8QxugiFSMWGytQXdtkQZUy6hmd7g3JjxSIlFUVVHkHCu40p+5+RIyUrINurx3XJtaKMfH9tK1gPKgGWkQKGs/WUFazEGw059DneKqCdglReU5uESFbKv1oY8/gfrEAJW0iRpaXQYamtwZqUEKr9c8p4wIb4eZYapY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765184381; c=relaxed/simple; bh=AbAfQOKVKOhalJr0SBhMWkxZEAPXtQJWY8iPpwPxZ6I=; h=From:Content-Type:Mime-Version:Subject:In-Reply-To:Date:Cc: Message-Id:References:To; b=sU97n/u31ncKjms4tqwnNI7TlfUeG+qpDZ2vN5IYmi51QLy00kjNJ3FjEXjqw6CX4fL0uvAxfASKGTL/aCFSN6+y5hKgXOMwbIv1GWnDuN77+t9iH9hNT9P7tBxGPSFmIv/t4nYGwPTBvRKE5DSg/Wi2FvOXkzcWSgWg1cIe22A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ic6L/uL7; arc=none smtp.client-ip=209.85.216.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ic6L/uL7" Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-3410c86070dso3268837a91.1 for ; Mon, 08 Dec 2025 00:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765184379; x=1765789179; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:subject:mime-version:from:from:to:cc:subject:date :message-id:reply-to; bh=rLUMcfa3m0yMke//cJjqI8fSMt2SaDS5xVKgbYRpXg8=; b=ic6L/uL7CuwC17cyOgu+xygY9xaDm9LvJkSinW3tMGHlKxgruqjAOIOxXwLeu95G6F tUo2YMd0hn7cMVHAKTEbYNHQmWZFeHfxMG1DHLYhIIGU+e1iRnYF6WftDWah3zfDLjaK NR9/2g4wCTrHuCNtn4CZQ44mmkJU3Bt0F7p2OVHyza1266OMFWuHRcls9wWDqaWgK8hn wKOMjW4TzAZnFK40jtXs6B1w+sGt4p2Pp9crFW8a2fSJhFK6wzDMJKPMT8KLIf9NAHDW 8rIKL9VTS937kT7bhDt7IiCrXShcVUr3zvyUxvA3E8SVKiQWFzgnhMuDW1gwTHcVp80j DqDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765184379; x=1765789179; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:subject:mime-version:from:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rLUMcfa3m0yMke//cJjqI8fSMt2SaDS5xVKgbYRpXg8=; b=VA2pyMVjCD0cmjeaE9qjzEPVRWEZKAk7il5WrCLMVfj6XK9u5vg4krw+w/7NybP2Mr ki7aiyR+QIFMLbOfMmLS04O/fM5uK7sa7U87igiKsXvJDsqBQHnhLY4jhjh58+dKYe41 SNkgmPFKfEd7zygBk4JdyN02nq9YgDt1zXiBXYwUhHGJNmWW1EMXqiwnt4PS0Q0W9TPB NF1cGgFU1dcepcWn3Qx61Kyb8+GZmM6KbHVUmBAZPpGJK8qe0erMPlk8g5cGxS1l//Lj nyJISLJa8UFmmcG4FGuaxZG4NVq1+XcU8mfNey0qoBREfmTHFfWsfl3j9C/6H7N0ZNov dCwg== X-Forwarded-Encrypted: i=1; AJvYcCVdJKj2N29592+hKdQ3AnTq5La/G+bH1nLIuZgEctASu+2AiU9ctUManiQuC4BLbE/eGVICydQMWbjBGAQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzrqkbnxsK0+9iWW9xkB8KNOFliEx2LjnlBAVXUaIK+5FtGnBkk Dzlpv+W2w4Xoga7kqL6CbtBtm/NrSWYfApd1/mGYheenL74NtTbHvu7PmVYbk7WGsWG2bg== X-Gm-Gg: ASbGnct8zoY8cYbCp+fgvV9NnGBVP7wMoHfITa7yKPUp8UEZ8Xm2bQfL13xx7235Ewj Ngf+LRrQix3171DRhrWs/peJncA8xjgomovvv1DuUbcdqkz1rLbvM7K19KilFTW2O2kJXERvLgq IT1YfYKaocSIklHX0WQibfZtp2b/EnUazCFp8SiCrsnifz5fHIagxIIf3Cvb9VR9cx/DIQtw1dK zCPFulA8nNL+0V4cXqqzjtdPpOGUFB11celppnTt3hCwZbrwnjlkT1rN/uM/40QdAbKm1XoD+51 oouYWDtWDRzzLVYXYVcQXyxQRDNqvqclKUU5G48MU9VIcba9bd+KQ7GPGA/bSpeL3Yd2n0n5U1X BJqOGm0h1zo1xaJB3gsWh96wdDzj0huw7K6fX1A8RqBBXIsQ+h5YskYqoXTMKAsEO8AqtK51P0e LvduPn4JkGiN7m3MDGaDIjvMWCK0qfGTrP9ifc6sip X-Google-Smtp-Source: AGHT+IHd6m49WuustZxX2QvF4HeyJhawxnwaeWkIUEHZ/bDwjuu6tITB49bqrqPoy2orZO1ly0YmFA== X-Received: by 2002:a17:90b:4c89:b0:343:6611:f21 with SMTP id 98e67ed59e1d1-349a24e3b08mr5325961a91.1.1765184379238; Mon, 08 Dec 2025 00:59:39 -0800 (PST) Received: from smtpclient.apple ([139.177.225.231]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3494ea63c1asm11417337a91.9.2025.12.08.00.59.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Dec 2025 00:59:38 -0800 (PST) From: qingwei hu X-Google-Original-From: qingwei hu Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.200.81.1.6\)) Subject: Re: [PATCH] kprobes: Call check_ftrace_location() on CONFIG_KPROBES_ON_FTRACE In-Reply-To: <20251208161955.54e2fef0fc793092a93ce88e@kernel.org> Date: Mon, 8 Dec 2025 16:59:24 +0800 Cc: davem@davemloft.net, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, naveen@kernel.org, qingwei.hu@bytedance.com, rostedt@goodmis.org Content-Transfer-Encoding: quoted-printable Message-Id: <2DC4EBDA-F668-4DB8-9F0C-F31FAFCF0721@bytedance.com> References: <20251205092933.3889547-1-qingwei.hu@bytedance.com> <20251205100823.28aa8ffd@gandalf.local.home> <2E248E7C-773B-4998-B059-A576163B36B0@bytedance.com> <20251208161955.54e2fef0fc793092a93ce88e@kernel.org> To: "Masami Hiramatsu (Google)" X-Mailer: Apple Mail (2.3864.200.81.1.6) > On Dec 8, 2025, at 15:19, Masami Hiramatsu (Google) = wrote: >=20 > On Mon, 8 Dec 2025 14:54:33 +0800 > qingwei hu wrote: >=20 >>=20 >>=20 >>> 2025=E5=B9=B412=E6=9C=885=E6=97=A5 23:08=EF=BC=8CSteven Rostedt = =E5=86=99=E9=81=93=EF=BC=9A >>>=20 >>> On Fri, 5 Dec 2025 17:29:33 +0800 >>> "qingwei.hu" wrote: >>>=20 >>>> From: Qingwei Hu >>>>=20 >>>> There is a possible configuration dependency: >>>>=20 >>>> KPROBES_ON_FTRACE [=3Dn] >>>> ^----- KPROBES [=3Dy] >>>> |--- HAVE_KPROBES_ON_FTRACE [=3Dn] >>>> |--- DYNAMIC_FTRACE_WITH_REGS [=3Dn] >>>> ^----- FTRACE [=3Dy] >>>> |--- DYNAMIC_FTRACE [=3Dy] >>>> |--- HAVE_DYNAMIC_FTRACE_WITH_REGS [=3Dn] >>>>=20 >>>> With DYNAMIC_FTRACE=3Dy, ftrace_location() is meaningful and may >>>> return the same address as the probe target. >>>>=20 >>>> However, when KPROBES_ON_FTRACE=3Dn, the current implementation >>>> returns -EINVAL after calling check_ftrace_location(), causing >>>> the validation to fail. >>>=20 >>> This is a feature not a bug. >>>=20 >>> The reason is if you put a kprobe on a ftrace location, it can cause = ftrace >>> to trigger a bug, as kprobes will modify the location and ftrace = will see >>> something it doesn't expect and think the system is corrupted. We = don't want >>> that either. >>>=20 >>> If you say "KPROBES_ON_FTRACE=3Dn" and place a kprobe on a location = that is >>> controlled by ftrace, it had better fail! >>>=20 >>> NAK >>>=20 >>> -- Steve >>=20 >> Thanks for your clear explanation. I will look into other approaches >> that work with this configuration. >>=20 >=20 > Can you check the code under arch// implements the > kprobe_ftrace_handler() correctly? if so, it should be enabled = automatically. >=20 > Thank you, >=20 >=20 > --=20 > Masami Hiramatsu (Google) I am working on the risc-v that have removed support for = KPROBE_ON_FTRACE and probe_ftrace_hander() since 7caa9765465f60 and 3308172276db5d. As 7caa9765465f60 commit say KPROBES_ON_FTRACE will be supplanted by = FPROBES, I have tested and verified this feature's usability. In this situation, = may be we should use fprobe instead of kprobe. But in the latest version, risc-v adjusts ftrace location to an offset 4 = byte from the function symbol. So it will kprobe successfully in the = beginning of the symbol while not support KPROBE_ON_FTRACE. I am not sure whether = this arrangement is consistent with Steve=E2=80=99s explanation. If the = adjustment is valid, I can temporarily backport the adjust function in order to support = kprobe.