Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
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
Chen Yisong
lxc
Commits
9e1accb9
Unverified
Commit
9e1accb9
authored
May 02, 2019
by
Stéphane Graber
Committed by
GitHub
May 02, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2972 from brauner/2019-05-02/seccomp_notify_mem_fd
seccomp: send process memory fd
parents
99b68bdb
5ed06d3a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
af_unix.c
src/lxc/af_unix.c
+6
-0
af_unix.h
src/lxc/af_unix.h
+2
-0
seccomp.c
src/lxc/seccomp.c
+25
-2
No files found.
src/lxc/af_unix.c
View file @
9e1accb9
...
@@ -199,6 +199,12 @@ again:
...
@@ -199,6 +199,12 @@ again:
return
ret
;
return
ret
;
}
}
int
lxc_unix_send_fds
(
int
fd
,
int
*
sendfds
,
int
num_sendfds
,
void
*
data
,
size_t
size
)
{
return
lxc_abstract_unix_send_fds
(
fd
,
sendfds
,
num_sendfds
,
data
,
size
);
}
int
lxc_abstract_unix_recv_fds
(
int
fd
,
int
*
recvfds
,
int
num_recvfds
,
int
lxc_abstract_unix_recv_fds
(
int
fd
,
int
*
recvfds
,
int
num_recvfds
,
void
*
data
,
size_t
size
)
void
*
data
,
size_t
size
)
{
{
...
...
src/lxc/af_unix.h
View file @
9e1accb9
...
@@ -35,6 +35,8 @@ extern void lxc_abstract_unix_close(int fd);
...
@@ -35,6 +35,8 @@ extern void lxc_abstract_unix_close(int fd);
extern
int
lxc_abstract_unix_connect
(
const
char
*
path
);
extern
int
lxc_abstract_unix_connect
(
const
char
*
path
);
extern
int
lxc_abstract_unix_send_fds
(
int
fd
,
int
*
sendfds
,
int
num_sendfds
,
extern
int
lxc_abstract_unix_send_fds
(
int
fd
,
int
*
sendfds
,
int
num_sendfds
,
void
*
data
,
size_t
size
);
void
*
data
,
size_t
size
);
extern
int
lxc_unix_send_fds
(
int
fd
,
int
*
sendfds
,
int
num_sendfds
,
void
*
data
,
size_t
size
);
extern
int
lxc_abstract_unix_recv_fds
(
int
fd
,
int
*
recvfds
,
int
num_recvfds
,
extern
int
lxc_abstract_unix_recv_fds
(
int
fd
,
int
*
recvfds
,
int
num_recvfds
,
void
*
data
,
size_t
size
);
void
*
data
,
size_t
size
);
extern
int
lxc_abstract_unix_send_credential
(
int
fd
,
void
*
data
,
size_t
size
);
extern
int
lxc_abstract_unix_send_credential
(
int
fd
,
void
*
data
,
size_t
size
);
...
...
src/lxc/seccomp.c
View file @
9e1accb9
...
@@ -1335,8 +1335,10 @@ int seccomp_notify_handler(int fd, uint32_t events, void *data,
...
@@ -1335,8 +1335,10 @@ int seccomp_notify_handler(int fd, uint32_t events, void *data,
{
{
#if HAVE_DECL_SECCOMP_NOTIF_GET_FD
#if HAVE_DECL_SECCOMP_NOTIF_GET_FD
__do_close_prot_errno
int
fd_mem
=
-
EBADF
;
int
reconnect_count
,
ret
;
int
reconnect_count
,
ret
;
ssize_t
bytes
;
ssize_t
bytes
;
char
mem_path
[
6
+
21
+
5
];
struct
lxc_handler
*
hdlr
=
data
;
struct
lxc_handler
*
hdlr
=
data
;
struct
lxc_conf
*
conf
=
hdlr
->
conf
;
struct
lxc_conf
*
conf
=
hdlr
->
conf
;
struct
seccomp_notif
*
req
=
conf
->
seccomp
.
notifier
.
req_buf
;
struct
seccomp_notif
*
req
=
conf
->
seccomp
.
notifier
.
req_buf
;
...
@@ -1355,14 +1357,33 @@ int seccomp_notify_handler(int fd, uint32_t events, void *data,
...
@@ -1355,14 +1357,33 @@ int seccomp_notify_handler(int fd, uint32_t events, void *data,
goto
out
;
goto
out
;
}
}
snprintf
(
mem_path
,
sizeof
(
mem_path
),
"/proc/%d/mem"
,
req
->
pid
);
fd_mem
=
open
(
mem_path
,
O_RDONLY
|
O_CLOEXEC
);
if
(
fd_mem
<
0
)
{
(
void
)
seccomp_notify_default_answer
(
fd
,
req
,
resp
,
hdlr
);
SYSERROR
(
"Failed to open process memory for seccomp notify request"
);
goto
out
;
}
/*
* Make sure that the fd for /proc/<pid>/mem we just opened still
* refers to the correct process's memory.
*/
ret
=
seccomp_notif_id_valid
(
fd
,
req
->
id
);
if
(
ret
<
0
)
{
(
void
)
seccomp_notify_default_answer
(
fd
,
req
,
resp
,
hdlr
);
SYSERROR
(
"Invalid seccomp notify request id"
);
goto
out
;
}
memcpy
(
&
msg
.
req
,
req
,
sizeof
(
msg
.
req
));
memcpy
(
&
msg
.
req
,
req
,
sizeof
(
msg
.
req
));
msg
.
monitor_pid
=
hdlr
->
monitor_pid
;
msg
.
monitor_pid
=
hdlr
->
monitor_pid
;
msg
.
init_pid
=
hdlr
->
pid
;
msg
.
init_pid
=
hdlr
->
pid
;
reconnect_count
=
0
;
reconnect_count
=
0
;
do
{
do
{
bytes
=
lxc_
send_nointr
(
listener_proxy_fd
,
&
msg
,
sizeof
(
msg
)
,
bytes
=
lxc_
unix_send_fds
(
listener_proxy_fd
,
&
fd_mem
,
1
,
&
msg
,
MSG_NOSIGNAL
);
sizeof
(
msg
)
);
if
(
bytes
!=
(
ssize_t
)
sizeof
(
msg
))
{
if
(
bytes
!=
(
ssize_t
)
sizeof
(
msg
))
{
SYSERROR
(
"Failed to forward message to seccomp proxy"
);
SYSERROR
(
"Failed to forward message to seccomp proxy"
);
if
(
seccomp_notify_default_answer
(
fd
,
req
,
resp
,
hdlr
))
if
(
seccomp_notify_default_answer
(
fd
,
req
,
resp
,
hdlr
))
...
@@ -1370,6 +1391,8 @@ int seccomp_notify_handler(int fd, uint32_t events, void *data,
...
@@ -1370,6 +1391,8 @@ int seccomp_notify_handler(int fd, uint32_t events, void *data,
}
}
}
while
(
reconnect_count
++
);
}
while
(
reconnect_count
++
);
close_prot_errno_disarm
(
fd_mem
);
reconnect_count
=
0
;
reconnect_count
=
0
;
do
{
do
{
bytes
=
lxc_recv_nointr
(
listener_proxy_fd
,
&
msg
,
sizeof
(
msg
),
0
);
bytes
=
lxc_recv_nointr
(
listener_proxy_fd
,
&
msg
,
sizeof
(
msg
),
0
);
...
...
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