Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:smk_write_net4addr - write() for /smack/netlabel*@file: file pointer, not actually used*@buf: where to get the data from*@count: bytes sent*@ppos: where to start* Accepts only one net4addr per write call

Proto:static ssize_t smk_write_net4addr(struct file *file, const char __user *buf, size_t count, loff_t *ppos)

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
const char __user *buf
size_tcount
loff_t *ppos
1128  struct smack_known * skp = NULL
1130  char * host = (char * ) & s_addr
1137  mask_bits = 1 << 31
1148  If Not smack_privileged - are all privilege requirements met*@cap: The requested capability* Is the task privileged and allowed to be privileged* by the onlycap rule.* Returns true if the task is allowed to be privileged, false if it's not. Then Return -EPERM
1150  If ppos != 0 Then Return -EINVAL
1152  If count < Value for parsing single label host rules* "1.2.3.4 X" Then Return -EINVAL
1155  data = 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.
1156  If IS_ERR(data) Then Return PTR_ERR(data)
1159  smack = 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).
1160  If (smack == NULL) Then
1161  rc = -ENOMEM
1162  Go to free_data_out
1165  rc = sscanf - Unformat a buffer into a list of arguments*@buf: input buffer*@fmt: formatting of buffer*@...: resulting arguments
1167  If rc != 6 Then
1168  rc = sscanf - Unformat a buffer into a list of arguments*@buf: input buffer*@fmt: formatting of buffer*@...: resulting arguments
1170  If rc != 5 Then
1171  rc = -EINVAL
1172  Go to free_out
1174  m = BEBITS
1175  masks = 32
1177  If masks > BEBITS Then
1178  rc = -EINVAL
1179  Go to free_out
1185  If smack[0] != '-' Then
1186  skp = smk_import_entry - import a label, return the list entry*@string: a text string that might be a Smack label*@len: the maximum size, or zero if it is NULL terminated
1187  If IS_ERR(skp) Then
1188  rc = PTR_ERR(skp)
1189  Go to free_out
1191  Else
1195  If strcmp(smack, SMACK_CIPSO_OPTION) != 0 Then
1196  rc = -EINVAL
1197  Go to free_out
1201  When m > 0 cycle
1202  temp_mask |= mask_bits
1203  mask_bits >>= 1
1205  s_addr = cpu_to_be32(temp_mask)
1207  s_addr &= s_addr
1212  mutex_lock( & smk_net4addr_lock)
1214  nsa = s_addr
1216  found = 0
1218  If s_addr == nsa && mask size == masks Then
1219  found = 1
1220  Break
1223  smk_netlabel_audit_set - fill a netlbl_audit struct*@nap: structure to fill
1225  If found == 0 Then
1226  snp = 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).
1227  If (snp == NULL) Then rc = -ENOMEM
1229  Else
1230  rc = 0
1231  s_addr = s_addr
1232  s_addr = s_addr
1233  label = skp
1234  mask size = masks
1237  Else
1242  If (label != NULL) Then rc = netlbl_cfg_unlbl_static_del( & init_net, NULL, & work address , & work mask , PF_INET, & audit_info)
1246  Else rc = 0
1248  label = skp
1256  If (rc == 0 && skp != NULL) Then rc = netlbl_cfg_unlbl_static_add( & init_net, NULL, & work address , & work mask , PF_INET, smk_secid, & audit_info)
1261  If rc == 0 Then rc = count
1264  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.
1266  free_out :
1267  kfree(smack)
1268  free_data_out :
1269  kfree(data)
1271  Return rc