Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:sel_open_policy

Proto:static int sel_open_policy(struct inode *inode, struct file *filp)

Type:int

Parameter:

TypeParameterName
struct inode *inode
struct file *filp
375  fsi = s_fs_info
376  state = state
377  struct policy_load_memory * plm = NULL
380  BUG_ON( needed for tty driver, and maybe others )
382  mutex_lock( & mutex)
384  rc = avc_has_perm - Check permissions and perform any appropriate auditing
387  If rc Then Go to err
390  rc = -EBUSY
391  If policy_opened Then Go to err
394  rc = -ENOMEM
395  plm = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
396  If Not plm Then Go to err
399  If NOTE: in a 32bit arch with a preemptable kernel and* an UP compile the i_size_read/write must be atomic* with respect to the local cpu (unlike with preempt disabled),* but they don't need to be atomic with respect to other cpus like in* true SMP (so they != security_policydb_len(state) Then
400  inode_lock(inode)
401  NOTE: unlike i_size_read(), i_size_write() does need locking around it* (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount* can be lost, resulting in subsequent i_size_read() calls spinning forever.
402  inode_unlock(inode)
405  rc = security_read_policy(state, & data, & len)
406  If rc Then Go to err
409  policy_opened = 1
411  needed for tty driver, and maybe others = plm
413  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.
415  Return 0
416  err :
417  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.
419  If plm Then vfree(data)
421  kfree(plm)
422  Return rc