Page MenuHomePhabricator

[Sanitizers] intercept ttyent api on FreeBSD
ClosedPublic

Authored by devnexen on Sep 15 2021, 12:13 PM.

Diff Detail

Event Timeline

devnexen created this revision.Sep 15 2021, 12:13 PM
devnexen requested review of this revision.Sep 15 2021, 12:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2021, 12:13 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
devnexen updated this revision to Diff 373020.Sep 16 2021, 11:45 AM
devnexen updated this revision to Diff 373272.Sep 17 2021, 10:16 AM
vitalybuka added inline comments.Sep 20 2021, 8:22 AM
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
7558

More consistent solution is to introduce
SANITIZER_INTERCEPT_SETTTYENTPATH

Actually this part disables setttyentpath on anything but FreeBSD. Is this intentional?

compiler-rt/test/sanitizer_common/TestCases/FreeBSD/ttyent.cpp
24–31 ↗(On Diff #373272)

can you please extract freebsd specific part into a separate file and move common stuff into Posix or Linux?

devnexen added inline comments.Sep 22 2021, 8:18 AM
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
7558

yes it is intentional this subpart is unsupported but ok about the new flag

devnexen updated this revision to Diff 374289.Sep 22 2021, 10:37 AM
krytarowski added inline comments.Sep 22 2021, 3:43 PM
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
7558

Please keep it enabled in NetBSD.

devnexen added inline comments.Sep 23 2021, 4:09 AM
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
7558

It s enabled with a separated flag

vitalybuka accepted this revision.Sep 23 2021, 3:26 PM
vitalybuka added inline comments.
compiler-rt/test/sanitizer_common/TestCases/Linux/ttyent.cpp
38–58

Can this be like:

void test4() {
#if defined(__NetBSD__)
  if (!setttyentpath(_PATH_TTYS))
    exit(1);
#else
  return;
#endif

  struct ttyent *typ = getttyent();
  assert(typ && typ->ty_name != nullptr);
  assert(typ->ty_type != nullptr);
  assert(typ->ty_class != nullptr);

  endttyent();
}

int main(void) {
  test1();
  test2();
  test3();
  test4();
This revision is now accepted and ready to land.Sep 23 2021, 3:26 PM
devnexen added inline comments.Sep 23 2021, 8:21 PM
compiler-rt/test/sanitizer_common/TestCases/Linux/ttyent.cpp
38–58

unfortunately I would have to ifdef the last member check which is netbsd specific.

This revision was landed with ongoing or failed builds.Sep 23 2021, 8:27 PM
This revision was automatically updated to reflect the committed changes.