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 5E92A20459A; Thu, 17 Jul 2025 01:29:17 +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=1752715757; cv=none; b=TvDzPj2C5Mf2HeGIbeVtomIwpFKZnBOsXS4Jxh+P0Ku2nHAxm27qfmdJoh0J4xsafM2e8a8ywz9yjRMLPhINauEIU+qd9FhScaVO25Ztjnu/DMzkb266NE1AQodmGpRR47pRZObObxFh+2oDYB7Y21VaWxJE6wfsHauKAgkQq2w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752715757; c=relaxed/simple; bh=/FbdkqgsRHQT3grN+rP3vo0JEynwNZBN/vKs+JQRgx0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=fOdpzyBCIZrRVA/wZlm2IJHOI36LvpD34+b5NWNb2snaHVEEt56jaLVjB98f6A+Vxj4yvEx0wpawxiU3kr3ZvhG81kw0wDtYCXMueKwnirwOO2+qfXBhqf3azuyGSOnWOWQQS0LzMo9ILu3DfLIJAjwE6l7m4bLRGwjK69lI/E0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IKVQNl7W; 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="IKVQNl7W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E0E7C4AF0C; Thu, 17 Jul 2025 01:29:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752715757; bh=/FbdkqgsRHQT3grN+rP3vo0JEynwNZBN/vKs+JQRgx0=; h=Date:From:To:Cc:Subject:References:From; b=IKVQNl7WkjtS6jt+CzQKZazYWBiNNVxZhwxxEEkdtw7H0HGd8DcGEZndNdM3sDIx6 vb8oQOtUCLGsH1+h/Rtr7+5hDTR9KQj+pvdCIHnfCd82IzFG4K7QUcVodahpV3+l+A AGfCbJdu6t/6rHQT7ca/v0Sc9dQNfhQ3pnlYb3+vsN8hENruCcP7V89dLmiseUYMTe /nbhwfu3dHF7cyjSvmrk2a6Zw+RMSowB75lhqFxx6Dox2gDUWs0GgrNHh8F3hOzt1A 1WwGgHkZ+B9PAN75PeXiSggVsurxctnyW1gR3ZlOBs/IgRt++nvMp2lbKYEDbvSMHO 6nM+VLCpXPAxA== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1ucDRJ-000000068zj-2b76; Wed, 16 Jul 2025 21:29:37 -0400 Message-ID: <20250717012937.469785338@kernel.org> User-Agent: quilt/0.68 Date: Wed, 16 Jul 2025 21:28:59 -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 v9 11/11] [DO NOT APPLY] unwind_user/sframe: Add prctl() interface for registering .sframe sections References: <20250717012848.927473176@kernel.org> 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=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