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
c38e5c4f
Unverified
Commit
c38e5c4f
authored
Feb 18, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpf: don't close invalid fd, simply swap
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
281f42af
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
cgroup2_devices.c
src/lxc/cgroups/cgroup2_devices.c
+5
-5
No files found.
src/lxc/cgroups/cgroup2_devices.c
View file @
c38e5c4f
...
@@ -365,7 +365,7 @@ static int bpf_program_load_kernel(struct bpf_program *prog)
...
@@ -365,7 +365,7 @@ static int bpf_program_load_kernel(struct bpf_program *prog)
int
bpf_program_cgroup_attach
(
struct
bpf_program
*
prog
,
int
type
,
int
fd_cgroup
,
int
bpf_program_cgroup_attach
(
struct
bpf_program
*
prog
,
int
type
,
int
fd_cgroup
,
int
replace_bpf_fd
,
__u32
flags
)
int
replace_bpf_fd
,
__u32
flags
)
{
{
__do_close
int
fd_
cgroup_dup
=
-
EBADF
;
__do_close
int
fd_
attach
=
-
EBADF
;
int
ret
;
int
ret
;
union
bpf_attr
*
attr
;
union
bpf_attr
*
attr
;
...
@@ -400,8 +400,8 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type, int fd_cgroup,
...
@@ -400,8 +400,8 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type, int fd_cgroup,
}
}
/* Leave the caller's fd alone. */
/* Leave the caller's fd alone. */
fd_
cgroup_dup
=
dup_cloexec
(
fd_cgroup
);
fd_
attach
=
dup_cloexec
(
fd_cgroup
);
if
(
fd_
cgroup_dup
<
0
)
if
(
fd_
attach
<
0
)
return
-
errno
;
return
-
errno
;
ret
=
bpf_program_load_kernel
(
prog
);
ret
=
bpf_program_load_kernel
(
prog
);
...
@@ -410,7 +410,7 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type, int fd_cgroup,
...
@@ -410,7 +410,7 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type, int fd_cgroup,
attr
=
&
(
union
bpf_attr
){
attr
=
&
(
union
bpf_attr
){
.
attach_type
=
type
,
.
attach_type
=
type
,
.
target_fd
=
fd_
cgroup_dup
,
.
target_fd
=
fd_
attach
,
.
attach_bpf_fd
=
prog
->
kernel_fd
,
.
attach_bpf_fd
=
prog
->
kernel_fd
,
.
attach_flags
=
flags
,
.
attach_flags
=
flags
,
};
};
...
@@ -422,7 +422,7 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type, int fd_cgroup,
...
@@ -422,7 +422,7 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type, int fd_cgroup,
if
(
ret
<
0
)
if
(
ret
<
0
)
return
syserrno_set
(
-
errno
,
"Failed to attach bpf program"
);
return
syserrno_set
(
-
errno
,
"Failed to attach bpf program"
);
close_move_fd
(
prog
->
fd_cgroup
,
fd_cgroup_dup
);
swap
(
prog
->
fd_cgroup
,
fd_attach
);
prog
->
attached_type
=
type
;
prog
->
attached_type
=
type
;
prog
->
attached_flags
=
flags
;
prog
->
attached_flags
=
flags
;
...
...
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