hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/include/linux/cred.h
....@@ -1,12 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /* Credentials management - see Documentation/security/credentials.rst
23 *
34 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
45 * Written by David Howells (dhowells@redhat.com)
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public Licence
8
- * as published by the Free Software Foundation; either version
9
- * 2 of the Licence, or (at your option) any later version.
106 */
117
128 #ifndef _LINUX_CRED_H
....@@ -15,7 +11,6 @@
1511 #include <linux/capability.h>
1612 #include <linux/init.h>
1713 #include <linux/key.h>
18
-#include <linux/selinux.h>
1914 #include <linux/atomic.h>
2015 #include <linux/uidgid.h>
2116 #include <linux/sched.h>
....@@ -139,7 +134,7 @@
139134 #ifdef CONFIG_KEYS
140135 unsigned char jit_keyring; /* default keyring to attach requested
141136 * keys to */
142
- struct key __rcu *session_keyring; /* keyring inherited over fork */
137
+ struct key *session_keyring; /* keyring inherited over fork */
143138 struct key *process_keyring; /* keyring private to this process */
144139 struct key *thread_keyring; /* keyring private to this thread */
145140 struct key *request_key_auth; /* assumed request_key authority */
....@@ -173,6 +168,7 @@
173168 extern int set_security_override(struct cred *, u32);
174169 extern int set_security_override_from_ctx(struct cred *, const char *);
175170 extern int set_create_files_as(struct cred *, struct inode *);
171
+extern int cred_fscmp(const struct cred *, const struct cred *);
176172 extern void __init cred_init(void);
177173
178174 /*
....@@ -256,6 +252,18 @@
256252 validate_creds(cred);
257253 nonconst_cred->non_rcu = 0;
258254 return get_new_cred(nonconst_cred);
255
+}
256
+
257
+static inline const struct cred *get_cred_rcu(const struct cred *cred)
258
+{
259
+ struct cred *nonconst_cred = (struct cred *) cred;
260
+ if (!cred)
261
+ return NULL;
262
+ if (!atomic_inc_not_zero(&nonconst_cred->usage))
263
+ return NULL;
264
+ validate_creds(cred);
265
+ nonconst_cred->non_rcu = 0;
266
+ return cred;
259267 }
260268
261269 /**
....@@ -378,7 +386,6 @@
378386 #define current_fsgid() (current_cred_xxx(fsgid))
379387 #define current_cap() (current_cred_xxx(cap_effective))
380388 #define current_user() (current_cred_xxx(user))
381
-#define current_security() (current_cred_xxx(security))
382389
383390 extern struct user_namespace init_user_ns;
384391 #ifdef CONFIG_USER_NS