mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 08:38:45 +02:00 
			
		
		
		
	 a3df991d3d
			
		
	
	
		a3df991d3d
		
			
		
	
	
	
	
		
			
			Add a wrapper around `struct cred` called `Credential`, and provide functionality to get the `Credential` associated with a `File`. Rust Binder must check the credentials of processes when they attempt to perform various operations, and these checks usually take a `&Credential` as parameter. The security_binder_set_context_mgr function would be one example. This patch is necessary to access these security_* methods from Rust. This Rust abstraction makes the following assumptions about the C side: * `struct cred` is refcounted with `get_cred`/`put_cred`. * It's okay to transfer a `struct cred` across threads, that is, you do not need to call `put_cred` on the same thread as where you called `get_cred`. * The `euid` field of a `struct cred` never changes after initialization. * The `f_cred` field of a `struct file` never changes after initialization. Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Co-developed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Trevor Gross <tmgross@umich.edu> Reviewed-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> 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-4-88484f7a3dcf@google.com Reviewed-by: Kees Cook <kees@kernel.org> Reviewed-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			660 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			660 B
		
	
	
	
		
			C
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0
 | |
| /*
 | |
|  * Non-trivial C macros cannot be used in Rust. Similarly, inlined C functions
 | |
|  * cannot be called either. This file explicitly creates functions ("helpers")
 | |
|  * that wrap those so that they can be called from Rust.
 | |
|  *
 | |
|  * Sorted alphabetically.
 | |
|  */
 | |
| 
 | |
| #include "blk.c"
 | |
| #include "bug.c"
 | |
| #include "build_assert.c"
 | |
| #include "build_bug.c"
 | |
| #include "cred.c"
 | |
| #include "err.c"
 | |
| #include "fs.c"
 | |
| #include "kunit.c"
 | |
| #include "mutex.c"
 | |
| #include "page.c"
 | |
| #include "rbtree.c"
 | |
| #include "refcount.c"
 | |
| #include "signal.c"
 | |
| #include "slab.c"
 | |
| #include "spinlock.c"
 | |
| #include "task.c"
 | |
| #include "uaccess.c"
 | |
| #include "wait.c"
 | |
| #include "workqueue.c"
 |