[libc-commits] [PATCH] D159104: [libc] Fix setrlimit/getrlimit on 32-bit systems
Mikhail Ramalho via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Aug 29 08:16:55 PDT 2023
mikhail.ramalho created this revision.
mikhail.ramalho added reviewers: michaelrj, sivachandra.
Herald added subscribers: libc-commits, asb, s.egerton, simoncook.
Herald added projects: libc-project, All.
mikhail.ramalho requested review of this revision.
Herald added a subscriber: wangpc.
libc uses SYS_prlimit64 (which takes a struct rlimit64) to implement
setrlimt and getrlimit (which take a struct rlimit). In 64-bit bits
systems this is not an issue since the members of struct rlimit64 and
struct rlimit are 64 bits long, however, in 32-bit systems the members
of struct rlimit are only 32 bits long, causing wrong values being
passed to SYS_prlimit64.
This patch adds new struct rlimit64 (and rlim64_t) to fix this issue.
We now create a local struct rlimit64 variable in setrlimt/getrlimit,
pass it to SYS_prlimit64 (and rewrite the original rlimit struct in
getrlimit if the syscall succeeds).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D159104
Files:
libc/config/linux/api.td
libc/include/CMakeLists.txt
libc/include/llvm-libc-types/CMakeLists.txt
libc/include/llvm-libc-types/rlim64_t.h
libc/include/llvm-libc-types/struct_rlimit64.h
libc/spec/posix.td
libc/src/sys/resource/linux/getrlimit.cpp
libc/src/sys/resource/linux/setrlimit.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159104.554357.patch
Type: text/x-patch
Size: 6225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230829/f61ec529/attachment-0001.bin>
More information about the libc-commits
mailing list