Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:smk_write_net6addr - 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 net6addr per write call

Proto:static ssize_t smk_write_net6addr(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
1391  struct smack_known * skp = NULL
1394  rc = 0
1395  found = 0
1399  mask = 128
1408  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
1410  If ppos != 0 Then Return -EINVAL
1412  If count < Value for parsing single label host rules* "1.2.3.4 X" Then Return -EINVAL
1415  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.
1416  If IS_ERR(data) Then Return PTR_ERR(data)
1419  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).
1420  If (smack == NULL) Then
1421  rc = -ENOMEM
1422  Go to free_data_out
1425  i = sscanf - Unformat a buffer into a list of arguments*@buf: input buffer*@fmt: formatting of buffer*@...: resulting arguments
1429  If i != 10 Then
1430  i = sscanf - Unformat a buffer into a list of arguments*@buf: input buffer*@fmt: formatting of buffer*@...: resulting arguments
1434  If i != 9 Then
1435  rc = -EINVAL
1436  Go to free_out
1439  If mask > 128 Then
1440  rc = -EINVAL
1441  Go to free_out
1443  When i < 8 cycle
1444  If scanned[i] > 0xffff Then
1445  rc = -EINVAL
1446  Go to free_out
1448  s6_addr16[i] = htons(scanned[i])
1454  If smack[0] != '-' Then
1455  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
1456  If IS_ERR(skp) Then
1457  rc = PTR_ERR(skp)
1458  Go to free_out
1460  Else
1464  If strcmp(smack, SMACK_DELETE_OPTION) != 0 Then
1465  rc = -EINVAL
1466  Go to free_out
1470  When i < 8 cycle
1471  If m >= 16 Then
1472  s6_addr16[i] = 0xffff
1473  m -= 16
1474  Else if m > 0 Then
1475  s6_addr16[i] = (1 << m) - 1
1476  m = 0
1477  Else s6_addr16[i] = 0
1479  s6_addr16[i] &= s6_addr16[i]
1486  mutex_lock( & smk_net6addr_lock)
1491  If mask != mask size Then Continue
1493  When i < 8 cycle
1494  If s6_addr16[i] != s6_addr16[i] Then
1496  found = 0
1497  Break
1500  If found == 1 Then Break
1503  If found == 0 Then
1504  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).
1505  If (snp == NULL) Then rc = -ENOMEM
1507  Else
1510  mask size = mask
1511  label = skp
1514  Else
1515  label = skp
1518  If rc == 0 Then rc = count
1521  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.
1523  free_out :
1524  kfree(smack)
1525  free_data_out :
1526  kfree(data)
1528  Return rc