Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

James-A-Clark
Copy link

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 <[email protected]>
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 <[email protected]>
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