Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:User requested a write of security.capability. If needed, update the* xattr to change from v2 to v3, or to fixup the v3 rootid.* If all is ok, we return the new size, on error return < 0.

Proto:int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size)

Type:int

Parameter:

TypeParameterName
struct dentry *dentry
void **ivalue
size_tsize
480  cap = ivalue
482  inode = d_backing_inode - Get upper or lower inode we should be using*@upper: The upper layer* This is the helper that should be used to get at the inode that will be used* if this dentry were to be opened as a file. The inode may be on the upper
483  task_ns = current_user_ns() , fs_ns = s_user_ns
488  If Not ivalue Then Return -EINVAL
490  If Not validheader(size, cap) Then Return -EINVAL
492  If Not apable_wrt_inode_uidgid - Check nsown_capable and uid and gid mapped*@inode: The inode in question*@cap: The capability in question* Return true if the current task has the given capability targeted at* its own user namespace and that the given inode's Then Return -EPERM
494  If size == XATTR_CAPS_SZ_2 Then If ns_capable(s_user_ns, CAP_SETFCAP) Then
497  Return size
499  rootid = rootid_from_xattr( * ivalue, size, task_ns)
500  If Not uid_valid(rootid) Then Return -EINVAL
503  nsrootid = m_kuid - Create a uid from a kuid user-namespace pair.*@targ: The user namespace we want a uid in.*@kuid: The kernel internal uid to start with.* Map @kuid into the user-namespace specified by @targ and* return the resulting uid.
504  If nsrootid == -1 Then Return -EINVAL
507  newsize = sizeof(structvfs_ns_cap_data)
508  nscap = Allocation memory
509  If Not nscap Then Return -ENOMEM
511  rootid = cpu_to_le32(nsrootid)
512  nsmagic = VFS_CAP_REVISION_3
513  magic = le32_to_cpu( Little endian )
514  If magic & VFS_CAP_FLAGS_EFFECTIVE Then nsmagic |= VFS_CAP_FLAGS_EFFECTIVE
516  magic_etc = cpu_to_le32(nsmagic)
517  memcpy( & data, & data, sizeof(__le32) * 2 * VFS_CAP_U32)
519  kvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
520  ivalue = nscap
521  Return newsize