This is an archive of the discontinued LLVM Phabricator instance.

Add new interceptors: getttyent(3) family
ClosedPublic

Authored by krytarowski on Feb 20 2018, 5:03 PM.

Details

Summary

getttyent, getttynam, setttyentpath - get ttys file entry

Reuse them on NetBSD.

Sponsored by <The NetBSD Foundation>

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Feb 20 2018, 5:03 PM
vitalybuka accepted this revision.Feb 25 2018, 2:09 PM

LGTM if you address my comments

lib/sanitizer_common/sanitizer_common_interceptors.inc
6859

struct __sanitizer_ttyent *ttyent = REAL...
here and below

6860

please no brackets here and below

6877

it does not check anything, why do you want to intercept it?
same for endttyent

7132

Could you please convert this peace into INIT_ style?
As a separate patch.
Trivial but I can't be sure that it compiles if I do it myself.

test/sanitizer_common/TestCases/NetBSD/getttyent.cc
5 ↗(On Diff #135172)

maybe ttyent.cc is better name
same for INIT_GETTTYENT->INIT_TTYENT

This revision is now accepted and ready to land.Feb 25 2018, 2:09 PM
vitalybuka added inline comments.Feb 25 2018, 2:11 PM
test/sanitizer_common/TestCases/NetBSD/getttyent.cc
13 ↗(On Diff #135172)

test would be cleaner without
if (!typ) exit(1);

if it nullptr it will fail anyway at printf

45 ↗(On Diff #135172)

Could you please combine declaration and initialization here and the rest?
struct ttyent *typ = getttyent();

krytarowski added inline comments.Feb 25 2018, 2:13 PM
lib/sanitizer_common/sanitizer_common_interceptors.inc
6877

Disable recursive interceptors.

7132

Do you mean, __libc_mutex_lock and the others bellow?

vitalybuka added inline comments.Feb 25 2018, 2:55 PM
test/sanitizer_common/TestCases/NetBSD/getttyent.cc
77 ↗(On Diff #135172)

Maybe some checks if you print it?

vitalybuka requested changes to this revision.Feb 25 2018, 2:59 PM

I'll make it red for consistency and promise to look again ASAP.

lib/sanitizer_common/sanitizer_platform_interceptors.h
464

Why only NETBSD?

This revision now requires changes to proceed.Feb 25 2018, 2:59 PM
krytarowski added inline comments.Feb 25 2018, 10:33 PM
lib/sanitizer_common/sanitizer_platform_interceptors.h
464

I can assure only NetBSD. Feel free to switch it to POSIX or other combination of OSes in a new commit.

test/sanitizer_common/TestCases/NetBSD/getttyent.cc
77 ↗(On Diff #135172)

I was thinking about it, however this setup uses the global configuration of a system that might be (and usually is) customized. It's easier with e.g. protoent, as protocol entries aren't usually modified.

apply comments from review

  • add missing changes to sanitizer_platform_limits_netbsd
  • fix a typo
krytarowski marked 2 inline comments as done.Feb 26 2018, 1:25 AM
  • drop interceptors for setttyent(3) and endttyent(3)
krytarowski marked 2 inline comments as done.Feb 26 2018, 1:40 AM
krytarowski edited the summary of this revision. (Show Details)Feb 26 2018, 5:53 AM
vitalybuka requested changes to this revision.Feb 26 2018, 10:02 AM
vitalybuka added inline comments.
lib/sanitizer_common/sanitizer_common_interceptors.inc
6859

unchanged

struct __sanitizer_ttyent *ttyent = REAL... here and below

6860

unchanged

please no brackets here and below

6877

I don't see how this helps.
Also you already removed such empty interceptors from other patches.

7132

Yes.

Do you mean, __libc_mutex_lock and the others bellow?

lib/sanitizer_common/sanitizer_platform_interceptors.h
464

I can assure only NetBSD. Feel free to switch it to POSIX or other combination of OSes in a new commit.

SGTM

test/sanitizer_common/TestCases/NetBSD/getttyent.cc
13 ↗(On Diff #135172)

also unchanged

This revision now requires changes to proceed.Feb 26 2018, 10:02 AM

@vitalybuka I think you have reviewed an older snapshot. All the mentioned now issues are gone.

I've retested the interceptors without arguments and the code still works fine.

vitalybuka accepted this revision.Feb 26 2018, 6:01 PM

Sorry. I am not sure how did this happen.

This revision is now accepted and ready to land.Feb 26 2018, 6:01 PM

I will add test name to CHECK in the test, and commit all three tests.

This revision was automatically updated to reflect the committed changes.