VirtualBox

Changeset 77544 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Mar 3, 2019 8:07:01 PM (6 years ago)
Author:
vboxsync
Message:

Runtime/fuzz: Updates, add a target state recording mechanism to record changes in target behavior caused by mutated inputs. This allows to decide which mutated input gets added to the input corpus and which one gets discarded. Currently this is only able to record the stdout/stderr channels of the fuzzed process but other sources to detect changed behvior will get added in the future

Location:
trunk/include/iprt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/fuzz.h

    r77509 r77544  
    4242
    4343/** A fuzzer context handle. */
    44 typedef struct RTFUZZCTXINT    *RTFUZZCTX;
     44typedef struct RTFUZZCTXINT      *RTFUZZCTX;
    4545/** Pointer to a fuzzer context handle. */
    46 typedef RTFUZZCTX              *PRTFUZZCTX;
     46typedef RTFUZZCTX                *PRTFUZZCTX;
    4747/** NIL fuzzer context handle. */
    48 #define NIL_RTFUZZCTX           ((RTFUZZCTX)~(uintptr_t)0)
     48#define NIL_RTFUZZCTX            ((RTFUZZCTX)~(uintptr_t)0)
    4949/** A fuzzer input handle. */
    50 typedef struct RTFUZZINPUTINT  *RTFUZZINPUT;
     50typedef struct RTFUZZINPUTINT    *RTFUZZINPUT;
    5151/** Pointer to a fuzzer input handle. */
    52 typedef RTFUZZINPUT            *PRTFUZZINPUT;
     52typedef RTFUZZINPUT              *PRTFUZZINPUT;
    5353/** NIL fuzzer input handle. */
    54 #define NIL_RTFUZZINPUT        ((RTFUZZINPUT)~(uintptr_t)0)
     54#define NIL_RTFUZZINPUT          ((RTFUZZINPUT)~(uintptr_t)0)
     55
     56
     57/** A fuzzer target recorder handler. */
     58typedef struct RTFUZZTGTRECINT   *RTFUZZTGTREC;
     59/** Pointer to a fuzzer target recorder handle. */
     60typedef RTFUZZTGTREC             *PRTFUZZTGTREC;
     61/** NIL fuzzer target recorder handle. */
     62#define NIL_RTFUZZTGTREC         ((RTFUZZTGTREC)~(uintptr_t)0)
     63/** A fuzzed target state handle. */
     64typedef struct RTFUZZTGTSTATEINT *RTFUZZTGTSTATE;
     65/** Pointer to a fuzzed target state handle. */
     66typedef RTFUZZTGTSTATE           *PRTFUZZTGTSTATE;
     67/** NIL fuzzed target state handle. */
     68#define NIL_RTFUZZTGTSTATE       ((RTFUZZTGTSTATE)~(uintptr_t)0)
    5569
    5670
    5771/** Fuzzing observer handle. */
    58 typedef struct RTFUZZOBSINT    *RTFUZZOBS;
     72typedef struct RTFUZZOBSINT      *RTFUZZOBS;
    5973/** Pointer to a fuzzing observer handle. */
    60 typedef RTFUZZOBS              *PRTFUZZOBS;
     74typedef RTFUZZOBS                *PRTFUZZOBS;
    6175/** NIL fuzzing observer handle. */
    62 #define NIL_RTFUZZOBS           ((RTFUZZOBS)~(uintptr_t)0)
     76#define NIL_RTFUZZOBS             ((RTFUZZOBS)~(uintptr_t)0)
    6377
    6478
     
    319333
    320334/**
    321  * Releases a reference from the given fuzzing input handle, destroying it when reaaching 0.
     335 * Releases a reference from the given fuzzing input handle, destroying it when reaching 0.
    322336 *
    323337 * @returns New reference count on success, 0 if the fuzzing input got destroyed.
     
    383397 */
    384398RTDECL(int) RTFuzzInputRemoveFromCtxCorpus(RTFUZZINPUT hFuzzInput);
     399
     400
     401/**
     402 * Creates a new fuzzed target recorder.
     403 *
     404 * @returns IPRT status code.
     405 * @param   phFuzzTgtRec        Where to store the handle to the fuzzed target recorder on success.
     406 */
     407RTDECL(int) RTFuzzTgtRecorderCreate(PRTFUZZTGTREC phFuzzTgtRec);
     408
     409/**
     410 * Retains a reference to the given fuzzed target recorder handle.
     411 *
     412 * @returns New reference count on success.
     413 * @param   hFuzzTgtRec         The fuzzed target recorder handle.
     414 */
     415RTDECL(uint32_t) RTFuzzTgtRecorderRetain(RTFUZZTGTREC hFuzzTgtRec);
     416
     417/**
     418 * Releases a reference from the given fuzzed target recorder handle, destroying it when reaching 0.
     419 *
     420 * @returns New reference count on success, 0 if the fuzzed target recorder got destroyed.
     421 * @param   hFuzzTgtRec         The fuzzed target recorder handle.
     422 */
     423RTDECL(uint32_t) RTFuzzTgtRecorderRelease(RTFUZZTGTREC hFuzzTgtRec);
     424
     425/**
     426 * Creates a new empty fuzzed target state.
     427 *
     428 * @returns IPRT status code.
     429 * @param   hFuzzTgtRec         The fuzzed target recorder handle.
     430 * @param   phFuzzTgtState      Where to store the handle to the fuzzed target state on success.
     431 */
     432RTDECL(int) RTFuzzTgtRecorderCreateNewState(RTFUZZTGTREC hFuzzTgtRec, PRTFUZZTGTSTATE phFuzzTgtState);
     433
     434/**
     435 * Retains a reference to the given fuzzed target state handle.
     436 *
     437 * @returns New reference count on success.
     438 * @param   hFuzzTgtState       The fuzzed target state handle.
     439 */
     440RTDECL(uint32_t) RTFuzzTgtStateRetain(RTFUZZTGTSTATE hFuzzTgtState);
     441
     442/**
     443 * Releases a reference from the given fuzzed target state handle, destroying it when reaching 0.
     444 *
     445 * @returns New reference count on success, 0 if the fuzzed target recorder got destroyed.
     446 * @param   hFuzzTgtState       The fuzzed target state handle.
     447 */
     448RTDECL(uint32_t) RTFuzzTgtStateRelease(RTFUZZTGTSTATE hFuzzTgtState);
     449
     450/**
     451 * Resets the given fuzzed target state to an empty state (keeping allocated memory).
     452 *
     453 * @returns IPRT status code.
     454 * @param   hFuzzTgtState       The fuzzed target state handle.
     455 *
     456 * @note Useful when the state is not added to the recorded set to avoid allocating memory.
     457 */
     458RTDECL(int) RTFuzzTgtStateReset(RTFUZZTGTSTATE hFuzzTgtState);
     459
     460/**
     461 * Finalizes the given fuzzed target state, making it readonly.
     462 *
     463 * @returns IPRT status code.
     464 * @param   hFuzzTgtState       The fuzzed target state handle.
     465 */
     466RTDECL(int) RTFuzzTgtStateFinalize(RTFUZZTGTSTATE hFuzzTgtState);
     467
     468/**
     469 * Adds the given state to the set for the owning target recorder.
     470 *
     471 * @returns IPRT status code.
     472 * @retval  VERR_ALREADY_EXISTS if the state is already existing in the recorder set.
     473 * @param   hFuzzTgtState       The fuzzed target state handle.
     474 *
     475 * @note This also finalizes the target state if not already done.
     476 */
     477RTDECL(int) RTFuzzTgtStateAddToRecorder(RTFUZZTGTSTATE hFuzzTgtState);
     478
     479/**
     480 * Appends the given stdout output to the given target state.
     481 *
     482 * @returns IPRT status code.
     483 * @param   hFuzzTgtState       The fuzzed target state handle.
     484 * @param   pvStdOut            Pointer to the stdout data buffer.
     485 * @param   cbStdOut            Size of the stdout data buffer in bytes.
     486 */
     487RTDECL(int) RTFuzzTgtStateAppendStdoutFromBuf(RTFUZZTGTSTATE hFuzzTgtState, const void *pvStdOut, size_t cbStdOut);
     488
     489/**
     490 * Appends the given stderr output to the given target state.
     491 *
     492 * @returns IPRT status code.
     493 * @param   hFuzzTgtState       The fuzzed target state handle.
     494 * @param   pvStdErr            Pointer to the stderr data buffer.
     495 * @param   cbStdErr            Size of the stderr data buffer in bytes.
     496 */
     497RTDECL(int) RTFuzzTgtStateAppendStderrFromBuf(RTFUZZTGTSTATE hFuzzTgtState, const void *pvStdErr, size_t cbStdErr);
     498
     499/**
     500 * Appends the given stdout output to the given target state, reading from the given pipe.
     501 *
     502 * @returns IPRT status code.
     503 * @param   hFuzzTgtState       The fuzzed target state handle.
     504 * @param   hPipe               The stdout pipe to read the data from.
     505 */
     506RTDECL(int) RTFuzzTgtStateAppendStdoutFromPipe(RTFUZZTGTSTATE hFuzzTgtState, RTPIPE hPipe);
     507
     508/**
     509 * Appends the given stderr output to the given target state, reading from the given pipe.
     510 *
     511 * @returns IPRT status code.
     512 * @param   hFuzzTgtState       The fuzzed target state handle.
     513 * @param   hPipe               The stdout pipe to read the data from.
     514 */
     515RTDECL(int) RTFuzzTgtStateAppendStderrFromPipe(RTFUZZTGTSTATE hFuzzTgtState, RTPIPE hPipe);
    385516
    386517
  • trunk/include/iprt/mangling.h

    r77509 r77544  
    10631063# define RTFuzzObsSetTestBinaryArgs                     RT_MANGLER(RTFuzzObsSetTestBinaryArgs)
    10641064# define RTFuzzObsSetTmpDirectory                       RT_MANGLER(RTFuzzObsSetTmpDirectory)
     1065# define RTFuzzTgtRecorderCreate                        RT_MANGLER(RTFuzzTgtRecorderCreate)
     1066# define RTFuzzTgtRecorderCreateNewState                RT_MANGLER(RTFuzzTgtRecorderCreateNewState)
     1067# define RTFuzzTgtRecorderRelease                       RT_MANGLER(RTFuzzTgtRecorderRelease)
     1068# define RTFuzzTgtRecorderRetain                        RT_MANGLER(RTFuzzTgtRecorderRetain)
     1069# define RTFuzzTgtStateAddToRecorder                    RT_MANGLER(RTFuzzTgtStateAddToRecorder)
     1070# define RTFuzzTgtStateAppendStderrFromBuf              RT_MANGLER(RTFuzzTgtStateAppendStderrFromBuf)
     1071# define RTFuzzTgtStateAppendStderrFromPipe             RT_MANGLER(RTFuzzTgtStateAppendStderrFromPipe)
     1072# define RTFuzzTgtStateAppendStdoutFromBuf              RT_MANGLER(RTFuzzTgtStateAppendStdoutFromBuf)
     1073# define RTFuzzTgtStateAppendStdoutFromPipe             RT_MANGLER(RTFuzzTgtStateAppendStdoutFromPipe)
     1074# define RTFuzzTgtStateFinalize                         RT_MANGLER(RTFuzzTgtStateFinalize)
     1075# define RTFuzzTgtStateRelease                          RT_MANGLER(RTFuzzTgtStateRelease)
     1076# define RTFuzzTgtStateReset                            RT_MANGLER(RTFuzzTgtStateReset)
     1077# define RTFuzzTgtStateRetain                           RT_MANGLER(RTFuzzTgtStateRetain)
    10651078# define RTGetOpt                                       RT_MANGLER(RTGetOpt)
    10661079# define RTGetOptArgvFree                               RT_MANGLER(RTGetOptArgvFree)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette