Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\safesetid\securityfs.c Create Date:2022-07-28 19:55:34
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:handle_policy_update

Proto:static ssize_t handle_policy_update(struct file *file, const char __user *ubuf, size_t len)

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
const char __user *ubuf
size_tlen
117  pol = Allocation memory
118  If Not pol Then Return -ENOMEM
120  policy_str = NULL
121  hash_init - initialize a hash table*@hashtable: hashtable to be initialized* Calculates the size of the hashtable from the given parameter, otherwise* same as hash_init_size.* This has to be a macro since HASH_BITS() will not work on pointers since(rules)
123  p = buf = memdup_user_nul - duplicate memory region from user space and NUL-terminate*@src: source address in user space*@len: number of bytes to copy* Return: an ERR_PTR() on failure.
124  If IS_ERR(buf) Then
125  err = PTR_ERR(buf)
126  Go to out_free_pol
128  policy_str = kstrdup - allocate space for and copy an existing string*@s: the string to duplicate*@gfp: the GFP mask used in the kmalloc() call when allocating memory* Return: newly allocated copy of @s or %NULL in case of error
129  If (policy_str == NULL) Then
130  err = -ENOMEM
131  Go to out_free_buf
135  When p != '\0' cycle
138  end = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
139  If (end == NULL) Then
140  err = -EINVAL
141  Go to out_free_buf
143  end = '\0'
145  rule = Allocation memory
146  If Not rule Then
147  err = -ENOMEM
148  Go to out_free_buf
151  err = In the case the input buffer contains one or more invalid UIDs, the kuid_t* variables pointed to by @parent and @child will get updated but this* function will return an error.* Contents of @buf may be modified.
152  If err Then Go to out_free_rule
157  pr_warn("bad policy: duplicate entry\n")
158  err = -EEXIST
159  Go to out_free_rule
162  insert_rule(pol, rule)
163  p = end + 1
164  Continue
166  out_free_rule :
167  kfree(rule)
168  Go to out_free_buf
171  err = verify_ruleset(pol)
173  If err && err != -EINVAL Then Go to out_free_buf
181  mutex_lock( & policy_update_lock)
182  pol = cu_replace_pointer() - replace an RCU pointer, returning its old value*@rcu_ptr: RCU pointer, whose old value is returned*@ptr: regular pointer*@c: the lockdep conditions under which the dereference will take place* Perform a replacement, where @rcu_ptr (safesetid_setuid_rules, pol, lockdep_is_held( & policy_update_lock))
184  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
185  err = len
187  out_free_buf :
188  kfree(buf)
189  out_free_pol :
190  If pol Then release_ruleset(pol)
192  Return err
Caller
NameDescribe
safesetid_file_write