VirtualBox

Changeset 83428 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Mar 25, 2020 7:44:11 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
136647
Message:

Runtime/RTFuzzCfg: Initial implementation of API for configuring a fuzzing context. The config and input corpus is stored in a single tarball to keep things easy to pass around [missing files]

Location:
trunk/include/iprt
Files:
2 edited

Legend:

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

    r83266 r83428  
    5454/** NIL fuzzer input handle. */
    5555#define NIL_RTFUZZINPUT          ((RTFUZZINPUT)~(uintptr_t)0)
     56
     57
     58/** A fuzzer config handle. */
     59typedef struct RTFUZZCFGINT      *RTFUZZCFG;
     60/** Pointer to a fuzzer config handle. */
     61typedef RTFUZZCFG                *PRTFUZZCFG;
     62/** NIL fuzzer config handle. */
     63#define NIL_RTFUZZCFG            ((RTFUZZCFG)~(uintptr_t)0)
    5664
    5765
     
    142150
    143151
     152/** @name RTFUZZCFG_IMPORT_F_XXX - Flags for RTFuzzCfgImport().
     153 * @{ */
     154/** Default flags. */
     155#define RTFUZZCFG_IMPORT_F_DEFAULT                 0
     156/** Adds only the inputs and doesn't set any glboal configuration flags of the fuzzing context. */
     157#define RTFUZZCFG_IMPORT_F_ONLY_INPUT              RT_BIT_32(0)
     158/** Mask of all valid flags. */
     159#define RTFUZZCFG_IMPORT_F_VALID                   UINT32_C(0x00000001)
     160/** @} */
     161
     162
    144163/**
    145164 * Fuzzing context state export callback.
     
    332351
    333352/**
     353 * Adds a new seed to the input corpus of the given fuzzing context from the given VFS I/O stream.
     354 *
     355 * @returns IPRT status code.
     356 * @param   hFuzzCtx            The fuzzing context handle.
     357 * @param   hVfsIos             The VFS I/O stream handle to load the seed from.
     358 */
     359RTDECL(int) RTFuzzCtxCorpusInputAddFromVfsIoStrm(RTFUZZCTX hFuzzCtx, RTVFSIOSTREAM hVfsIos);
     360
     361/**
     362 * Adds a new seed to the input corpus of the given fuzzing context from the given VFS I/O stream - extended version.
     363 *
     364 * @returns IPRT status code.
     365 * @param   hFuzzCtx            The fuzzing context handle.
     366 * @param   hVfsIos             The VFS I/O stream handle to load the seed from.
     367 * @param   offMutStart         Start offset at which a mutation can happen.
     368 * @param   cbMutRange          Size of the range in bytes where a mutation can happen,
     369 *                              use UINT64_MAX to allow mutations till the end of the input.
     370 */
     371RTDECL(int) RTFuzzCtxCorpusInputAddFromVfsIoStrmEx(RTFUZZCTX hFuzzCtx, RTVFSIOSTREAM hVfsIos,
     372                                                   uint64_t offMutStart, uint64_t cbMutRange);
     373
     374/**
    334375 * Adds new seeds to the input corpus of the given fuzzing context from the given directory.
    335376 *
     
    497538 */
    498539RTDECL(int) RTFuzzInputRemoveFromCtxCorpus(RTFUZZINPUT hFuzzInput);
     540
     541
     542/**
     543 * Creates a fuzzing config from the given VFS file handle.
     544 *
     545 * @returns IPRT status code.
     546 * @param   phFuzzCfg           Where to store the handle to the fuzzing config on success.
     547 * @param   hVfsFile            The VFS file to use (retained).
     548 * @param   pErrInfo            Where to store extended error info. Optional.
     549 */
     550RTDECL(int) RTFuzzCfgCreateFromVfsFile(PRTFUZZCFG phFuzzCfg, RTVFSFILE hVfsFile, PRTERRINFO pErrInfo);
     551
     552/**
     553 * Creates a fuzzing config from the given file path.
     554 *
     555 * @returns IPRT status code.
     556 * @param   phFuzzCfg           Where to store the handle to the fuzzing config on success.
     557 * @param   pszFilename         Filename to load the config from.
     558 * @param   pErrInfo            Where to store extended error info. Optional.
     559 */
     560RTDECL(int) RTFuzzCfgCreateFromFile(PRTFUZZCFG phFuzzCfg, const char *pszFilename, PRTERRINFO pErrInfo);
     561
     562/**
     563 * Retains a reference to the given fuzzing config.
     564 *
     565 * @returns New reference count on success.
     566 * @param   hFuzzCfg            Handle of the fuzzing config.
     567 */
     568RTDECL(uint32_t) RTFuzzCfgRetain(RTFUZZCFG hFuzzCfg);
     569
     570/**
     571 * Releases a reference from the given fuzzing config, destroying it when reaching 0.
     572 *
     573 * @returns New reference count on success, 0 if the fuzzing config got destroyed.
     574 * @param   hFuzzCfg            Handle of the fuzzing config.
     575 */
     576RTDECL(uint32_t) RTFuzzCfgRelease(RTFUZZCFG hFuzzCfg);
     577
     578/**
     579 * Imports the given fuzzing config into a previously created fuzzing context.
     580 *
     581 * @returns IPRT status code.
     582 * @param   hFuzzCfg            Handle of the fuzzing config.
     583 * @param   hFuzzCtx            Handle of the fuzzing context.
     584 * @param   fFlags              Flags controlling what to import exactly, combination of RTFUZZCFG_IMPORT_F_XXX.
     585 */
     586RTDECL(int) RTFuzzCfgImport(RTFUZZCFG hFuzzCfg, RTFUZZCTX hFuzzCtx, uint32_t fFlags);
     587
     588/**
     589 * Queries the custom config for the controller of the fuzzing process.
     590 *
     591 * @returns IPRT status code.
     592 * @param   hFuzzCfg            Handle of the fuzzing config.
     593 * @param   phVfsFile           Where to store the handle of the VFS file containing the custom config.
     594 */
     595RTDECL(int) RTFuzzCfgQueryCustomCfg(RTFUZZCFG hFuzzCfg, PRTVFSFILE phVfsFile);
    499596
    500597
  • trunk/include/iprt/mangling.h

    r83426 r83428  
    10571057# define RTFuzzCtxCorpusInputAddFromFileEx              RT_MANGLER(RTFuzzCtxCorpusInputAddFromFileEx)
    10581058# define RTFuzzCtxCorpusInputAddFromVfsFile             RT_MANGLER(RTFuzzCtxCorpusInputAddFromVfsFile)
    1059 # define RTFuzzCtxCorpusInputAddFromVfsFileEx           RT_MANGER(RTFuzzCtxCorpusInputAddFromVfsFileEx)
     1059# define RTFuzzCtxCorpusInputAddFromVfsFileEx           RT_MANGLER(RTFuzzCtxCorpusInputAddFromVfsFileEx)
     1060# define RTFuzzCtxCorpusInputAddFromVfsIoStrm           RT_MANGLER(RTFuzzCtxCorpusInputAddFromVfsIoStrm)
     1061# define RTFuzzCtxCorpusInputAddFromVfsIoStrmEx         RT_MANGLER(RTFuzzCtxCorpusInputAddFromVfsIoStrmEx)
    10601062# define RTFuzzCtxCreate                                RT_MANGLER(RTFuzzCtxCreate)
    10611063# define RTFuzzCtxCreateFromState                       RT_MANGLER(RTFuzzCtxCreateFromState)
Note: See TracChangeset for help on using the changeset viewer.

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