From 8258014fd1e34e942a549c88c7e022a00445c352 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Fri, 30 May 2014 08:47:35 +0200 Subject: fix for broken kernel side RLIM_INFINITY on mips On 32 bit mips the kernel uses -1UL/2 to mark RLIM_INFINITY (and this is the definition in the userspace api), but since it is in the middle of the valid range of limits and limits are often compared with relational operators, various kernel side logic is broken if larger than -1UL/2 limits are used. So we truncate the limits to -1UL/2 in get/setrlimit and prlimit. Even if the kernel side logic consistently treated -1UL/2 as greater than any other limit value, there wouldn't be any clean workaround that allowed using large limits: * using -1UL/2 as RLIM_INFINITY in userspace would mean different infinity value for get/setrlimt and prlimit (where infinity is always -1ULL) and userspace logic could break easily (just like the kernel is broken now) and more special case code would be needed for mips. * translating -1UL/2 kernel side value to -1ULL in userspace would mean that -1UL/2 limit cannot be set (eg. -1UL/2+1 had to be passed to the kernel instead). --- arch/mips/syscall_arch.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/mips') diff --git a/arch/mips/syscall_arch.h b/arch/mips/syscall_arch.h index c52976eb..e62c3398 100644 --- a/arch/mips/syscall_arch.h +++ b/arch/mips/syscall_arch.h @@ -5,6 +5,8 @@ long (__syscall)(long, ...); +#define SYSCALL_RLIM_INFINITY (-1UL/2) + #ifndef __clang__ #define __asm_syscall(...) do { \ -- cgit v1.2.1