Skip to content

Commit 81f2154

Browse files
author
Ethan Graham
committed
prog: use separate allocation size for KFuzzTest arguments
1 parent cd97285 commit 81f2154

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

prog/kfuzztest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const (
2222
// x86_64, so we hardcode it for now. A more robust solution would involve
2323
// reading this from the debugfs entry at boot before fuzzing begins.
2424
kFuzzTestMinalign uint64 = 8
25+
26+
// Maximum input size accepted by the KFuzzTest kernel module.
27+
KFuzzTestMaxInputSize uint64 = 64 << 10
2528
)
2629

2730
func kFuzzTestWritePrefix(buf *bytes.Buffer) {

prog/rand.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ func (r *randGen) randString(s *state, t *BufferType) []byte {
368368
}
369369

370370
func (r *randGen) allocAddr(s *state, typ Type, dir Dir, size uint64, data Arg) *PointerArg {
371+
_, isStruct := data.(*GroupArg)
372+
if r.genKFuzzTest && isStruct {
373+
size = KFuzzTestMaxInputSize
374+
}
371375
return MakePointerArg(typ, dir, s.ma.alloc(r, size, data.Type().Alignment()), data)
372376
}
373377

0 commit comments

Comments
 (0)