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
5d14cf6f
Unverified
Commit
5d14cf6f
authored
Dec 01, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups/devices: handle NULL
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ba2cb20d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
cgroup2_devices.c
src/lxc/cgroups/cgroup2_devices.c
+15
-0
No files found.
src/lxc/cgroups/cgroup2_devices.c
View file @
5d14cf6f
...
@@ -51,6 +51,9 @@ static int bpf_program_add_instructions(struct bpf_program *prog,
...
@@ -51,6 +51,9 @@ static int bpf_program_add_instructions(struct bpf_program *prog,
void
bpf_program_free
(
struct
bpf_program
*
prog
)
void
bpf_program_free
(
struct
bpf_program
*
prog
)
{
{
if
(
!
prog
)
return
;
(
void
)
bpf_program_cgroup_detach
(
prog
);
(
void
)
bpf_program_cgroup_detach
(
prog
);
if
(
prog
->
kernel_fd
>=
0
)
if
(
prog
->
kernel_fd
>=
0
)
...
@@ -176,6 +179,9 @@ struct bpf_program *bpf_program_new(uint32_t prog_type)
...
@@ -176,6 +179,9 @@ struct bpf_program *bpf_program_new(uint32_t prog_type)
int
bpf_program_init
(
struct
bpf_program
*
prog
)
int
bpf_program_init
(
struct
bpf_program
*
prog
)
{
{
if
(
!
prog
)
return
minus_one_set_errno
(
EINVAL
);
const
struct
bpf_insn
pre_insn
[]
=
{
const
struct
bpf_insn
pre_insn
[]
=
{
/* load device type to r2 */
/* load device type to r2 */
BPF_LDX_MEM
(
BPF_W
,
BPF_REG_2
,
BPF_REG_1
,
offsetof
(
struct
bpf_cgroup_dev_ctx
,
access_type
)),
BPF_LDX_MEM
(
BPF_W
,
BPF_REG_2
,
BPF_REG_1
,
offsetof
(
struct
bpf_cgroup_dev_ctx
,
access_type
)),
...
@@ -206,6 +212,9 @@ int bpf_program_append_device(struct bpf_program *prog, struct device_item *devi
...
@@ -206,6 +212,9 @@ int bpf_program_append_device(struct bpf_program *prog, struct device_item *devi
int
access_mask
;
int
access_mask
;
int
device_type
;
int
device_type
;
if
(
!
prog
||
!
device
)
return
minus_one_set_errno
(
EINVAL
);
/* This is a global rule so no need to append anything. */
/* This is a global rule so no need to append anything. */
if
(
device
->
global_rule
>=
0
)
{
if
(
device
->
global_rule
>=
0
)
{
prog
->
blacklist
=
device
->
global_rule
;
prog
->
blacklist
=
device
->
global_rule
;
...
@@ -287,6 +296,9 @@ int bpf_program_finalize(struct bpf_program *prog)
...
@@ -287,6 +296,9 @@ int bpf_program_finalize(struct bpf_program *prog)
BPF_EXIT_INSN
(),
BPF_EXIT_INSN
(),
};
};
if
(
!
prog
)
return
minus_one_set_errno
(
EINVAL
);
TRACE
(
"Implementing %s bpf device cgroup program"
,
TRACE
(
"Implementing %s bpf device cgroup program"
,
prog
->
blacklist
?
"blacklist"
:
"whitelist"
);
prog
->
blacklist
?
"blacklist"
:
"whitelist"
);
return
bpf_program_add_instructions
(
prog
,
ins
,
ARRAY_SIZE
(
ins
));
return
bpf_program_add_instructions
(
prog
,
ins
,
ARRAY_SIZE
(
ins
));
...
@@ -327,6 +339,9 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type,
...
@@ -327,6 +339,9 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type,
union
bpf_attr
attr
;
union
bpf_attr
attr
;
int
ret
;
int
ret
;
if
(
!
prog
)
return
minus_one_set_errno
(
EINVAL
);
if
(
flags
&
~
(
BPF_F_ALLOW_OVERRIDE
,
BPF_F_ALLOW_MULTI
))
if
(
flags
&
~
(
BPF_F_ALLOW_OVERRIDE
,
BPF_F_ALLOW_MULTI
))
return
error_log_errno
(
EINVAL
,
"Invalid flags for bpf program"
);
return
error_log_errno
(
EINVAL
,
"Invalid flags for bpf program"
);
...
...
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