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
9d984c3f
Unverified
Commit
9d984c3f
authored
Apr 07, 2021
by
Christian Brauner
Committed by
GitHub
Apr 07, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3763 from evverx/fuzz-lxc-define-load
oss-fuzz: fuzz lxc_config_define_add and lxc_config_define_load
parents
ace51ce8
55376ebd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
3 deletions
+77
-3
cifuzz.yml
.github/workflows/cifuzz.yml
+1
-1
confile.c
src/lxc/confile.c
+3
-0
fuzz-lxc-define-load.c
src/tests/fuzz-lxc-define-load.c
+64
-0
oss-fuzz.sh
src/tests/oss-fuzz.sh
+9
-2
No files found.
.github/workflows/cifuzz.yml
View file @
9d984c3f
...
@@ -28,7 +28,7 @@ jobs:
...
@@ -28,7 +28,7 @@ jobs:
uses
:
google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
uses
:
google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with
:
with
:
oss-fuzz-project-name
:
'
lxc'
oss-fuzz-project-name
:
'
lxc'
fuzz-seconds
:
18
0
fuzz-seconds
:
36
0
dry-run
:
false
dry-run
:
false
sanitizer
:
${{ matrix.sanitizer }}
sanitizer
:
${{ matrix.sanitizer }}
-
name
:
Upload Crash
-
name
:
Upload Crash
...
...
src/lxc/confile.c
View file @
9d984c3f
...
@@ -3135,7 +3135,9 @@ bool lxc_config_define_load(struct lxc_list *defines, struct lxc_container *c)
...
@@ -3135,7 +3135,9 @@ bool lxc_config_define_load(struct lxc_list *defines, struct lxc_container *c)
break
;
break
;
}
}
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
lxc_config_define_free
(
defines
);
lxc_config_define_free
(
defines
);
#endif
/* !FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
return
bret
;
return
bret
;
}
}
...
@@ -3149,6 +3151,7 @@ void lxc_config_define_free(struct lxc_list *defines)
...
@@ -3149,6 +3151,7 @@ void lxc_config_define_free(struct lxc_list *defines)
free
(
new_item
->
key
);
free
(
new_item
->
key
);
free
(
new_item
->
val
);
free
(
new_item
->
val
);
lxc_list_del
(
it
);
lxc_list_del
(
it
);
free
(
it
->
elem
);
free
(
it
);
free
(
it
);
}
}
}
}
...
...
src/tests/fuzz-lxc-define-load.c
0 → 100644
View file @
9d984c3f
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <stddef.h>
#include <stdint.h>
#include "conf.h"
#include "confile.h"
#include "lxctest.h"
#include "utils.h"
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
)
{
__do_free
char
*
new_str
=
NULL
;
struct
lxc_container
*
c
=
NULL
;
struct
lxc_list
defines
;
struct
lxc_list
*
it
;
__do_close
int
devnull_fd
=
-
EBADF
;
if
(
size
>
102400
)
return
0
;
c
=
lxc_container_new
(
"FUZZ"
,
NULL
);
lxc_test_assert_abort
(
c
);
new_str
=
(
char
*
)
malloc
(
size
+
1
);
lxc_test_assert_abort
(
new_str
);
memcpy
(
new_str
,
data
,
size
);
new_str
[
size
]
=
'\0'
;
lxc_list_init
(
&
defines
);
if
(
lxc_config_define_add
(
&
defines
,
new_str
)
<
0
)
goto
out
;
if
(
!
lxc_config_define_load
(
&
defines
,
c
))
goto
out
;
devnull_fd
=
open_devnull
();
lxc_test_assert_abort
(
devnull_fd
>=
0
);
lxc_list_for_each
(
it
,
&
defines
)
{
__do_free
char
*
val
=
NULL
;
struct
new_config_item
*
config_item
=
it
->
elem
;
int
len
;
len
=
c
->
get_config_item
(
c
,
config_item
->
key
,
NULL
,
0
);
if
(
len
<
0
)
continue
;
val
=
(
char
*
)
malloc
(
len
+
1
);
lxc_test_assert_abort
(
val
);
if
(
c
->
get_config_item
(
c
,
config_item
->
key
,
val
,
len
+
1
)
!=
len
)
continue
;
if
(
len
>
0
)
dprintf
(
devnull_fd
,
"[%s/%s]
\n
"
,
config_item
->
key
,
val
);
}
out:
lxc_container_put
(
c
);
lxc_config_define_free
(
&
defines
);
return
0
;
}
src/tests/oss-fuzz.sh
View file @
9d984c3f
...
@@ -43,8 +43,11 @@ sed -i 's/^AC_CHECK_LIB(util/#/' configure.ac
...
@@ -43,8 +43,11 @@ sed -i 's/^AC_CHECK_LIB(util/#/' configure.ac
make
-j
$(
nproc
)
make
-j
$(
nproc
)
$CC
-c
-o
fuzz-lxc-config-read.o
$CFLAGS
-Isrc
-Isrc
/lxc src/tests/fuzz-lxc-config-read.c
for
fuzz_target_source
in
src/tests/fuzz-lxc
*
.c
;
do
$CXX
$CXXFLAGS
$LIB_FUZZING_ENGINE
fuzz-lxc-config-read.o src/lxc/.libs/liblxc.a
-o
$OUT
/fuzz-lxc-config-read
fuzz_target_name
=
$(
basename
"
$fuzz_target_source
"
".c"
)
$CC
-c
-o
"
$fuzz_target_name
.o"
$CFLAGS
-Isrc
-Isrc
/lxc
"
$fuzz_target_source
"
$CXX
$CXXFLAGS
$LIB_FUZZING_ENGINE
"
$fuzz_target_name
.o"
src/lxc/.libs/liblxc.a
-o
"
$OUT
/
$fuzz_target_name
"
done
perl
-lne
'if (/config_jump_table\[\]\s*=/../^}/) { /"([^"]+)"/ && print "$1=" }'
src/lxc/confile.c
>
doc/examples/keys.conf
perl
-lne
'if (/config_jump_table\[\]\s*=/../^}/) { /"([^"]+)"/ && print "$1=" }'
src/lxc/confile.c
>
doc/examples/keys.conf
[[
-s
doc/examples/keys.conf
]]
[[
-s
doc/examples/keys.conf
]]
...
@@ -53,3 +56,7 @@ perl -lne 'if (/config_jump_table_net\[\]\s*=/../^}/) { /"([^"]+)"/ && print "lx
...
@@ -53,3 +56,7 @@ perl -lne 'if (/config_jump_table_net\[\]\s*=/../^}/) { /"([^"]+)"/ && print "lx
[[
-s
doc/examples/lxc-net-keys.conf
]]
[[
-s
doc/examples/lxc-net-keys.conf
]]
zip
-r
$OUT
/fuzz-lxc-config-read_seed_corpus.zip doc/examples
zip
-r
$OUT
/fuzz-lxc-config-read_seed_corpus.zip doc/examples
mkdir
fuzz-lxc-define-load_seed_corpus
perl
-lne
'/([^=]+)/ && print "printf $1= >fuzz-lxc-define-load_seed_corpus/$1"'
doc/examples/
{
keys,lxc-net-keys
}
.conf | bash
zip
-r
$OUT
/fuzz-lxc-define-load_seed_corpus.zip fuzz-lxc-define-load_seed_corpus
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