From mboxrd@z Thu Jan 1 00:00:00 1970 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 CDBF7234964; Tue, 8 Jul 2025 02:12:00 +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=1751940720; cv=none; b=kiR+1ENdikE5oB39djDZcVWLthYp8Ac48abnMtS8ZYC/yQ1uI+/4xxu+Bgx+vzZ3IbXRqZkrQhUmHiRDar4P53isCXW9kV2zfKjXbFD1aXjQIw0fw9SLDulphO0qu32ntEMGJaE4dvuhgqRTVSHTJ+00vfzk3wNFBd3YzQHZvjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751940720; c=relaxed/simple; bh=/FbdkqgsRHQT3grN+rP3vo0JEynwNZBN/vKs+JQRgx0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=MZRKzQWoSDyEqXeXaKnmQYQ/7V7189LB07nFCKUQGV6SQbsjkICojHqUsSzPZ+KscjXqYXSY6yjDhatM3fC19TCXf8NXAHTDoEPNK97T6CjQdzdT9q7DFvqV+pbznSg7oTE8hCz2sB8puCYgOo1zRVfA+3TQMXybdgbGoeAAQg8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DpdZyziQ; 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="DpdZyziQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5591BC4CEFF; Tue, 8 Jul 2025 02:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751940720; bh=/FbdkqgsRHQT3grN+rP3vo0JEynwNZBN/vKs+JQRgx0=; h=Date:From:To:Cc:Subject:References:From; b=DpdZyziQEjyLVkRSx5ewFYD3A/AwizLJSJax7xpONR6pAdGYkswEPqWnokSuqDrse 3lRvrvqUQeGT5/xb0rrXaSTSvTNaEr7Lb/2R+Sxi379blICo7a4OepBduQ+YaOOSFl rPg+mfXM/U4PCIGAw0HdaFwUc2MEvweBMpByJO8IIQiXrCVd+L0OrHULCXQmA5Qdxe GgoC4ZpC2gdlnjy1bYpqmHEA4WQHa4kYQL+0ofNMK/CU/aRP/SjyNa8WkhyiANIzAC dchZlqejRnT5E688anYppXDW5VVGKWx0oODz8xehltry2jSnaV5UgNwaEAPaUOTMGA 4cOxSlz4dujxw== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1uYxoO-00000000DgX-2J09; Mon, 07 Jul 2025 22:12:00 -0400 Message-ID: <20250708021200.397301537@kernel.org> User-Agent: quilt/0.68 Date: Mon, 07 Jul 2025 22:11:27 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org Cc: Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Jens Remus , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [PATCH v8 12/12] unwind_user/sframe: Add prctl() interface for registering .sframe sections References: <20250708021115.894007410@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Josh Poimboeuf The kernel doesn't have direct visibility to the ELF contents of shared libraries. Add some prctl() interfaces which allow glibc to tell the kernel where to find .sframe sections. [ This adds an interface for prctl() for testing loading of sframes for libraries. But this interface should really be a system call. This patch is for testing purposes only and should not be applied to mainline. ] Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) --- include/uapi/linux/prctl.h | 6 +++++- kernel/sys.c | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index 43dec6eed559..c575cf7151b1 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -351,7 +351,7 @@ struct prctl_mm_map { * configuration. All bits may be locked via this call, including * undefined bits. */ -#define PR_LOCK_SHADOW_STACK_STATUS 76 +#define PR_LOCK_SHADOW_STACK_STATUS 76 /* * Controls the mode of timer_create() for CRIU restore operations. @@ -371,4 +371,8 @@ struct prctl_mm_map { # define PR_FUTEX_HASH_GET_SLOTS 2 # define PR_FUTEX_HASH_GET_IMMUTABLE 3 +/* SFRAME management */ +#define PR_ADD_SFRAME 79 +#define PR_REMOVE_SFRAME 80 + #endif /* _LINUX_PRCTL_H */ diff --git a/kernel/sys.c b/kernel/sys.c index adc0de0aa364..cf788e66dc86 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -65,6 +65,7 @@ #include #include #include +#include #include @@ -2824,6 +2825,14 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, case PR_FUTEX_HASH: error = futex_hash_prctl(arg2, arg3, arg4); break; + case PR_ADD_SFRAME: + error = sframe_add_section(arg2, arg3, arg4, arg5); + break; + case PR_REMOVE_SFRAME: + if (arg3 || arg4 || arg5) + return -EINVAL; + error = sframe_remove_section(arg2); + break; default: trace_task_prctl_unknown(option, arg2, arg3, arg4, arg5); error = -EINVAL; -- 2.47.2