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
72a27f06
Unverified
Commit
72a27f06
authored
Feb 18, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: improve bpf device program management
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
35cca0f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
37 deletions
+7
-37
cgfsng.c
src/lxc/cgroups/cgfsng.c
+7
-37
No files found.
src/lxc/cgroups/cgfsng.c
View file @
72a27f06
...
@@ -3204,48 +3204,18 @@ __cgfsng_ops static bool cgfsng_devices_activate(struct cgroup_ops *ops, struct
...
@@ -3204,48 +3204,18 @@ __cgfsng_ops static bool cgfsng_devices_activate(struct cgroup_ops *ops, struct
if
(
ret
)
if
(
ret
)
return
log_error_errno
(
false
,
ENOMEM
,
"Failed to initialize bpf program"
);
return
log_error_errno
(
false
,
ENOMEM
,
"Failed to initialize bpf program"
);
/* First pass, determine whether this is an allow- or denylist. */
bpf_device_set_type
(
prog
,
&
conf
->
devices
);
lxc_list_for_each
(
it
,
&
conf
->
devices
)
{
TRACE
(
"Device bpf %s all devices by default"
,
struct
device_item
*
cur
=
it
->
elem
;
bpf_device_block_all
(
prog
)
?
"blocks"
:
"allows"
);
if
(
cur
->
global_rule
>
LXC_BPF_DEVICE_CGROUP_LOCAL_RULE
)
prog
->
device_list_type
=
cur
->
global_rule
;
}
lxc_list_for_each
(
it
,
&
conf
->
devices
)
{
lxc_list_for_each
(
it
,
&
conf
->
devices
)
{
struct
device_item
*
cur
=
it
->
elem
;
struct
device_item
*
cur
=
it
->
elem
;
/* Nothing to be done. */
if
(
!
bpf_device_add
(
prog
,
cur
))
{
if
(
cur
->
global_rule
>
LXC_BPF_DEVICE_CGROUP_LOCAL_RULE
)
TRACE
(
"Skipping type %c, major %d, minor %d, access %s, allow %d"
,
cur
->
type
,
cur
->
major
,
cur
->
minor
,
cur
->
access
,
cur
->
allow
);
continue
;
continue
;
switch
(
prog
->
device_list_type
)
{
case
LXC_BPF_DEVICE_CGROUP_ALLOWLIST
:
/* We're denying all devices so skip individual deny rules. */
if
(
!
cur
->
allow
)
{
TRACE
(
"Skipping deny rule in denylist bpf device program: type %c, major %d, minor %d, access %s, allow %d"
,
cur
->
type
,
cur
->
major
,
cur
->
minor
,
cur
->
access
,
cur
->
allow
);
continue
;
}
break
;
case
LXC_BPF_DEVICE_CGROUP_DENYLIST
:
/* We're allowing all devices so skip individual allow rules. */
if
(
cur
->
allow
)
{
TRACE
(
"Skipping allow rule in allow bpf device program: type %c, major %d, minor %d, access %s, allow %d"
,
cur
->
type
,
cur
->
major
,
cur
->
minor
,
cur
->
access
,
cur
->
allow
);
continue
;
}
break
;
}
}
ret
=
bpf_program_append_device
(
prog
,
cur
);
ret
=
bpf_program_append_device
(
prog
,
cur
);
...
...
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