linux/rust
Alice Ryhl 94d356c033
rust: security: add abstraction for secctx
Add an abstraction for viewing the string representation of a security
context.

This is needed by Rust Binder because it has a feature where a process
can view the string representation of the security context for incoming
transactions. The process can use that to authenticate incoming
transactions, and since the feature is provided by the kernel, the
process can trust that the security context is legitimate.

This abstraction makes the following assumptions about the C side:
* When a call to `security_secid_to_secctx` is successful, it returns a
  pointer and length. The pointer references a byte string and is valid
  for reading for that many bytes.
* The string may be referenced until `security_release_secctx` is
  called.
* If CONFIG_SECURITY is set, then the three methods mentioned in
  rust/helpers are available without a helper. (That is, they are not a
  #define or `static inline`.)

Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Trevor Gross <tmgross@umich.edu>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20240915-alice-file-v10-5-88484f7a3dcf@google.com
Acked-by: Paul Moore <paul@paul-moore.com>
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-09-30 13:02:28 +02:00
..
bindings rust: security: add abstraction for secctx 2024-09-30 13:02:28 +02:00
helpers rust: security: add abstraction for secctx 2024-09-30 13:02:28 +02:00
kernel rust: security: add abstraction for secctx 2024-09-30 13:02:28 +02:00
macros kbuild: rust: replace proc macros dependency on core.o with the version text 2024-09-05 22:44:51 +02:00
uapi rust: allow dead_code for never constructed bindings 2024-07-10 10:28:51 +02:00
.gitignore rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
bindgen_parameters rust: Ignore preserve-most functions 2023-12-13 01:09:55 +01:00
build_error.rs rust: add build_error crate 2022-12-04 01:59:16 +01:00
compiler_builtins.rs rust: add intrinsics to fix -Os builds 2024-08-10 00:05:10 +02:00
exports.c rust: kbuild: auto generate helper exports 2024-08-19 11:09:02 +02:00
Makefile kbuild: rust: replace proc macros dependency on core.o with the version text 2024-09-05 22:44:51 +02:00