Bug 294047 - valgrind does not correctly emulate prlimit64(..., RLIMIT_NOFILE, ...)
Summary: valgrind does not correctly emulate prlimit64(..., RLIMIT_NOFILE, ...)
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
: 275673 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-02-14 07:50 UTC by Matthias Schwarzott
Modified: 2012-09-24 20:52 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
valgrind-improve-prlimit64-v5.patch (11.31 KB, patch)
2012-02-18 10:13 UTC, Matthias Schwarzott
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Schwarzott 2012-02-14 07:50:29 UTC
Version:           unspecified
OS:                Linux

The prlimit64 syscall is not correctly emulated by valgrind.
On 32bit platforms setrlimit64 and getrlimit64 are implemented using prlimit64.


Reproducible: Always

Steps to Reproduce:
Lowering RLIMIT_NOFILE using prlimit64.


Actual Results:  
valgrind can no longer open private files, as fcntl(FD_DUPFD, ...) will fail.


Expected Results:  
prlimit64 should work equivalent to setrlimit and getrlimit.
Comment 1 Matthias Schwarzott 2012-02-18 10:13:01 UTC
Created attachment 68897 [details]
valgrind-improve-prlimit64-v5.patch

The attached patch does this:
Change prlimit64 to behave like a combination of the existing setrlimit and getrlimit.
Run emulation only if ARG0 (pid) is 0 or equal getpid()
improve setrlimit (like new prlimit64) to return EINVAL if softlimit>hardlimit
Add tests (using getrlimit64 and setrlimit64)

TODO: Tests using prlimit and prlimit64 (perhaps with different pid
values)

on x86:
getrlimit -> syscall getrlimit
setrlimit -> syscall setrlimit
prlimit -> syscall prlimit64
getrlimit64 -> syscall prlimit64
setrlimit64 -> syscall prlimit64
prlimit64 -> syscall prlimit64

on amd64:
getrlimit -> syscall getrlimit
setrlimit -> syscall setrlimit
prlimit -> syscall prlimit64
getrlimit64 -> syscall getrlimit
setrlimit64 -> syscall setrlimit
prlimit64 -> syscall prlimit64
Comment 2 Tom Hughes 2012-03-01 13:47:00 UTC
Committed as r12411.
Comment 3 Philippe Waroquiers 2012-09-24 20:52:12 UTC
*** Bug 275673 has been marked as a duplicate of this bug. ***