Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:map_write

Proto:static ssize_t map_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos, int cap_setid, struct uid_gid_map *map, struct uid_gid_map *parent_map)

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
const char __user *buf
size_tcount
loff_t *ppos
intcap_setid
struct uid_gid_map *map
struct uid_gid_map *parent_map
850  seq = needed for tty driver, and maybe others
851  ns = private
855  kbuf = NULL
859  If ppos != 0 || count >= PAGE_SIZE Then Return -EINVAL
863  kbuf = memdup_user_nul(buf, count)
864  If IS_ERR(kbuf) Then Return PTR_ERR(kbuf)
886  mutex_lock( & userns_state_mutex)
888  memset( & new_map, 0, sizeof(structuid_gid_map))
890  ret = -EPERM
892  If 64 bytes -- 1 cache line != 0 Then Go to out
898  If cap_valid(cap_setid) && Not le_ns_capable - Determine if the file's opener had a capability in effect*@file: The file we want to check*@ns: The usernamespace we want the capability in*@cap: The capability to be tested for* Return true if task that opened the file had a capability in Then Go to out
902  ret = -EINVAL
903  pos = kbuf
904  When pos cycle
907  next_line = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
908  If next_line Then
909  next_line = '\0'
910  next_line++
911  If next_line == '\0' Then next_line = NULL
915  pos = skip_spaces - Removes leading whitespace from @str.*@str: The string to be stripped.* Returns a pointer to the first non-whitespace character in @str.
916  first = simple_strtoul - convert a string to an unsigned long*@cp: The start of the string*@endp: A pointer to the end of the parsed string will be placed here*@base: The number base to use* This function is obsolete. Please use kstrtoul instead.
917  If Not Note: isspace() must return false for %NUL-terminator ( * pos) Then Go to out
920  pos = skip_spaces - Removes leading whitespace from @str.*@str: The string to be stripped.* Returns a pointer to the first non-whitespace character in @str.
921  lower_first = simple_strtoul - convert a string to an unsigned long*@cp: The start of the string*@endp: A pointer to the end of the parsed string will be placed here*@base: The number base to use* This function is obsolete. Please use kstrtoul instead.
922  If Not Note: isspace() must return false for %NUL-terminator ( * pos) Then Go to out
925  pos = skip_spaces - Removes leading whitespace from @str.*@str: The string to be stripped.* Returns a pointer to the first non-whitespace character in @str.
926  count = simple_strtoul - convert a string to an unsigned long*@cp: The start of the string*@endp: A pointer to the end of the parsed string will be placed here*@base: The number base to use* This function is obsolete. Please use kstrtoul instead.
927  If pos && Not Note: isspace() must return false for %NUL-terminator ( * pos) Then Go to out
931  pos = skip_spaces - Removes leading whitespace from @str.*@str: The string to be stripped.* Returns a pointer to the first non-whitespace character in @str.
932  If pos != '\0' Then Go to out
936  If ((first == (u32) - 1) || (lower_first == (u32) - 1)) Then Go to out
943  If first + count <= first Then Go to out
945  If lower_first + count <= lower_first Then Go to out
950  If mappings_overlap( & new_map, & extent) Then Go to out
953  If (( 64 bytes -- 1 cache line + 1) == UID_GID_MAP_MAX_EXTENTS && (next_line != NULL)) Then Go to out
957  ret = sert_extent - Safely insert a new idmap extent into struct uid_gid_map.* Takes care to allocate a 4K block of memory if the number of mappings exceeds* UID_GID_MAP_MAX_BASE_EXTENTS.
958  If ret < 0 Then Go to out
960  ret = -EINVAL
963  If 64 bytes -- 1 cache line == 0 Then Go to out
966  ret = -EPERM
968  If Not new_idmap_permitted(file, ns, cap_setid, & new_map) Then Go to out
971  ret = -EPERM
975  When idx < 64 bytes -- 1 cache line cycle
979  If 64 bytes -- 1 cache line <= UID_GID_MAP_MAX_BASE_EXTENTS Then e = extent[idx]
981  Else e = forward[idx]
984  lower_first = map_id_range_down(parent_map, lower_first, count)
991  If (lower_first == (u32) - 1) Then Go to out
994  lower_first = lower_first
1001  ret = sort_idmaps - Sorts an array of idmap entries.* Can only be called if number of mappings exceeds UID_GID_MAP_MAX_BASE_EXTENTS.
1002  If ret < 0 Then Go to out
1006  If 64 bytes -- 1 cache line <= UID_GID_MAP_MAX_BASE_EXTENTS Then
1007  No 3D Now!(extent, extent, 64 bytes -- 1 cache line * size of extent[0] )
1009  Else
1010  forward = forward
1011  reverse = reverse
1013  smp_wmb()
1014  64 bytes -- 1 cache line = 64 bytes -- 1 cache line
1016  ppos = count
1017  ret = count
1018  out :
1019  If ret < 0 && 64 bytes -- 1 cache line > UID_GID_MAP_MAX_BASE_EXTENTS Then
1020  kfree(forward)
1021  kfree(reverse)
1022  forward = NULL
1023  reverse = NULL
1024  64 bytes -- 1 cache line = 0
1027  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.
1028  kfree(kbuf)
1029  Return ret
Caller
NameDescribe
proc_uid_map_write
proc_gid_map_write
proc_projid_map_write