Skip to content

Commit f2bf456

Browse files
committed
get related pid namespace from a pid in the related pid namespace
Signed-off-by: YangKeao <[email protected]>
1 parent e468ada commit f2bf456

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

driver/ioem.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -911,14 +911,14 @@ static struct {
911911
.version = ATOMIC_INIT(0),
912912
};
913913

914-
static int ioem_get_pid_ns_inode_from_pid(unsigned int pid_nr, unsigned int* out)
914+
static int ioem_get_pid_ns_inode_from_pid(unsigned int pid_nr, struct pid_namespace* pid_ns, unsigned int* out)
915915
{
916916
int ret = 0;
917917
struct pid *pid;
918918
struct task_struct* task;
919919
struct pid_namespace* ns;
920920

921-
pid = find_vpid(pid_nr);
921+
pid = find_pid_ns(pid_nr, pid_ns);
922922
if (pid) {
923923
get_pid(pid);
924924
} else {
@@ -976,14 +976,17 @@ int build_ioem_injection(unsigned long id, struct chaos_injection * injection)
976976

977977
ioem_injection->arg.device = new_decode_dev(ioem_injection->arg.device);
978978
if (ioem_injection->arg.pid_ns != 0) {
979-
unsigned int ns;
979+
unsigned int ns_inode;
980+
struct pid_namespace* pid_ns = get_pid_ns(task_active_pid_ns(current));
981+
982+
ret = ioem_get_pid_ns_inode_from_pid(ioem_injection->arg.pid_ns, pid_ns, &ns_inode);
983+
put_pid_ns(pid_ns);
980984

981-
ret = ioem_get_pid_ns_inode_from_pid(ioem_injection->arg.pid_ns, &ns);
982985
if (ret > 0) {
983986
goto free_matcher_arg;
984987
}
985988

986-
ioem_injection->arg.pid_ns = ns;
989+
ioem_injection->arg.pid_ns = ns_inode;
987990
}
988991

989992
ioem_injection->injector_type = injection->injector_type;

0 commit comments

Comments
 (0)