Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:getsecurity: We are called for security

Proto:int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer, bool alloc)

Type:int

Parameter:

TypeParameterName
struct inode *inode
const char *name
void **buffer
boolalloc
375  char * tmpbuf = NULL
381  If strcmp(name, "capability") != 0 Then Return -EOPNOTSUPP
384  dentry = d_find_any_alias(inode)
385  If Not dentry Then Return -EINVAL
388  size = sizeof(structvfs_ns_cap_data)
389  ret = vfs_getxattr_alloc(dentry, XATTR_NAME_CAPS, & tmpbuf, size, GFP_NOFS)
391  dput(dentry)
393  If ret < 0 Then Return ret
396  fs_ns = s_user_ns
397  cap = tmpbuf
398  If is_v2header((size_t)ret, cap) Then
401  If alloc Then buffer = tmpbuf
403  Else kfree(tmpbuf)
405  Return ret
406  Else if Not is_v3header((size_t)ret, cap) Then
407  kfree(tmpbuf)
408  Return -EINVAL
411  nscap = tmpbuf
412  root = le32_to_cpu(rootid)
413  kroot = make_kuid - Map a user-namespace uid pair into a kuid
417  mappedroot = 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.
418  If (mappedroot != (uid_t) - 1 && mappedroot != (uid_t)0) Then
419  If alloc Then
420  buffer = tmpbuf
422  Else kfree(tmpbuf)
424  Return size
427  If Not rootid_owns_currentns(kroot) Then
428  kfree(tmpbuf)
429  Return -EOPNOTSUPP
433  size = sizeof(structvfs_cap_data)
434  If alloc Then
435  buffer = Allocation memory
436  If buffer Then
437  cap = buffer
443  memcpy( & data, & data, sizeof(__le32) * 2 * VFS_CAP_U32)
445  Else
446  size = -ENOMEM
449  kfree(tmpbuf)
450  Return size