History

security: don't use RCU accessors for cred->session_keyring

sparse complains that a bunch of places in kernel/cred.c access cred->session_keyring without the RCU helpers required by the __rcu annotation. cred->session_keyring is written in the following places: - prepare_kernel_cred() [in a new cred struct] - keyctl_session_to_parent() [in a new cred struct] - prepare_creds [in a new cred struct, via memcpy] - install_session_keyring_to_cred() - from install_session_keyring() on new creds - from join_session_keyring() on new creds [twice] - from umh_keys_init() - from call_usermodehelper_exec_async() on new creds All of these writes are before the creds are committed; therefore, cred->session_keyring doesn't need RCU protection. Remove the __rcu annotation and fix up all existing users that use __rcu.

Jann Horn committed 7 years ago

Commit 5c7e3721 parent 1b26fcd3 files · +7 −16Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/cred.h+1−1
@@ -138,7 +138,7 @@ struct cred { · 137 unmodified lines
138#ifdef CONFIG_KEYS138#ifdef CONFIG_KEYS
139 unsigned char jit_keyring; /* default keyring to attach requested139 unsigned char jit_keyring; /* default keyring to attach requested
140 * keys to */140 * keys to */
141 struct key __rcu *session_keyring; /* keyring inherited over fork */141 struct key *session_keyring; /* keyring inherited over fork */
142 struct key *process_keyring; /* keyring private to this process */142 struct key *process_keyring; /* keyring private to this process */
143 struct key *thread_keyring; /* keyring private to this thread */143 struct key *thread_keyring; /* keyring private to this thread */
144 struct key *request_key_auth; /* assumed request_key authority */144 struct key *request_key_auth; /* assumed request_key authority */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t