VirtualBox

Changeset 72940 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Jul 7, 2018 1:37:19 PM (7 years ago)
Author:
vboxsync
Message:

Runtime/RTFuzz: Some updates, add a mode where the client is aware of being fuzzed for improved efficiency. The input data is fuzzed in the client and fed to the consumer until the program crashes upon the master can reconstruct the input causing the crash because we work with deterministic random number generators. This eliminates the overhead of constantly spawning new client processes.

Location:
trunk/include/iprt
Files:
2 edited

Legend:

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

    r72649 r72940  
    222222
    223223/**
     224 * Reseeds the PRNG of the given fuzzing context.
     225 *
     226 * @returns IPRT status code.
     227 * @param   hFuzzCtx            The fuzzing context handle.
     228 * @param   uSeed               The new seed.
     229 */
     230RTDECL(int) RTFuzzCtxReseed(RTFUZZCTX hFuzzCtx, uint64_t uSeed);
     231
     232/**
    224233 * Generates a new input from the given fuzzing context and returns it.
    225234 *
     
    230239RTDECL(int) RTFuzzCtxInputGenerate(RTFUZZCTX hFuzzCtx, PRTFUZZINPUT phFuzzInput);
    231240
     241/**
     242 * Mutates a raw buffer.
     243 *
     244 * @returns IPRT status code.
     245 * @param   hFuzzCtx            The fuzzing context handle.
     246 * @param   pvBuf               Pointer to the buffer to mutate.
     247 * @param   cbBuf               Size of the buffer iny bytes to mutate.
     248 * @param   phFuzzInput         Where to store the handle to the fuzzed input on success.
     249 */
     250RTDECL(int) RTFuzzCtxMutateBuffer(RTFUZZCTX hFuzzCtx, void *pvBuf, size_t cbBuf,
     251                                  PRTFUZZINPUT phFuzzInput);
    232252
    233253
     
    296316RTDECL(int) RTFuzzInputRemoveFromCtxCorpus(RTFUZZINPUT hFuzzInput);
    297317
     318
     319/**
     320 * Fuzzed binary input channel.
     321 */
     322typedef enum RTFUZZOBSINPUTCHAN
     323{
     324    /** Invalid. */
     325    RTFUZZOBSINPUTCHAN_INVALID = 0,
     326    /** File input. */
     327    RTFUZZOBSINPUTCHAN_FILE,
     328    /** Input over stdin. */
     329    RTFUZZOBSINPUTCHAN_STDIN,
     330    /** The binary is a fuzzing aware client using the
     331     * specified protocol over stdin/stdout. */
     332    RTFUZZOBSINPUTCHAN_FUZZING_AWARE_CLIENT,
     333    /** TCP server. */
     334    RTFUZZOBSINPUTCHAN_TCP_SERVER,
     335    /** TCP client. */
     336    RTFUZZOBSINPUTCHAN_TCP_CLIENT,
     337    /** UDP server. */
     338    RTFUZZOBSINPUTCHAN_UDP_SERVER,
     339    /** UDP client. */
     340    RTFUZZOBSINPUTCHAN_UDP_CLIENT,
     341    /** 32bit hack. */
     342    RTFUZZOBSINPUTCHAN_32BIT_HACK = 0x7fffffff
     343} RTFUZZOBSINPUTCHAN;
    298344
    299345/**
     
    359405RTDECL(int) RTFuzzObsSetTmpDirectory(RTFUZZOBS hFuzzObs, const char *pszTmp);
    360406
    361 
    362407/**
    363408 * Sets the directory to store results to.
     
    369414RTDECL(int) RTFuzzObsSetResultDirectory(RTFUZZOBS hFuzzObs, const char *pszResults);
    370415
    371 
    372416/**
    373417 * Sets the binary to run for each fuzzed input.
     
    376420 * @param   hFuzzObs            The fuzzing observer handle.
    377421 * @param   pszBinary           The binary path.
    378  * @param   fFlags              Flags controlling execution of the binary, RTFUZZ_OBS_BINARY_F_XXX.
    379  */
    380 RTDECL(int) RTFuzzObsSetTestBinary(RTFUZZOBS hFuzzObs, const char *pszBinary, uint32_t fFlags);
    381 
    382 /** @name RTFUZZ_OBS_BINARY_F_XXX
    383  * @{ */
    384 /** The tested binary requires a real file to read from and doesn't support stdin. */
    385 #define RTFUZZ_OBS_BINARY_F_INPUT_FILE  RT_BIT_32(0)
    386 /** @} */
     422 * @param   enmInputChan        The input channel to use.
     423 */
     424RTDECL(int) RTFuzzObsSetTestBinary(RTFUZZOBS hFuzzObs, const char *pszBinary, RTFUZZOBSINPUTCHAN enmInputChan);
    387425
    388426/**
     
    426464RTR3DECL(RTEXITCODE) RTFuzzCmdMaster(unsigned cArgs, char **papszArgs);
    427465
     466
     467/**
     468 * Client input consumption callback.
     469 *
     470 * @returns IPRT status code.
     471 * @retval  VINF_SUCCESS the fuzzed code accepted the input.
     472 * @retval  VERR_* the client rejected the input while parsing it.
     473 * @param   pvBuf               The buffer containing the input data.
     474 * @param   cbBuf               Size of the buffer in bytes.
     475 * @param   pvUser              Opaque user data.
     476 */
     477typedef DECLCALLBACK(int) FNFUZZCLIENTCONSUME(const void *pvBuf, size_t cbBuf, void *pvUser);
     478/** Pointer to a client consumption callback. */
     479typedef FNFUZZCLIENTCONSUME *PFNFUZZCLIENTCONSUME;
     480
     481/**
     482 * A fuzzing client program for more efficient fuzzing.
     483 *
     484 * @returns Program exit code.
     485 *
     486 * @param   cArgs               The number of arguments.
     487 * @param   papszArgs           The argument vector.  (Note that this may be
     488 *                              reordered, so the memory must be writable.)
     489 * @param   pfnConsume          Input data consumption callback.
     490 * @param   pvUser              Opaque user data to pass to the callback.
     491 */
     492RTR3DECL(RTEXITCODE) RTFuzzCmdFuzzingClient(unsigned cArgs, char **papszArgs, PFNFUZZCLIENTCONSUME pfnConsume, void *pvUser);
    428493/** @} */
    429494
  • trunk/include/iprt/mangling.h

    r72778 r72940  
    10231023# define RTFuzzCtxCreateFromStateFile                   RT_MANGLER(RTFuzzCtxCreateFromStateFile)
    10241024# define RTFuzzCtxInputGenerate                         RT_MANGLER(RTFuzzCtxInputGenerate)
     1025# define RTFuzzCtxMutateBuffer                          RT_MANGLER(RTFuzzCtxMutateBuffer)
    10251026# define RTFuzzCtxRelease                               RT_MANGLER(RTFuzzCtxRelease)
     1027# define RTFuzzCtxReseed                                RT_MANGLER(RTFuzzCtxReseed)
    10261028# define RTFuzzCtxRetain                                RT_MANGLER(RTFuzzCtxRetain)
    10271029# define RTFuzzCtxStateExport                           RT_MANGLER(RTFuzzCtxStateExport)
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