Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\fork.c Create Date:2022-07-28 08:59:01
Last Modify:2020-03-17 11:04:53 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:share allows a process to 'unshare' part of the process* context which was originally shared using clone. copy_** functions used by do_fork() cannot be used here directly* because they modify an inactive task_struct that is being* constructed

Proto:int ksys_unshare(unsigned long unshare_flags)

Type:int

Parameter:

TypeParameterName
unsigned longunshare_flags
2897  struct fs_struct * fs, * new_fs = NULL
2898  struct files_struct * fd, * new_fd = NULL
2899  struct cred * new_cred = NULL
2900  struct nsproxy * new_nsproxy = NULL
2901  do_sysvsem = 0
2908  If unshare_flags & New user namespace Then unshare_flags |= Same thread group | set if fs info shared between processes
2913  If unshare_flags & set if VM shared between processes Then unshare_flags |= set if signal handlers and blocked signals shared
2918  If unshare_flags & set if signal handlers and blocked signals shared Then unshare_flags |= Same thread group
2923  If unshare_flags & New mount namespace group Then unshare_flags |= set if fs info shared between processes
2926  err = Check constraints on flags passed to the unshare system call.
2927  If err Then Go to bad_unshare_out
2934  If unshare_flags & (New ipc namespace | share system V SEM_UNDO semantics ) Then do_sysvsem = 1
2936  err = Unshare the filesystem structure if it is being shared
2937  If err Then Go to bad_unshare_out
2939  err = Unshare file descriptor table if it is being shared
2940  If err Then Go to bad_unshare_cleanup_fs
2942  err = unshare_userns(unshare_flags, & new_cred)
2943  If err Then Go to bad_unshare_cleanup_fd
2945  err = unshare_nsproxy_namespaces(unshare_flags, & new_nsproxy, new_cred, new_fs)
2947  If err Then Go to bad_unshare_cleanup_cred
2950  If new_fs || new_fd || do_sysvsem || new_cred || new_nsproxy Then
2951  If do_sysvsem Then
2963  If new_nsproxy Then switch_task_namespaces(current process, new_nsproxy)
2966  Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring* subscriptions and synchronises with wait4(). Also used in procfs. Also* pins the final release of task.io_context. Also protects ->cpuset and* ->cgroup.subsys[]. And ->vfork_done.
2968  If new_fs Then
2969  fs = fs
2970  spin_lock( & lock)
2971  fs = new_fs
2972  If --users Then new_fs = NULL
2974  Else new_fs = fs
2976  spin_unlock( & lock)
2979  If new_fd Then
2980  fd = files
2981  files = new_fd
2982  new_fd = fd
2985  task_unlock(current process)
2987  If new_cred Then
2990  new_cred = NULL
2994  perf_event_namespaces(current process)
2996  bad_unshare_cleanup_cred :
2997  If new_cred Then put_cred - Release a reference to a set of credentials*@cred: The credentials to release* Release a reference to a set of credentials, deleting them when the last ref* is released
2999  bad_unshare_cleanup_fd :
3000  If new_fd Then put_files_struct(new_fd)
3003  bad_unshare_cleanup_fs :
3004  If new_fs Then free_fs_struct(new_fs)
3007  bad_unshare_out :
3008  Return err
Caller
NameDescribe
SYSCALL_DEFINE1