Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:sel_write_create

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

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
char *buf
size_tsize
861  fsi = s_fs_info
862  state = state
863  char * scon = NULL, * tcon = NULL
864  char * namebuf = NULL, * objname = NULL
868  char * newcon = NULL
872  length = avc_has_perm - Check permissions and perform any appropriate auditing
876  If length Then Go to out
879  length = -ENOMEM
880  scon = 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).
881  If Not scon Then Go to out
884  length = -ENOMEM
885  tcon = 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).
886  If Not tcon Then Go to out
889  length = -ENOMEM
890  namebuf = 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).
891  If Not namebuf Then Go to out
894  length = -EINVAL
895  nargs = sscanf - Unformat a buffer into a list of arguments*@buf: input buffer*@fmt: formatting of buffer*@...: resulting arguments
896  If nargs < 3 || nargs > 4 Then Go to out
898  If nargs == 4 Then
909  r = w = namebuf
910  Do
911  c1 = r++
912  If c1 == '+' Then c1 = ' '
914  Else if c1 == '%' Then
923  w++ = c1
924  When c1 != '\0' cycle
926  objname = namebuf
929  length = security_context_str_to_sid(state, scon, & ssid, GFP_KERNEL)
930  If length Then Go to out
933  length = security_context_str_to_sid(state, tcon, & tsid, GFP_KERNEL)
934  If length Then Go to out
937  length = security_transition_sid_user(state, ssid, tsid, tclass, objname, & newsid)
939  If length Then Go to out
942  length = security_sid_to_context(state, newsid, & newcon, & len)
943  If length Then Go to out
946  length = -ERANGE
947  If len > SIMPLE_TRANSACTION_LIMIT Then
948  pr_err("SELinux: %s: context size (%u) exceeds payload max\n", __func__, len)
950  Go to out
953  memcpy(buf, newcon, len)
954  length = len
955  out :
956  kfree(newcon)
957  kfree(namebuf)
958  kfree(tcon)
959  kfree(scon)
960  Return length