Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
a00ef142
Commit
a00ef142
authored
Sep 30, 2011
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use pr_err for error printing
To follow kernel style Signed-off-by:
Cyrill Gorcunov
<
gorcunov@gmail.com
>
parent
f83520aa
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
55 deletions
+55
-55
cr-dump.c
cr-dump.c
+19
-19
cr-restore.c
cr-restore.c
+11
-11
cr-show.c
cr-show.c
+2
-2
crtools.c
crtools.c
+1
-1
elf.c
elf.c
+2
-2
util.h
include/util.h
+7
-7
parasite-syscall.c
parasite-syscall.c
+10
-10
util.c
util.c
+3
-3
No files found.
cr-dump.c
View file @
a00ef142
...
@@ -91,7 +91,7 @@ err:
...
@@ -91,7 +91,7 @@ err:
return
ret
;
return
ret
;
err_bogus_mapping:
err_bogus_mapping:
pr_err
or
(
"Bogus mapping %lx-%lx
\n
"
,
pr_err
(
"Bogus mapping %lx-%lx
\n
"
,
vma_area
->
vma
.
start
,
vma_area
->
vma
.
start
,
vma_area
->
vma
.
end
);
vma_area
->
vma
.
end
);
goto
err
;
goto
err
;
...
@@ -156,7 +156,7 @@ static int dump_pipe_and_data(int lfd, struct pipe_entry *e,
...
@@ -156,7 +156,7 @@ static int dump_pipe_and_data(int lfd, struct pipe_entry *e,
pipe_size
=
fcntl
(
lfd
,
F_GETPIPE_SZ
);
pipe_size
=
fcntl
(
lfd
,
F_GETPIPE_SZ
);
if
(
pipe_size
<
0
)
{
if
(
pipe_size
<
0
)
{
pr_err
or
(
"Can't obtain piped data size
\n
"
);
pr_err
(
"Can't obtain piped data size
\n
"
);
goto
err
;
goto
err
;
}
}
...
@@ -215,7 +215,7 @@ err:
...
@@ -215,7 +215,7 @@ err:
pr_info
(
"Dumped pipe: fd: %8lx pipeid: %8lx flags: %8lx bytes: %8lx
\n
"
,
pr_info
(
"Dumped pipe: fd: %8lx pipeid: %8lx flags: %8lx bytes: %8lx
\n
"
,
e
.
fd
,
e
.
pipeid
,
e
.
flags
,
e
.
bytes
);
e
.
fd
,
e
.
pipeid
,
e
.
flags
,
e
.
bytes
);
else
else
pr_err
or
(
"Dumping pipe %d/%x flags %x
\n
"
,
fd
,
id
,
flags
);
pr_err
(
"Dumping pipe %d/%x flags %x
\n
"
,
fd
,
id
,
flags
);
return
ret
;
return
ret
;
}
}
...
@@ -273,7 +273,7 @@ static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long p
...
@@ -273,7 +273,7 @@ static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long p
return
0
;
return
0
;
}
}
pr_err
or
(
"Can't dump file %s of that type [%x]
\n
"
,
fd_name
,
st_buf
.
st_mode
);
pr_err
(
"Can't dump file %s of that type [%x]
\n
"
,
fd_name
,
st_buf
.
st_mode
);
return
1
;
return
1
;
}
}
...
@@ -436,7 +436,7 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size)
...
@@ -436,7 +436,7 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size)
int
ret
=
-
1
;
int
ret
=
-
1
;
if
(
size
!=
GDT_ENTRY_TLS_ENTRIES
)
{
if
(
size
!=
GDT_ENTRY_TLS_ENTRIES
)
{
pr_err
or
(
"Wrong TLS storage size: %d
\n
"
,
size
);
pr_err
(
"Wrong TLS storage size: %d
\n
"
,
size
);
goto
err
;
goto
err
;
}
}
...
@@ -451,12 +451,12 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size)
...
@@ -451,12 +451,12 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size)
while
(
fgets
(
loc_buf
,
sizeof
(
loc_buf
),
file
))
{
while
(
fgets
(
loc_buf
,
sizeof
(
loc_buf
),
file
))
{
u32
a
,
b
;
u32
a
,
b
;
if
(
sscanf
(
loc_buf
,
"%x %x"
,
&
a
,
&
b
)
!=
2
)
{
if
(
sscanf
(
loc_buf
,
"%x %x"
,
&
a
,
&
b
)
!=
2
)
{
pr_err
or
(
"Can't parse tls entry: %s
\n
"
);
pr_err
(
"Can't parse tls entry: %s
\n
"
);
ret
=
-
1
;
ret
=
-
1
;
goto
err
;
goto
err
;
}
}
if
(
ret
>=
GDT_ENTRY_TLS_ENTRIES
)
{
if
(
ret
>=
GDT_ENTRY_TLS_ENTRIES
)
{
pr_err
or
(
"Too many entries in tls
\n
"
);
pr_err
(
"Too many entries in tls
\n
"
);
ret
=
-
1
;
ret
=
-
1
;
goto
err
;
goto
err
;
}
}
...
@@ -467,7 +467,7 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size)
...
@@ -467,7 +467,7 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size)
}
}
if
(
ret
!=
GDT_ENTRY_TLS_ENTRIES
)
{
if
(
ret
!=
GDT_ENTRY_TLS_ENTRIES
)
{
pr_err
or
(
"tls returened %i entries instead of %i
\n
"
,
pr_err
(
"tls returened %i entries instead of %i
\n
"
,
ret
,
GDT_ENTRY_TLS_ENTRIES
);
ret
,
GDT_ENTRY_TLS_ENTRIES
);
ret
=
-
1
;
ret
=
-
1
;
goto
err
;
goto
err
;
...
@@ -606,7 +606,7 @@ static struct pstree_item *find_children(pid_t pid)
...
@@ -606,7 +606,7 @@ static struct pstree_item *find_children(pid_t pid)
fclose
(
file
),
file
=
NULL
;
fclose
(
file
),
file
=
NULL
;
if
(
!
found
)
{
if
(
!
found
)
{
pr_err
or
(
"Children marker is not found
\n
"
);
pr_err
(
"Children marker is not found
\n
"
);
goto
err
;
goto
err
;
}
}
...
@@ -842,63 +842,63 @@ static int dump_one_task(pid_t pid, struct cr_fdset *cr_fdset)
...
@@ -842,63 +842,63 @@ static int dump_one_task(pid_t pid, struct cr_fdset *cr_fdset)
ret
=
collect_mappings
(
pid
);
ret
=
collect_mappings
(
pid
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Collect mappings (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
pr_err
(
"Collect mappings (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
goto
err
;
goto
err
;
}
}
ret
=
seize_task
(
pid
);
ret
=
seize_task
(
pid
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Failed to seize task (pid: %d) with %d
\n
"
,
pr_err
(
"Failed to seize task (pid: %d) with %d
\n
"
,
pid
,
ret
);
pid
,
ret
);
goto
err
;
goto
err
;
}
}
ret
=
dump_task_core_seized
(
pid
,
cr_fdset
);
ret
=
dump_task_core_seized
(
pid
,
cr_fdset
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Dump core (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
pr_err
(
"Dump core (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
goto
err
;
goto
err
;
}
}
parasite_ctl
=
parasite_infect_seized
(
pid
,
NULL
,
&
vma_area_list
);
parasite_ctl
=
parasite_infect_seized
(
pid
,
NULL
,
&
vma_area_list
);
if
(
!
parasite_ctl
)
{
if
(
!
parasite_ctl
)
{
pr_err
or
(
"Can't infect (pid: %d) with parasite
\n
"
,
pid
);
pr_err
(
"Can't infect (pid: %d) with parasite
\n
"
,
pid
);
goto
err
;
goto
err
;
}
}
ret
=
parasite_dump_pages_seized
(
parasite_ctl
,
&
vma_area_list
,
ret
=
parasite_dump_pages_seized
(
parasite_ctl
,
&
vma_area_list
,
cr_fdset
,
CR_FD_PAGES
);
cr_fdset
,
CR_FD_PAGES
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Can't dump pages (pid: %d) with parasite
\n
"
,
pid
);
pr_err
(
"Can't dump pages (pid: %d) with parasite
\n
"
,
pid
);
goto
err
;
goto
err
;
}
}
ret
=
parasite_cure_seized
(
&
parasite_ctl
,
&
vma_area_list
);
ret
=
parasite_cure_seized
(
&
parasite_ctl
,
&
vma_area_list
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Can't cure (pid: %d) from parasite
\n
"
,
pid
);
pr_err
(
"Can't cure (pid: %d) from parasite
\n
"
,
pid
);
goto
err
;
goto
err
;
}
}
ret
=
unseize_task
(
pid
);
ret
=
unseize_task
(
pid
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Can't unsieze (pid: %d) task
\n
"
,
pid
);
pr_err
(
"Can't unsieze (pid: %d) task
\n
"
,
pid
);
goto
err
;
goto
err
;
}
}
ret
=
dump_task_files
(
pid
,
cr_fdset
);
ret
=
dump_task_files
(
pid
,
cr_fdset
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Dump files (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
pr_err
(
"Dump files (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
goto
err
;
goto
err
;
}
}
ret
=
dump_task_mappings
(
pid
,
cr_fdset
);
ret
=
dump_task_mappings
(
pid
,
cr_fdset
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Dump mappings (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
pr_err
(
"Dump mappings (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
goto
err
;
goto
err
;
}
}
ret
=
finalize_core
(
pid
,
cr_fdset
);
ret
=
finalize_core
(
pid
,
cr_fdset
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
or
(
"Finalizing core (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
pr_err
(
"Finalizing core (pid: %d) failed with %d
\n
"
,
pid
,
ret
);
goto
err
;
goto
err
;
}
}
...
...
cr-restore.c
View file @
a00ef142
...
@@ -184,7 +184,7 @@ static int collect_shmem(int pid, struct shmem_entry *e)
...
@@ -184,7 +184,7 @@ static int collect_shmem(int pid, struct shmem_entry *e)
continue
;
continue
;
if
(
shmems
[
i
].
end
!=
e
->
end
)
{
if
(
shmems
[
i
].
end
!=
e
->
end
)
{
pr_err
or
(
"Bogus shmem
\n
"
);
pr_err
(
"Bogus shmem
\n
"
);
return
1
;
return
1
;
}
}
...
@@ -270,7 +270,7 @@ static int collect_pipe(int pid, struct pipe_entry *e, int p_fd)
...
@@ -270,7 +270,7 @@ static int collect_pipe(int pid, struct pipe_entry *e, int p_fd)
pipes
[
nr_pipes
].
status
=
PIPE_WRONLY
;
pipes
[
nr_pipes
].
status
=
PIPE_WRONLY
;
break
;
break
;
default:
default:
pr_err
or
(
"%d: Unknown pipe status pipeid %d
\n
"
,
pr_err
(
"%d: Unknown pipe status pipeid %d
\n
"
,
pid
,
e
->
pipeid
);
pid
,
e
->
pipeid
);
break
;
break
;
}
}
...
@@ -437,7 +437,7 @@ static int open_fe_fd(struct fdinfo_entry *fe, int fd)
...
@@ -437,7 +437,7 @@ static int open_fe_fd(struct fdinfo_entry *fe, int fd)
int
tmp
;
int
tmp
;
if
(
read
(
fd
,
path
,
fe
->
len
)
!=
fe
->
len
)
{
if
(
read
(
fd
,
path
,
fe
->
len
)
!=
fe
->
len
)
{
pr_err
or
(
"Error reading path"
);
pr_err
(
"Error reading path"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -518,7 +518,7 @@ static int prepare_fds(int pid)
...
@@ -518,7 +518,7 @@ static int prepare_fds(int pid)
read
(
fdinfo_fd
,
&
mag
,
4
);
read
(
fdinfo_fd
,
&
mag
,
4
);
if
(
mag
!=
FDINFO_MAGIC
)
{
if
(
mag
!=
FDINFO_MAGIC
)
{
pr_err
or
(
"Bad file magic number in %s
\n
"
,
path
);
pr_err
(
"Bad file magic number in %s
\n
"
,
path
);
return
1
;
return
1
;
}
}
...
@@ -538,7 +538,7 @@ static int prepare_fds(int pid)
...
@@ -538,7 +538,7 @@ static int prepare_fds(int pid)
}
}
if
(
ret
!=
sizeof
(
fe
))
{
if
(
ret
!=
sizeof
(
fe
))
{
pr_err
or
(
"Corrupted file %s
\n
"
,
path
);
pr_err
(
"Corrupted file %s
\n
"
,
path
);
return
1
;
return
1
;
}
}
...
@@ -554,7 +554,7 @@ static int prepare_fds(int pid)
...
@@ -554,7 +554,7 @@ static int prepare_fds(int pid)
return
1
;
return
1
;
break
;
break
;
default:
default:
pr_err
or
(
"Unknown type in %s
\n
"
,
path
);
pr_err
(
"Unknown type in %s
\n
"
,
path
);
return
1
;
return
1
;
}
}
}
}
...
@@ -657,7 +657,7 @@ static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd)
...
@@ -657,7 +657,7 @@ static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd)
pr_info
(
"%d: Search for %016lx shmem %p/%d
\n
"
,
pid
,
vi
->
start
,
si
,
si
?
si
->
pid
:
-
1
);
pr_info
(
"%d: Search for %016lx shmem %p/%d
\n
"
,
pid
,
vi
->
start
,
si
,
si
?
si
->
pid
:
-
1
);
if
(
!
si
)
{
if
(
!
si
)
{
pr_err
or
(
"Can't find my shmem %016lx
\n
"
,
vi
->
start
);
pr_err
(
"Can't find my shmem %016lx
\n
"
,
vi
->
start
);
return
1
;
return
1
;
}
}
...
@@ -755,7 +755,7 @@ static int fixup_pages_data(int pid, int fd)
...
@@ -755,7 +755,7 @@ static int fixup_pages_data(int pid, int fd)
read
(
shfd
,
&
magic
,
sizeof
(
magic
));
read
(
shfd
,
&
magic
,
sizeof
(
magic
));
if
(
magic
!=
PAGES_MAGIC
)
{
if
(
magic
!=
PAGES_MAGIC
)
{
pr_err
or
(
"Bad shmem file magic number %s
\n
"
,
path
);
pr_err
(
"Bad shmem file magic number %s
\n
"
,
path
);
return
1
;
return
1
;
}
}
...
@@ -905,7 +905,7 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
...
@@ -905,7 +905,7 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
tmp
=
splice
(
pipes_fd
,
NULL
,
pfd
[
1
],
NULL
,
e
->
bytes
,
0
);
tmp
=
splice
(
pipes_fd
,
NULL
,
pfd
[
1
],
NULL
,
e
->
bytes
,
0
);
if
(
tmp
!=
e
->
bytes
)
{
if
(
tmp
!=
e
->
bytes
)
{
pr_err
or
(
"Wanted to restore %d bytes, but got %d
\n
"
,
pr_err
(
"Wanted to restore %d bytes, but got %d
\n
"
,
e
->
bytes
,
tmp
);
e
->
bytes
,
tmp
);
if
(
tmp
<
0
)
if
(
tmp
<
0
)
perror
(
"Error splicing data"
);
perror
(
"Error splicing data"
);
...
@@ -1014,7 +1014,7 @@ static int open_pipe(int pid, struct pipe_entry *e, int *pipes_fd)
...
@@ -1014,7 +1014,7 @@ static int open_pipe(int pid, struct pipe_entry *e, int *pipes_fd)
pi
=
find_pipe
(
e
->
pipeid
);
pi
=
find_pipe
(
e
->
pipeid
);
if
(
!
pi
)
{
if
(
!
pi
)
{
pr_err
or
(
"BUG: can't find my pipe %x
\n
"
,
e
->
pipeid
);
pr_err
(
"BUG: can't find my pipe %x
\n
"
,
e
->
pipeid
);
return
1
;
return
1
;
}
}
...
@@ -1132,7 +1132,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path)
...
@@ -1132,7 +1132,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path)
while
(
1
)
{
while
(
1
)
{
ret
=
read
(
fd
,
&
e
,
sizeof
(
e
));
ret
=
read
(
fd
,
&
e
,
sizeof
(
e
));
if
(
ret
!=
sizeof
(
e
))
{
if
(
ret
!=
sizeof
(
e
))
{
pr_err
or
(
"%d: Read returned %d
\n
"
,
my_pid
,
ret
);
pr_err
(
"%d: Read returned %d
\n
"
,
my_pid
,
ret
);
if
(
ret
<
0
)
if
(
ret
<
0
)
perror
(
"Can't read pstree"
);
perror
(
"Can't read pstree"
);
exit
(
1
);
exit
(
1
);
...
...
cr-show.c
View file @
a00ef142
...
@@ -318,13 +318,13 @@ static int collect_pstree(pid_t pid, struct cr_fdset *cr_fdset)
...
@@ -318,13 +318,13 @@ static int collect_pstree(pid_t pid, struct cr_fdset *cr_fdset)
item
->
children
=
xmalloc
(
size
);
item
->
children
=
xmalloc
(
size
);
if
(
!
item
->
children
)
{
if
(
!
item
->
children
)
{
pr_err
or
(
"No memory for children pids
\n
"
);
pr_err
(
"No memory for children pids
\n
"
);
goto
err
;
goto
err
;
}
}
ret
=
read
(
fd
,
item
->
children
,
size
);
ret
=
read
(
fd
,
item
->
children
,
size
);
if
(
ret
!=
size
)
{
if
(
ret
!=
size
)
{
pr_err
or
(
"An error in reading children pids
\n
"
);
pr_err
(
"An error in reading children pids
\n
"
);
xfree
(
item
->
children
);
xfree
(
item
->
children
);
goto
err
;
goto
err
;
}
}
...
...
crtools.c
View file @
a00ef142
...
@@ -162,7 +162,7 @@ int prep_cr_fdset_for_restore(struct cr_fdset *cr_fdset,
...
@@ -162,7 +162,7 @@ int prep_cr_fdset_for_restore(struct cr_fdset *cr_fdset,
read_ptr_safe
(
cr_fdset
->
desc
[
i
].
fd
,
&
magic
,
err
);
read_ptr_safe
(
cr_fdset
->
desc
[
i
].
fd
,
&
magic
,
err
);
if
(
magic
!=
cr_fdset
->
desc
[
i
].
tmpl
->
magic
)
{
if
(
magic
!=
cr_fdset
->
desc
[
i
].
tmpl
->
magic
)
{
pr_err
or
(
"Magic doesn't match for %s
\n
"
,
pr_err
(
"Magic doesn't match for %s
\n
"
,
cr_fdset
->
desc
[
i
].
name
);
cr_fdset
->
desc
[
i
].
name
);
goto
err
;
goto
err
;
}
}
...
...
elf.c
View file @
a00ef142
...
@@ -107,11 +107,11 @@ int convert_to_elf(char *elf_path, int fd_core)
...
@@ -107,11 +107,11 @@ int convert_to_elf(char *elf_path, int fd_core)
/* Figure out if we're overflowed */
/* Figure out if we're overflowed */
if
(
e_phnum
>
ELF_MAX_PHDR
)
{
if
(
e_phnum
>
ELF_MAX_PHDR
)
{
pr_err
or
(
"Too many VMA areas (%li of %li allowed)
\n
"
,
pr_err
(
"Too many VMA areas (%li of %li allowed)
\n
"
,
e_phnum
,
ELF_MAX_PHDR
);
e_phnum
,
ELF_MAX_PHDR
);
goto
err_close
;
goto
err_close
;
}
else
if
(
nrpages
>
ELF_MAX_PAGES
)
{
}
else
if
(
nrpages
>
ELF_MAX_PAGES
)
{
pr_err
or
(
"Too many pages to restore (%li of %li allowed)
\n
"
,
pr_err
(
"Too many pages to restore (%li of %li allowed)
\n
"
,
nrpages
,
ELF_MAX_PAGES
);
nrpages
,
ELF_MAX_PAGES
);
goto
err_close
;
goto
err_close
;
}
}
...
...
include/util.h
View file @
a00ef142
...
@@ -16,11 +16,11 @@
...
@@ -16,11 +16,11 @@
extern
void
printk
(
const
char
*
format
,
...);
extern
void
printk
(
const
char
*
format
,
...);
#define pr_info(fmt, ...) printk(fmt, ##__VA_ARGS__)
#define pr_info(fmt, ...) printk(fmt, ##__VA_ARGS__)
#define pr_err
or
(fmt, ...) printk("Error (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define pr_err(fmt, ...) printk("Error (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define pr_panic(fmt, ...) printk("PANIC (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define pr_panic(fmt, ...) printk("PANIC (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define pr_warning(fmt, ...) printk("Warning: " fmt, ##__VA_ARGS__)
#define pr_warning(fmt, ...) printk("Warning: " fmt, ##__VA_ARGS__)
#define pr_err
or
_jmp(label) \
#define pr_err_jmp(label) \
do { \
do { \
printk("EJMP: %s:%d\n", __FILE__, __LINE__); \
printk("EJMP: %s:%d\n", __FILE__, __LINE__); \
goto label; \
goto label; \
...
@@ -29,20 +29,20 @@ extern void printk(const char *format, ...);
...
@@ -29,20 +29,20 @@ extern void printk(const char *format, ...);
#define jerr(code, label) \
#define jerr(code, label) \
do { \
do { \
if ((code)) \
if ((code)) \
pr_err
or
_jmp(label); \
pr_err_jmp(label); \
} while (0)
} while (0)
#define jerr_cond(code, cond, label) \
#define jerr_cond(code, cond, label) \
do { \
do { \
if ((code) cond) \
if ((code) cond) \
pr_err
or
_jmp(label); \
pr_err_jmp(label); \
} while (0)
} while (0)
#define jerr_rc(code, rc, label) \
#define jerr_rc(code, rc, label) \
do { \
do { \
rc = (code); \
rc = (code); \
if (rc) \
if (rc) \
pr_err
or
_jmp(label); \
pr_err_jmp(label); \
} while (0)
} while (0)
#if 0
#if 0
...
@@ -65,7 +65,7 @@ extern void printk(const char *format, ...);
...
@@ -65,7 +65,7 @@ extern void printk(const char *format, ...);
#define pr_perror(fmt, ...) \
#define pr_perror(fmt, ...) \
do { \
do { \
pr_err
or
("%s: " fmt, strerror(errno), \
pr_err("%s: " fmt, strerror(errno), \
##__VA_ARGS__); \
##__VA_ARGS__); \
} while (0)
} while (0)
...
@@ -154,7 +154,7 @@ int close_safe(int *fd);
...
@@ -154,7 +154,7 @@ int close_safe(int *fd);
({ \
({ \
void *___p = op( __VA_ARGS__ ); \
void *___p = op( __VA_ARGS__ ); \
if (!___p) \
if (!___p) \
pr_err
or
("%s: Can't allocate %li bytes\n", \
pr_err("%s: Can't allocate %li bytes\n", \
__func__, (long)(size)); \
__func__, (long)(size)); \
___p; \
___p; \
})
})
...
...
parasite-syscall.c
View file @
a00ef142
...
@@ -284,7 +284,7 @@ again:
...
@@ -284,7 +284,7 @@ again:
if
(
ptrace_poke_area
((
long
)
ctl
->
pid
,
(
void
*
)
parasite_arg
.
args
,
if
(
ptrace_poke_area
((
long
)
ctl
->
pid
,
(
void
*
)
parasite_arg
.
args
,
(
void
*
)
ctl
->
addr_args
,
parasite_arg
.
args_size
))
{
(
void
*
)
ctl
->
addr_args
,
parasite_arg
.
args_size
))
{
pr_err
or
(
"Can't setup parasite arguments (pid: %d)
\n
"
,
ctl
->
pid
);
pr_err
(
"Can't setup parasite arguments (pid: %d)
\n
"
,
ctl
->
pid
);
goto
err_restore
;
goto
err_restore
;
}
}
...
@@ -324,7 +324,7 @@ retry_signal:
...
@@ -324,7 +324,7 @@ retry_signal:
(
void
*
)(
ctl
->
addr_args
+
(
void
*
)(
ctl
->
addr_args
+
offsetof
(
parasite_args_cmd_dumppages_t
,
fd
)),
offsetof
(
parasite_args_cmd_dumppages_t
,
fd
)),
sizeof
(
parasite_dumppages
.
fd
)))
{
sizeof
(
parasite_dumppages
.
fd
)))
{
pr_err
or
(
"Can't get file descriptor back (pid: %d)
\n
"
,
ctl
->
pid
);
pr_err
(
"Can't get file descriptor back (pid: %d)
\n
"
,
ctl
->
pid
);
goto
err_restore
;
goto
err_restore
;
}
}
}
}
...
@@ -337,7 +337,7 @@ retry_signal:
...
@@ -337,7 +337,7 @@ retry_signal:
(
void
*
)(
ctl
->
addr_args
+
(
void
*
)(
ctl
->
addr_args
+
offsetof
(
parasite_args_cmd_dumppages_t
,
nrpages_dumped
)),
offsetof
(
parasite_args_cmd_dumppages_t
,
nrpages_dumped
)),
sizeof
(
parasite_dumppages
.
fd
)))
{
sizeof
(
parasite_dumppages
.
fd
)))
{
pr_err
or
(
"Can't get statistics (pid: %d)
\n
"
,
ctl
->
pid
);
pr_err
(
"Can't get statistics (pid: %d)
\n
"
,
ctl
->
pid
);
goto
err_restore
;
goto
err_restore
;
}
}
pr_info
(
" (dumped: %16li pages)
\n
"
,
parasite_dumppages
.
nrpages_dumped
);
pr_info
(
" (dumped: %16li pages)
\n
"
,
parasite_dumppages
.
nrpages_dumped
);
...
@@ -409,7 +409,7 @@ int parasite_cure_seized(struct parasite_ctl **p_ctl,
...
@@ -409,7 +409,7 @@ int parasite_cure_seized(struct parasite_ctl **p_ctl,
vma_area
=
get_vma_by_ip
(
vma_area_list
,
regs
.
ip
);
vma_area
=
get_vma_by_ip
(
vma_area_list
,
regs
.
ip
);
if
(
!
vma_area
)
{
if
(
!
vma_area
)
{
pr_err
or
(
"No suitable VMA found to run cure (pid: %d)
\n
"
,
ctl
->
pid
);
pr_err
(
"No suitable VMA found to run cure (pid: %d)
\n
"
,
ctl
->
pid
);
goto
err
;
goto
err
;
}
}
...
@@ -419,7 +419,7 @@ int parasite_cure_seized(struct parasite_ctl **p_ctl,
...
@@ -419,7 +419,7 @@ int parasite_cure_seized(struct parasite_ctl **p_ctl,
(
void
*
)
ctl
->
vma_area
->
vma
.
start
,
(
void
*
)
ctl
->
vma_area
->
vma
.
start
,
(
size_t
)
vma_entry_len
(
&
ctl
->
vma_area
->
vma
));
(
size_t
)
vma_entry_len
(
&
ctl
->
vma_area
->
vma
));
if
(
ret
)
if
(
ret
)
pr_err
or
(
"munmap_seized failed (pid: %d)
\n
"
,
ctl
->
pid
);
pr_err
(
"munmap_seized failed (pid: %d)
\n
"
,
ctl
->
pid
);
if
(
ptrace
(
PTRACE_SETREGS
,
ctl
->
pid
,
NULL
,
&
regs_orig
))
{
if
(
ptrace
(
PTRACE_SETREGS
,
ctl
->
pid
,
NULL
,
&
regs_orig
))
{
ret
=
-
1
;
ret
=
-
1
;
...
@@ -440,7 +440,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l
...
@@ -440,7 +440,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l
ctl
=
xzalloc
(
sizeof
(
*
ctl
)
+
sizeof
(
*
vma_area
));
ctl
=
xzalloc
(
sizeof
(
*
ctl
)
+
sizeof
(
*
vma_area
));
if
(
!
ctl
)
{
if
(
!
ctl
)
{
pr_err
or
(
"Parasite control block allocation failed (pid: %d)
\n
"
,
pid
);
pr_err
(
"Parasite control block allocation failed (pid: %d)
\n
"
,
pid
);
goto
err
;
goto
err
;
}
}
...
@@ -449,11 +449,11 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l
...
@@ -449,11 +449,11 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l
ctl
->
vma_area
=
(
struct
vma_area
*
)(
char
*
)
&
ctl
[
sizeof
(
*
ctl
)];
ctl
->
vma_area
=
(
struct
vma_area
*
)(
char
*
)
&
ctl
[
sizeof
(
*
ctl
)];
if
(
ptrace
(
PTRACE_GETREGS
,
pid
,
NULL
,
&
regs
))
if
(
ptrace
(
PTRACE_GETREGS
,
pid
,
NULL
,
&
regs
))
pr_err
or
_jmp
(
err_free
);
pr_err_jmp
(
err_free
);
vma_area
=
get_vma_by_ip
(
vma_area_list
,
regs
.
ip
);
vma_area
=
get_vma_by_ip
(
vma_area_list
,
regs
.
ip
);
if
(
!
vma_area
)
{
if
(
!
vma_area
)
{
pr_err
or
(
"No suitable VMA found to run parasite "
pr_err
(
"No suitable VMA found to run parasite "
"bootstrap code (pid: %d)
\n
"
,
pid
);
"bootstrap code (pid: %d)
\n
"
,
pid
);
goto
err_free
;
goto
err_free
;
}
}
...
@@ -474,7 +474,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l
...
@@ -474,7 +474,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l
(
int
)
-
1
,
(
off_t
)
0
);
(
int
)
-
1
,
(
off_t
)
0
);
if
(
!
mmaped
||
(
long
)
mmaped
<
0
)
{
if
(
!
mmaped
||
(
long
)
mmaped
<
0
)
{
pr_err
or
(
"Can't allocate memory for parasite blob (pid: %d)
\n
"
,
pid
);
pr_err
(
"Can't allocate memory for parasite blob (pid: %d)
\n
"
,
pid
);
goto
err_restore_regs
;
goto
err_restore_regs
;
}
}
...
@@ -487,7 +487,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l
...
@@ -487,7 +487,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l
ctl
->
vma_area
->
vma
.
end
=
(
u64
)(
mmaped
+
parasite_size
);
ctl
->
vma_area
->
vma
.
end
=
(
u64
)(
mmaped
+
parasite_size
);
if
(
ptrace_poke_area
(
pid
,
parasite_blob
,
mmaped
,
parasite_size
))
{
if
(
ptrace_poke_area
(
pid
,
parasite_blob
,
mmaped
,
parasite_size
))
{
pr_err
or
(
"Can't inject parasite blob (pid: %d)
\n
"
,
pid
);
pr_err
(
"Can't inject parasite blob (pid: %d)
\n
"
,
pid
);
goto
err_munmap_restore
;
goto
err_munmap_restore
;
}
}
...
...
util.c
View file @
a00ef142
...
@@ -297,7 +297,7 @@ int parse_maps(pid_t pid, struct list_head *vma_area_list)
...
@@ -297,7 +297,7 @@ int parse_maps(pid_t pid, struct list_head *vma_area_list)
&
start
,
&
end
,
&
r
,
&
w
,
&
x
,
&
s
,
&
pgoff
,
&
dev_maj
,
&
start
,
&
end
,
&
r
,
&
w
,
&
x
,
&
s
,
&
pgoff
,
&
dev_maj
,
&
dev_min
,
&
ino
);
&
dev_min
,
&
ino
);
if
(
ret
!=
10
)
{
if
(
ret
!=
10
)
{
pr_err
or
(
"Can't parse: %s"
,
big_buffer
);
pr_err
(
"Can't parse: %s"
,
big_buffer
);
return
-
1
;
return
-
1
;
}
}
...
@@ -375,7 +375,7 @@ int parse_maps(pid_t pid, struct list_head *vma_area_list)
...
@@ -375,7 +375,7 @@ int parse_maps(pid_t pid, struct list_head *vma_area_list)
goto
err
;
goto
err
;
}
}
if
(
!
S_ISREG
(
st_buf
.
st_mode
))
{
if
(
!
S_ISREG
(
st_buf
.
st_mode
))
{
pr_err
or
(
"Can't handle non-regular "
pr_err
(
"Can't handle non-regular "
"mapping on %s%s
\n
"
,
"mapping on %s%s
\n
"
,
map_files_path
,
map_files_path
,
vma_file_path
);
vma_file_path
);
...
@@ -424,7 +424,7 @@ err:
...
@@ -424,7 +424,7 @@ err:
return
ret
;
return
ret
;
err_bogus_mapping:
err_bogus_mapping:
pr_err
or
(
"Bogus mapping %lx-%lx
\n
"
,
pr_err
(
"Bogus mapping %lx-%lx
\n
"
,
vma_area
->
vma
.
start
,
vma_area
->
vma
.
start
,
vma_area
->
vma
.
end
);
vma_area
->
vma
.
end
);
goto
err
;
goto
err
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment