This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

setrlimit change to prlimit change in behavior?


Hi,

I observed a, probably silly, change in behavior while running the
valgrind testsuite on a RHEL7 setup using linux 3.10 and glibc 2.17 and
a Fedora27 (beta) setup using linux 4.13 and glibc 2.26.

The valgrind testsuite has a testcase that checks that
 setrlimit (RLIMIT_NOFILE, NULL)
returns failure and sets errno to EFAULT.

Which it does on RHEL7, but on Fedora27 this silently returns success.

I suspect that this was caused by commit 695d7d138 "Assume prlimit64 is
available" which turns setrlimit (RLIMIT_NOFILE, NULL) into prlimit (0,
RLIMIT_NOFILE, NULL, NULL).

The man page http://man7.org/linux/man-pages/man2/prlimit.2.html
doesn't really make clear what happens if both old_limit and new_limit
are NULL. But apparently the kernel interprets that as a NOP. Or maybe
a check to see if you would have permission to get/set the limit for
the given pid. But that is zero here, which means, your own process.

There is probably no other code than the valgrind testsuite that
depends on this particular behavior of getting an EFAULT for a NULL
argument to setrlimit. And we could easily change the testcase. But
maybe someone sees a real issue in this change of behavior?

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]