Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:sel_write_user

Proto:static ssize_t sel_write_user(struct file *file, char *buf, size_t size)

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
char *buf
size_tsize
1026  fsi = s_fs_info
1027  state = state
1028  con = NULL , user = NULL
1029  unsigned int sid, * sids = NULL
1035  length = avc_has_perm - Check permissions and perform any appropriate auditing
1039  If length Then Go to out
1042  length = -ENOMEM
1043  con = 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).
1044  If Not con Then Go to out
1047  length = -ENOMEM
1048  user = 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).
1049  If Not user Then Go to out
1052  length = -EINVAL
1053  If sscanf - Unformat a buffer into a list of arguments*@buf: input buffer*@fmt: formatting of buffer*@...: resulting arguments != 2 Then Go to out
1056  length = security_context_str_to_sid(state, con, & sid, GFP_KERNEL)
1057  If length Then Go to out
1060  length = security_get_user_sids(state, sid, user, & sids, & nsids)
1061  If length Then Go to out
1064  length = sprintf(buf, "%u", nsids) + 1
1065  ptr = buf + length
1066  When i < nsids cycle
1067  rc = security_sid_to_context(state, sids[i], & newcon, & len)
1068  If rc Then
1069  length = rc
1070  Go to out
1072  If length + len >= SIMPLE_TRANSACTION_LIMIT Then
1073  kfree(newcon)
1074  length = -ERANGE
1075  Go to out
1077  memcpy(ptr, newcon, len)
1078  kfree(newcon)
1079  ptr += len
1080  length += len
1082  out :
1083  kfree(sids)
1084  kfree(user)
1085  kfree(con)
1086  Return length