Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\process_keys.c Create Date:2022-07-28 18:22:05
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Look up the user and user session keyrings for the current process's UID,* creating them if they don't exist.

Proto:int look_up_user_keyrings(struct key **_user_keyring, struct key **_user_session_keyring)

Type:int

Parameter:

TypeParameterName
struct key **_user_keyring
struct key **_user_session_keyring
77  cred = current_cred - Access the current task's subjective credentials* Access the subjective credentials of the current task. RCU-safe,* since nobody else can modify it.()
78  user_ns = current_user_ns()
82  uid = from_kuid(user_ns, real UID of the task )
86  user_keyring_perm = KEY_POS_ALL & ~possessor can set key attributes | KEY_USR_ALL
88  kenter("%u", uid)
90  reg_keyring = Get or create a user register keyring.
91  If IS_ERR(reg_keyring) Then Return PTR_ERR(reg_keyring)
94  lock for writing
95  ret = 0
101  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
102  uid_keyring_r = keyring_search - Search the supplied keyring tree for a matching key*@keyring: The root of the keyring tree to be searched
104  kdebug("_uid %p", uid_keyring_r)
105  If uid_keyring_r == ERR_PTR( - EAGAIN) Then
106  uid_keyring = Allocate a keyring and link into the destination keyring.
111  If IS_ERR(uid_keyring) Then
113  Go to error
115  Else if IS_ERR(uid_keyring_r) Then
116  ret = PTR_ERR(uid_keyring_r)
117  Go to error
118  Else
119  uid_keyring = key_ref_to_ptr(uid_keyring_r)
123  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
124  session_keyring_r = keyring_search - Search the supplied keyring tree for a matching key*@keyring: The root of the keyring tree to be searched
126  kdebug("_uid_ses %p", session_keyring_r)
127  If session_keyring_r == ERR_PTR( - EAGAIN) Then
128  session_keyring = Allocate a keyring and link into the destination keyring.
133  If IS_ERR(session_keyring) Then
135  Go to error_release
141  ret = key_link - Link a key to a keyring*@keyring: The keyring to make the link in
142  If ret < 0 Then Go to error_release_session
148  ret = key_link - Link a key to a keyring*@keyring: The keyring to make the link in
149  If ret < 0 Then Go to error_release_session
151  Else if IS_ERR(session_keyring_r) Then
152  ret = PTR_ERR(session_keyring_r)
153  Go to error_release
154  Else
155  session_keyring = key_ref_to_ptr(session_keyring_r)
158  lease a write lock
160  If _user_session_keyring Then _user_session_keyring = session_keyring
162  Else key_put - Discard a reference to a key.*@key: The key to discard a reference from.* Discard a reference to a key, and when all the references are gone, we* schedule the cleanup task to come and pull it out of the tree in process
164  If _user_keyring Then _user_keyring = uid_keyring
166  Else key_put - Discard a reference to a key.*@key: The key to discard a reference from.* Discard a reference to a key, and when all the references are gone, we* schedule the cleanup task to come and pull it out of the tree in process
168  kleave(" = 0")
169  Return 0
171  error_release_session :
172  key_put - Discard a reference to a key.*@key: The key to discard a reference from.* Discard a reference to a key, and when all the references are gone, we* schedule the cleanup task to come and pull it out of the tree in process
173  error_release :
174  key_put - Discard a reference to a key.*@key: The key to discard a reference from.* Discard a reference to a key, and when all the references are gone, we* schedule the cleanup task to come and pull it out of the tree in process
175  error :
176  lease a write lock
177  kleave(" = %d", ret)
178  Return ret
Caller
NameDescribe
lookup_user_keyLook up a key ID given us by userspace with a given permissions mask to get* the key it refers to.* Flags can be passed to request that special keyrings be created if referred* to directly, to permit partially constructed keys to be found and to skip
init_root_keyringMake sure that root's user and user-session keyrings exist.
call_sbin_request_keyRequest userspace finish the construction of a key* - execute "/sbin/request-key "
construct_get_dest_keyringGet the appropriate destination keyring for the request.* The keyring selected is returned with an extra reference upon it which the* caller must release.