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
720cab0b
Commit
720cab0b
authored
Sep 11, 2012
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fd: Sanitize open_fd with send_fd_to_self helper
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
8cc9477d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
20 deletions
+26
-20
files.c
files.c
+26
-20
No files found.
files.c
View file @
720cab0b
...
...
@@ -325,6 +325,26 @@ int send_fd_to_peer(int fd, struct fdinfo_list_entry *fle, int sock)
return
send_fd
(
sock
,
&
saddr
,
len
,
fd
);
}
static
int
send_fd_to_self
(
int
fd
,
struct
fdinfo_list_entry
*
fle
,
int
*
sock
)
{
int
dfd
=
fle
->
fe
->
fd
;
if
(
fd
==
dfd
)
return
0
;
pr_info
(
"
\t\t\t
Going to dup %d into %d
\n
"
,
fd
,
dfd
);
if
(
move_img_fd
(
sock
,
dfd
))
return
-
1
;
if
(
dup2
(
fd
,
dfd
)
!=
dfd
)
{
pr_perror
(
"Can't dup local fd %d -> %d"
,
fd
,
dfd
);
return
-
1
;
}
fcntl
(
dfd
,
F_SETFD
,
fle
->
fe
->
flags
);
return
0
;
}
static
int
post_open_fd
(
int
pid
,
FdinfoEntry
*
fe
,
struct
file_desc
*
d
)
{
struct
fdinfo_list_entry
*
fle
;
...
...
@@ -367,27 +387,13 @@ static int open_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
pr_info
(
"
\t\t
Create fd for %d
\n
"
,
fe
->
fd
);
list_for_each_entry
(
fle
,
&
d
->
fd_info_head
,
desc_list
)
{
if
(
pid
==
fle
->
pid
)
{
pr_info
(
"
\t\t\t
Going to dup %d into %d
\n
"
,
fe
->
fd
,
fle
->
fe
->
fd
);
if
(
fe
->
fd
==
fle
->
fe
->
fd
)
continue
;
if
(
move_img_fd
(
&
sock
,
fle
->
fe
->
fd
))
return
-
1
;
if
(
dup2
(
fe
->
fd
,
fle
->
fe
->
fd
)
!=
fle
->
fe
->
fd
)
{
pr_perror
(
"Can't dup local fd %d -> %d"
,
fe
->
fd
,
fle
->
fe
->
fd
);
return
-
1
;
}
fcntl
(
fle
->
fe
->
fd
,
F_SETFD
,
fle
->
fe
->
flags
);
continue
;
}
if
(
pid
==
fle
->
pid
)
ret
=
send_fd_to_self
(
fe
->
fd
,
fle
,
&
sock
);
else
ret
=
send_fd_to_peer
(
fe
->
fd
,
fle
,
sock
);
if
(
send_fd_to_peer
(
fe
->
fd
,
fle
,
sock
)
)
{
pr_
perror
(
"Can't send file descriptor"
);
if
(
ret
)
{
pr_
err
(
"Can't sent fd %d to %d
\n
"
,
fe
->
fd
,
fle
->
pid
);
return
-
1
;
}
}
...
...
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