| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* Credentials management - see Documentation/security/credentials.rst |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. |
|---|
| 4 | 5 | * 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. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #ifndef _LINUX_CRED_H |
|---|
| .. | .. |
|---|
| 15 | 11 | #include <linux/capability.h> |
|---|
| 16 | 12 | #include <linux/init.h> |
|---|
| 17 | 13 | #include <linux/key.h> |
|---|
| 18 | | -#include <linux/selinux.h> |
|---|
| 19 | 14 | #include <linux/atomic.h> |
|---|
| 20 | 15 | #include <linux/uidgid.h> |
|---|
| 21 | 16 | #include <linux/sched.h> |
|---|
| .. | .. |
|---|
| 139 | 134 | #ifdef CONFIG_KEYS |
|---|
| 140 | 135 | unsigned char jit_keyring; /* default keyring to attach requested |
|---|
| 141 | 136 | * keys to */ |
|---|
| 142 | | - struct key __rcu *session_keyring; /* keyring inherited over fork */ |
|---|
| 137 | + struct key *session_keyring; /* keyring inherited over fork */ |
|---|
| 143 | 138 | struct key *process_keyring; /* keyring private to this process */ |
|---|
| 144 | 139 | struct key *thread_keyring; /* keyring private to this thread */ |
|---|
| 145 | 140 | struct key *request_key_auth; /* assumed request_key authority */ |
|---|
| .. | .. |
|---|
| 173 | 168 | extern int set_security_override(struct cred *, u32); |
|---|
| 174 | 169 | extern int set_security_override_from_ctx(struct cred *, const char *); |
|---|
| 175 | 170 | extern int set_create_files_as(struct cred *, struct inode *); |
|---|
| 171 | +extern int cred_fscmp(const struct cred *, const struct cred *); |
|---|
| 176 | 172 | extern void __init cred_init(void); |
|---|
| 177 | 173 | |
|---|
| 178 | 174 | /* |
|---|
| .. | .. |
|---|
| 256 | 252 | validate_creds(cred); |
|---|
| 257 | 253 | nonconst_cred->non_rcu = 0; |
|---|
| 258 | 254 | 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; |
|---|
| 259 | 267 | } |
|---|
| 260 | 268 | |
|---|
| 261 | 269 | /** |
|---|
| .. | .. |
|---|
| 378 | 386 | #define current_fsgid() (current_cred_xxx(fsgid)) |
|---|
| 379 | 387 | #define current_cap() (current_cred_xxx(cap_effective)) |
|---|
| 380 | 388 | #define current_user() (current_cred_xxx(user)) |
|---|
| 381 | | -#define current_security() (current_cred_xxx(security)) |
|---|
| 382 | 389 | |
|---|
| 383 | 390 | extern struct user_namespace init_user_ns; |
|---|
| 384 | 391 | #ifdef CONFIG_USER_NS |
|---|