From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9DC743FFF9D for ; Tue, 11 Aug 2026 08:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786437201; cv=none; b=ot1zFBHxrFx7jXPvR8HUPMQw2lVEJsalrUhZ7EQOvr8ga9KubFLBZWt4FcnY+mnuxj37naFw6HwxrMKWBbaczoaXGONAb+APaPKziztELJ/WF5sq7rsVQnP52LecRokky4kIM4a3gg6b95U5z8pZCmEN2Poamw7xmfUgKucV7g4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786437201; c=relaxed/simple; bh=eGhkp78y0j9gb4w+MAJDBJ94U08BflApsVuciyIMsMQ=; h=Date:From:To:Cc:Subject:Message-Id:Mime-Version:Content-Type; b=RJ1mL7ZgYsYyp6JOBFa0w8yocfFSlCK7MLudE37sJC/hVG85fzYb5dFg2m4gu7q0dxovnIux8fGRiGvyE+39cJ8Y7rjPgfdSFB4+esh269lQpWsPU+Q/biAgMGhfw6T/ltaXV7z9unJLSx89LozAVCXnHhAxK+KsGGPkDbE3CaQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CGBJScAY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CGBJScAY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14EB71F000E9; Tue, 11 Aug 2026 08:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786437200; bh=TCgDFRgR+Y4XMsxZwF2+5KI6HnJiAnzGxqJNVSOnmNg=; h=Date:From:To:Cc:Subject; b=CGBJScAYQGIEViqg540UNDWuEKrU29uKble6glXvYXmg+1mGS9fmB4NGRJbncgL2l zLC5cfkDRfLHg51zRosUDhTSjkyGPvcUmK6Lck33r9Iuoo/DZ3e187PZv/9ehDDRb4 xRi4QwT+gLJFM3e7CJaSdhc1lhMMp5n1sBBD0KwgLq6PjaqC+wNXojog6ZSJMGhdn/ XGBEvn2k1ShHTK+3IHGEZRv83aTRALPQnPsvPJKUdGsAcAdwtYTFM2VGN7J3cmjFZ1 PWJJW7zqcHHwcgBKdSujTzoB/tjpyb+WdaBvX8u1F1zoJD4gHuTrVCbykOCctaxe0y a6TTJc9jR4eaw== Date: Tue, 11 Aug 2026 17:33:16 +0900 From: Masami Hiramatsu (Google) To: Linus Torvalds Cc: Rui Qi , Steven Rostedt , Masami Hiramatsu , linux-kernel@vger.kernel.org Subject: [GIT PULL] probes: Fixes for v7.2-rc7 Message-Id: <20260811173316.586a54e7e1dca31ee81692dc@kernel.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi Linus, Probes fixes for v7.2-rc7: - selftests/ftrace: Convert ELF entry point to file offset in uprobe test Convert the ELF entry point address (e_entry) to a file offset using LOAD segment headers in add_remove_uprobe test. This fixes uprobe registration failures (-EINVAL) on non-PIE executables where vaddr exceeds file size. Please pull the latest probes-fixes-v7.2-rc7 tree, which can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git probes-fixes-v7.2-rc7 Tag SHA1: 4c8d7ffb75feb2123c2a69ad46bb3c77c2bc74b0 Head SHA1: 24aa630f6259e6a2107936c06fed72063f712b64 Rui Qi (1): selftests/ftrace: Convert ELF entry point to file offset in uprobe test ---- .../ftrace/test.d/dynevent/add_remove_uprobe.tc | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) --------------------------- commit 24aa630f6259e6a2107936c06fed72063f712b64 Author: Rui Qi Date: Fri Aug 7 16:15:12 2026 +0800 selftests/ftrace: Convert ELF entry point to file offset in uprobe test The add_remove_uprobe test uses readelf -h to obtain the ELF entry point (e_entry) and passes it directly as the offset to uprobe_events. However, uprobe_events expects a file offset, not a virtual address. For PIE binaries, the virtual address happens to equal the file offset because the first LOAD segment has p_vaddr == p_offset, so the test works by coincidence. But for non-PIE executables, e_entry is an absolute virtual address that can far exceed the file size. When the probe is enabled, uprobe_register() checks offset > i_size_read(inode) and rejects it with -EINVAL. Fix this by converting the virtual address to a file offset using the ELF program headers: scan readelf -lW output for the LOAD segment containing the entry point, then compute file_offset = e_entry - p_vaddr + p_offset. For PIE binaries the result is unchanged; for non-PIE binaries the offset is correctly translated. The conversion uses only POSIX shell primitives, with no dependency on gawk or perl. Link: https://lore.kernel.org/all/20260807081512.2974757-3-qirui.001@bytedance.com/ Fixes: dc4b165855f2 ("selftests/ftrace: Use readelf to find entry point in uprobe test") Cc: stable@vger.kernel.org Signed-off-by: Rui Qi Signed-off-by: Masami Hiramatsu (Google) diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc index f2048c244526..19430bd5864c 100644 --- a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc @@ -12,9 +12,32 @@ echo 0 > events/enable echo > dynamic_events REALBIN=`readlink -f /bin/sh` -ENTRYPOINT=`readelf -h ${REALBIN} | grep Entry | sed -e 's/[^0]*//'` -echo "p:myevent ${REALBIN}:${ENTRYPOINT}" >> uprobe_events +# Get the entry point virtual address from ELF header +ENTRY=`readelf -hW ${REALBIN} | grep "Entry point" | awk '{print $NF}'` + +# Convert virtual address to file offset: find the LOAD segment containing +# the entry point, then compute file_offset = e_entry - p_vaddr + p_offset. +# For PIE binaries this is a no-op (vaddr == file offset), but for non-PIE +# executables the virtual address is much larger than the file size and +# must be converted, otherwise uprobe_register() rejects it with -EINVAL. +ENTRY_DEC=$(printf '%d' "$ENTRY") +OFFSET=$ENTRY +while IFS= read -r line; do + set -- $line + [ "$1" = "LOAD" ] || continue + VA_DEC=$(printf '%d' "$3") + OFF_DEC=$(printf '%d' "$2") + FSZ_DEC=$(printf '%d' "$5") + if [ "$ENTRY_DEC" -ge "$VA_DEC" ] && [ "$ENTRY_DEC" -lt "$((VA_DEC + FSZ_DEC))" ]; then + OFFSET=$(printf '0x%x' "$((ENTRY_DEC - VA_DEC + OFF_DEC))") + break + fi +done << EOF +$(readelf -lW ${REALBIN} | grep LOAD) +EOF + +echo "p:myevent ${REALBIN}:${OFFSET}" >> uprobe_events grep -q myevent uprobe_events test -d events/uprobes/myevent -- Masami Hiramatsu (Google)