Skip to content

fuzzer: Supply mode argument to open() when required to#25

Open
James-A-Clark wants to merge 1 commit into
deater:masterfrom
James-A-Clark:master
Open

fuzzer: Supply mode argument to open() when required to#25
James-A-Clark wants to merge 1 commit into
deater:masterfrom
James-A-Clark:master

Conversation

@James-A-Clark

Copy link
Copy Markdown

Hi,

I noticed that the default behaviour on some configs of libc is to terminate when there is an issue
with the open() flags. This change allows the fuzzer to run instead of instantly quitting
in that case.

See the commit message for more details.

Thanks
James

When FORTIFY_SOURCE is enabled, libc will terminate the process on
a call to open() with flags that require a mode argument but it's
not provided. Here is the relevant part of the glibc docs:

  The mode argument must be supplied if O_CREAT or O_TMPFILE is
  specified in flags; if it is not supplied, some arbitrary
  bytes from the stack will be applied as the file mode.

And this is what it looks like when running the fuzzer:

  ==================================================
  Starting fuzzing at 2022-03-17 13:15:53
  ==================================================
  *** invalid open call: O_CREAT or O_TMPFILE without mode ***: ./perf_fuzzer terminated
  Aborted

Fix this by supplying a mode argument when the random flags indicate
it's required. The actual mode is not important because files can't
be created in sysfs.

Signed-off-by: James Clark <james.clark@arm.com>
rli9 added a commit to intel/lkp-tests that referenced this pull request May 25, 2023
Below issue at least occurs on glibc 2.28.

*** invalid open call: O_CREAT or O_TMPFILE without mode ***: terminated
Aborted

Link: deater/perf_event_tests#25
Signed-off-by: Philip Li <philip.li@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant