Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Clark
linux
Commits
3c041184
Commit
3c041184
authored
10 years ago
by
Al Viro
Browse files
Options
Downloads
Patches
Plain Diff
switch the rest of proc_ns_operations to working with &...->ns
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
ff24870f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ipc/namespace.c
+9
-6
9 additions, 6 deletions
ipc/namespace.c
kernel/pid_namespace.c
+9
-5
9 additions, 5 deletions
kernel/pid_namespace.c
kernel/user_namespace.c
+9
-5
9 additions, 5 deletions
kernel/user_namespace.c
kernel/utsname.c
+9
-6
9 additions, 6 deletions
kernel/utsname.c
with
36 additions
and
22 deletions
ipc/namespace.c
+
9
−
6
View file @
3c041184
...
@@ -149,6 +149,11 @@ void put_ipc_ns(struct ipc_namespace *ns)
...
@@ -149,6 +149,11 @@ void put_ipc_ns(struct ipc_namespace *ns)
}
}
}
}
static
inline
struct
ipc_namespace
*
to_ipc_ns
(
struct
ns_common
*
ns
)
{
return
container_of
(
ns
,
struct
ipc_namespace
,
ns
);
}
static
void
*
ipcns_get
(
struct
task_struct
*
task
)
static
void
*
ipcns_get
(
struct
task_struct
*
task
)
{
{
struct
ipc_namespace
*
ns
=
NULL
;
struct
ipc_namespace
*
ns
=
NULL
;
...
@@ -160,17 +165,17 @@ static void *ipcns_get(struct task_struct *task)
...
@@ -160,17 +165,17 @@ static void *ipcns_get(struct task_struct *task)
ns
=
get_ipc_ns
(
nsproxy
->
ipc_ns
);
ns
=
get_ipc_ns
(
nsproxy
->
ipc_ns
);
task_unlock
(
task
);
task_unlock
(
task
);
return
ns
;
return
ns
?
&
ns
->
ns
:
NULL
;
}
}
static
void
ipcns_put
(
void
*
ns
)
static
void
ipcns_put
(
void
*
ns
)
{
{
return
put_ipc_ns
(
ns
);
return
put_ipc_ns
(
to_ipc_ns
(
ns
)
);
}
}
static
int
ipcns_install
(
struct
nsproxy
*
nsproxy
,
void
*
new
)
static
int
ipcns_install
(
struct
nsproxy
*
nsproxy
,
void
*
new
)
{
{
struct
ipc_namespace
*
ns
=
new
;
struct
ipc_namespace
*
ns
=
to_ipc_ns
(
new
)
;
if
(
!
ns_capable
(
ns
->
user_ns
,
CAP_SYS_ADMIN
)
||
if
(
!
ns_capable
(
ns
->
user_ns
,
CAP_SYS_ADMIN
)
||
!
ns_capable
(
current_user_ns
(),
CAP_SYS_ADMIN
))
!
ns_capable
(
current_user_ns
(),
CAP_SYS_ADMIN
))
return
-
EPERM
;
return
-
EPERM
;
...
@@ -184,9 +189,7 @@ static int ipcns_install(struct nsproxy *nsproxy, void *new)
...
@@ -184,9 +189,7 @@ static int ipcns_install(struct nsproxy *nsproxy, void *new)
static
unsigned
int
ipcns_inum
(
void
*
vp
)
static
unsigned
int
ipcns_inum
(
void
*
vp
)
{
{
struct
ipc_namespace
*
ns
=
vp
;
return
((
struct
ns_common
*
)
vp
)
->
inum
;
return
ns
->
ns
.
inum
;
}
}
const
struct
proc_ns_operations
ipcns_operations
=
{
const
struct
proc_ns_operations
ipcns_operations
=
{
...
...
This diff is collapsed.
Click to expand it.
kernel/pid_namespace.c
+
9
−
5
View file @
3c041184
...
@@ -313,6 +313,11 @@ int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
...
@@ -313,6 +313,11 @@ int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
return
0
;
return
0
;
}
}
static
inline
struct
pid_namespace
*
to_pid_ns
(
struct
ns_common
*
ns
)
{
return
container_of
(
ns
,
struct
pid_namespace
,
ns
);
}
static
void
*
pidns_get
(
struct
task_struct
*
task
)
static
void
*
pidns_get
(
struct
task_struct
*
task
)
{
{
struct
pid_namespace
*
ns
;
struct
pid_namespace
*
ns
;
...
@@ -323,18 +328,18 @@ static void *pidns_get(struct task_struct *task)
...
@@ -323,18 +328,18 @@ static void *pidns_get(struct task_struct *task)
get_pid_ns
(
ns
);
get_pid_ns
(
ns
);
rcu_read_unlock
();
rcu_read_unlock
();
return
ns
;
return
ns
?
&
ns
->
ns
:
NULL
;
}
}
static
void
pidns_put
(
void
*
ns
)
static
void
pidns_put
(
void
*
ns
)
{
{
put_pid_ns
(
ns
);
put_pid_ns
(
to_pid_ns
(
ns
)
);
}
}
static
int
pidns_install
(
struct
nsproxy
*
nsproxy
,
void
*
ns
)
static
int
pidns_install
(
struct
nsproxy
*
nsproxy
,
void
*
ns
)
{
{
struct
pid_namespace
*
active
=
task_active_pid_ns
(
current
);
struct
pid_namespace
*
active
=
task_active_pid_ns
(
current
);
struct
pid_namespace
*
ancestor
,
*
new
=
ns
;
struct
pid_namespace
*
ancestor
,
*
new
=
to_pid_ns
(
ns
)
;
if
(
!
ns_capable
(
new
->
user_ns
,
CAP_SYS_ADMIN
)
||
if
(
!
ns_capable
(
new
->
user_ns
,
CAP_SYS_ADMIN
)
||
!
ns_capable
(
current_user_ns
(),
CAP_SYS_ADMIN
))
!
ns_capable
(
current_user_ns
(),
CAP_SYS_ADMIN
))
...
@@ -364,8 +369,7 @@ static int pidns_install(struct nsproxy *nsproxy, void *ns)
...
@@ -364,8 +369,7 @@ static int pidns_install(struct nsproxy *nsproxy, void *ns)
static
unsigned
int
pidns_inum
(
void
*
ns
)
static
unsigned
int
pidns_inum
(
void
*
ns
)
{
{
struct
pid_namespace
*
pid_ns
=
ns
;
return
((
struct
ns_common
*
)
ns
)
->
inum
;
return
pid_ns
->
ns
.
inum
;
}
}
const
struct
proc_ns_operations
pidns_operations
=
{
const
struct
proc_ns_operations
pidns_operations
=
{
...
...
This diff is collapsed.
Click to expand it.
kernel/user_namespace.c
+
9
−
5
View file @
3c041184
...
@@ -841,6 +841,11 @@ static bool new_idmap_permitted(const struct file *file,
...
@@ -841,6 +841,11 @@ static bool new_idmap_permitted(const struct file *file,
return
false
;
return
false
;
}
}
static
inline
struct
user_namespace
*
to_user_ns
(
struct
ns_common
*
ns
)
{
return
container_of
(
ns
,
struct
user_namespace
,
ns
);
}
static
void
*
userns_get
(
struct
task_struct
*
task
)
static
void
*
userns_get
(
struct
task_struct
*
task
)
{
{
struct
user_namespace
*
user_ns
;
struct
user_namespace
*
user_ns
;
...
@@ -849,17 +854,17 @@ static void *userns_get(struct task_struct *task)
...
@@ -849,17 +854,17 @@ static void *userns_get(struct task_struct *task)
user_ns
=
get_user_ns
(
__task_cred
(
task
)
->
user_ns
);
user_ns
=
get_user_ns
(
__task_cred
(
task
)
->
user_ns
);
rcu_read_unlock
();
rcu_read_unlock
();
return
user_ns
;
return
user_ns
?
&
user_ns
->
ns
:
NULL
;
}
}
static
void
userns_put
(
void
*
ns
)
static
void
userns_put
(
void
*
ns
)
{
{
put_user_ns
(
ns
);
put_user_ns
(
to_user_ns
(
ns
)
);
}
}
static
int
userns_install
(
struct
nsproxy
*
nsproxy
,
void
*
ns
)
static
int
userns_install
(
struct
nsproxy
*
nsproxy
,
void
*
ns
)
{
{
struct
user_namespace
*
user_ns
=
ns
;
struct
user_namespace
*
user_ns
=
to_user_ns
(
ns
)
;
struct
cred
*
cred
;
struct
cred
*
cred
;
/* Don't allow gaining capabilities by reentering
/* Don't allow gaining capabilities by reentering
...
@@ -890,8 +895,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
...
@@ -890,8 +895,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
static
unsigned
int
userns_inum
(
void
*
ns
)
static
unsigned
int
userns_inum
(
void
*
ns
)
{
{
struct
user_namespace
*
user_ns
=
ns
;
return
((
struct
ns_common
*
)
ns
)
->
inum
;
return
user_ns
->
ns
.
inum
;
}
}
const
struct
proc_ns_operations
userns_operations
=
{
const
struct
proc_ns_operations
userns_operations
=
{
...
...
This diff is collapsed.
Click to expand it.
kernel/utsname.c
+
9
−
6
View file @
3c041184
...
@@ -88,6 +88,11 @@ void free_uts_ns(struct kref *kref)
...
@@ -88,6 +88,11 @@ void free_uts_ns(struct kref *kref)
kfree
(
ns
);
kfree
(
ns
);
}
}
static
inline
struct
uts_namespace
*
to_uts_ns
(
struct
ns_common
*
ns
)
{
return
container_of
(
ns
,
struct
uts_namespace
,
ns
);
}
static
void
*
utsns_get
(
struct
task_struct
*
task
)
static
void
*
utsns_get
(
struct
task_struct
*
task
)
{
{
struct
uts_namespace
*
ns
=
NULL
;
struct
uts_namespace
*
ns
=
NULL
;
...
@@ -101,17 +106,17 @@ static void *utsns_get(struct task_struct *task)
...
@@ -101,17 +106,17 @@ static void *utsns_get(struct task_struct *task)
}
}
task_unlock
(
task
);
task_unlock
(
task
);
return
ns
;
return
ns
?
&
ns
->
ns
:
NULL
;
}
}
static
void
utsns_put
(
void
*
ns
)
static
void
utsns_put
(
void
*
ns
)
{
{
put_uts_ns
(
ns
);
put_uts_ns
(
to_uts_ns
(
ns
)
);
}
}
static
int
utsns_install
(
struct
nsproxy
*
nsproxy
,
void
*
new
)
static
int
utsns_install
(
struct
nsproxy
*
nsproxy
,
void
*
new
)
{
{
struct
uts_namespace
*
ns
=
new
;
struct
uts_namespace
*
ns
=
to_uts_ns
(
new
)
;
if
(
!
ns_capable
(
ns
->
user_ns
,
CAP_SYS_ADMIN
)
||
if
(
!
ns_capable
(
ns
->
user_ns
,
CAP_SYS_ADMIN
)
||
!
ns_capable
(
current_user_ns
(),
CAP_SYS_ADMIN
))
!
ns_capable
(
current_user_ns
(),
CAP_SYS_ADMIN
))
...
@@ -125,9 +130,7 @@ static int utsns_install(struct nsproxy *nsproxy, void *new)
...
@@ -125,9 +130,7 @@ static int utsns_install(struct nsproxy *nsproxy, void *new)
static
unsigned
int
utsns_inum
(
void
*
vp
)
static
unsigned
int
utsns_inum
(
void
*
vp
)
{
{
struct
uts_namespace
*
ns
=
vp
;
return
((
struct
ns_common
*
)
vp
)
->
inum
;
return
ns
->
ns
.
inum
;
}
}
const
struct
proc_ns_operations
utsns_operations
=
{
const
struct
proc_ns_operations
utsns_operations
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment