prlimit64: inconsistencies between kernel and userland
Hi,
There is an inconsistency in the definition of RLIM64_INFINITY between kernel and userland for the O32 and N32 ABI:
On the kernel side, the value is defined for all architectures as include/uapi/linux/resource.h:
| #define RLIM64_INFINITY (~0ULL)
On the GNU libc side, the value is defined in ports/sysdeps/unix/sysv/linux/mips/bits/resource.h:
For the O32 and N32 ABI:
| # define RLIM64_INFINITY 0x7fffffffffffffffULL
and for the N64 ABI:
| # define RLIM64_INFINITY 0xffffffffffffffffUL
This was not a problem until the prlimit64 syscall was wired in the 2.6.36 kernel. Since then, on a 64-bit kernel and an O32 or N32 userland, but not on a 32-bit kernel, this causes some issues for example it's not possible to set "ulimit -c unlimited" using dash as a non-priviledged user.
This is due to the fact that when available the glibc uses the prlimit64 syscall to implement setrlimit64, which is called from called from pam_limits.so. Instead of setting the limit to infinity (according to the userland), it is set to a very big value but still lower than infinity (according to the kernel). When later the setrlimit syscall is used to set the value to infinity, it gets an EPERM value as the kernel consider that as an increase of the limit (from a big value to infinity).
I don't know where the issue should be fixed. The GNU libc has this value for more than 7 years, and as it is defined in a header file, it means a lot of binaries are broken when used with a 2.6.36+ kernel. Fixing that on the kernel side means that MIPS would have a different value than other architectures.
How do you think the issue should be fixed?
Regards,
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Any news about this issue? It really starts to causes a lot of issues in Debian. I have added a Cc: to libc people so that we can also hear their opinion.
Thanks,
Aurelien
Quoted 50 lines · Aurelien Jarno
Hi,
There is an inconsistency in the definition of
RLIM64_INFINITYbetween kernel and userland for the O32 and N32 ABI:On the kernel side, the value is defined for all architectures as
include/uapi/linux/resource.h:| #define
RLIM64_INFINITY(~0ULL)On the GNU libc side, the value is defined in
ports/sysdeps/unix/sysv/linux/mips/bits/resource.h:For the O32 and N32 ABI:
| # define
RLIM64_INFINITY0x7fffffffffffffffULLand for the N64 ABI:
| # define
RLIM64_INFINITY0xffffffffffffffffULThis was not a problem until the prlimit64 syscall was wired in the 2.6.36 kernel. Since then, on a 64-bit kernel and an O32 or N32 userland, but not on a 32-bit kernel, this causes some issues for example it's not possible to set "ulimit -c unlimited" using dash as a non-priviledged user.
This is due to the fact that when available the glibc uses the prlimit64 syscall to implement setrlimit64, which is called from called from pam_limits.so. Instead of setting the limit to infinity (according to the userland), it is set to a very big value but still lower than infinity (according to the kernel). When later the setrlimit syscall is used to set the value to infinity, it gets an EPERM value as the kernel consider that as an increase of the limit (from a big value to infinity).
I don't know where the issue should be fixed. The GNU libc has this value for more than 7 years, and as it is defined in a header file, it means a lot of binaries are broken when used with a 2.6.36+ kernel. Fixing that on the kernel side means that MIPS would have a different value than other architectures.
How do you think the issue should be fixed?
Regards,
AurelienSignature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
From: Aurelien Jarno <[email protected]>
Date: Mon, 4 Nov 2013 22:37:56 +0100
Quoted 3 lines
Any news about this issue? It really starts to causes a lot of issues in Debian. I have added a Cc: to libc people so that we can also hear their opinion.
I had the same exact problem on sparc several years ago, I simply fixed the glibc header value, it's the only way to fix this.
Yes, that means you then have to recompile applications and libraries that reference this value.
Quoted 7 lines · David Miller
From: Aurelien Jarno <[email protected]>
Date: Mon, 4 Nov 2013 22:37:56 +0100Quoted 3 lines
Any news about this issue? It really starts to causes a lot of issues in Debian. I have added a Cc: to libc people so that we can also hear their opinion.
Quoted 5 lines
I had the same exact problem on sparc several years ago, I simply fixed the glibc header value, it's the only way to fix this.
Yes, that means you then have to recompile applications and libraries that reference this value.
Surely you can create new symbol versions for getrlimit64 and setrlimit64, with the old versions just using the 32-bit syscalls (or otherwise translating between conventions, but using the 32-bit syscalls is the simplest approach)? I see no need to break compatibility with existing binaries.
As I noted in
<https://sourceware.org/ml/libc-ports/2006-05/msg00020.html>, at that time the value of RLIM64_INFINITY for o32/n32 was purely a glibc convention the kernel didn't see at all. It's only with the use of newer syscalls that this glibc convention is any sort of problem.
Signature · 2 lines
Joseph S. Myers [email protected]
Quoted 21 lines · Joseph S. Myers
Quoted 7 lines · David Miller
From: Aurelien Jarno <[email protected]>
Date: Mon, 4 Nov 2013 22:37:56 +0100Quoted 3 lines
Any news about this issue? It really starts to causes a lot of issues in Debian. I have added a Cc: to libc people so that we can also hear their opinion.
Quoted 5 lines
I had the same exact problem on sparc several years ago, I simply fixed the glibc header value, it's the only way to fix this.
Yes, that means you then have to recompile applications and libraries that reference this value.
Surely you can create new symbol versions for getrlimit64 and setrlimit64, with the old versions just using the 32-bit syscalls (or otherwise translating between conventions, but using the 32-bit syscalls is the simplest approach)? I see no need to break compatibility with existing binaries.
Quoted 5 lines
As I noted in
<https://sourceware.org/ml/libc-ports/2006-05/msg00020.html>, at that time the value ofRLIM64_INFINITYfor o32/n32 was purely a glibc convention the kernel didn't see at all. It's only with the use of newer syscalls that this glibc convention is any sort of problem.
Why not just make them convert any value >= 0x7fffffffffffffff to infinity before making the syscall? There's certainly no meaningful use for finite values in that range...
Rich
Quoted 28 lines · * Rich Felker ([email protected]) [131105 02:22]:
Quoted 21 lines · Joseph S. Myers
Quoted 7 lines · David Miller
From: Aurelien Jarno <[email protected]>
Date: Mon, 4 Nov 2013 22:37:56 +0100Quoted 3 lines
Any news about this issue? It really starts to causes a lot of issues in Debian. I have added a Cc: to libc people so that we can also hear their opinion.
Quoted 5 lines
I had the same exact problem on sparc several years ago, I simply fixed the glibc header value, it's the only way to fix this.
Yes, that means you then have to recompile applications and libraries that reference this value.
Surely you can create new symbol versions for getrlimit64 and setrlimit64, with the old versions just using the 32-bit syscalls (or otherwise translating between conventions, but using the 32-bit syscalls is the simplest approach)? I see no need to break compatibility with existing binaries.
Quoted 5 lines
As I noted in
<https://sourceware.org/ml/libc-ports/2006-05/msg00020.html>, at that time the value ofRLIM64_INFINITYfor o32/n32 was purely a glibc convention the kernel didn't see at all. It's only with the use of newer syscalls that this glibc convention is any sort of problem.
Quoted 3 lines
Why not just make them convert any value >=
0x7fffffffffffffffto infinity before making the syscall? There's certainly no meaningful use for finite values in that range...
Or just replace 0x7fffffffffffffff by kernels infinity - and still fixing glibc, because the same value as the kernel should be the right answer long term.
Andi
Quoted 29 lines · Andreas Barth
Quoted 28 lines · * Rich Felker ([email protected]) [131105 02:22]:
Quoted 26 lines · Joseph S. Myers
Quoted 7 lines · David Miller
From: Aurelien Jarno <[email protected]>
Date: Mon, 4 Nov 2013 22:37:56 +0100Quoted 3 lines
Any news about this issue? It really starts to causes a lot of issues in Debian. I have added a Cc: to libc people so that we can also hear their opinion.
Quoted 5 lines
I had the same exact problem on sparc several years ago, I simply fixed the glibc header value, it's the only way to fix this.
Yes, that means you then have to recompile applications and libraries that reference this value.
Surely you can create new symbol versions for getrlimit64 and setrlimit64, with the old versions just using the 32-bit syscalls (or otherwise translating between conventions, but using the 32-bit syscalls is the simplest approach)? I see no need to break compatibility with existing binaries.
As I noted in
<https://sourceware.org/ml/libc-ports/2006-05/msg00020.html>, at that time the value ofRLIM64_INFINITYfor o32/n32 was purely a glibc convention the kernel didn't see at all. It's only with the use of newer syscalls that this glibc convention is any sort of problem.
Quoted 7 lines
Quoted 3 lines
Why not just make them convert any value >=
0x7fffffffffffffffto infinity before making the syscall? There's certainly no meaningful use for finite values in that range...Or just replace
0x7fffffffffffffffby kernels infinity - and still fixing glibc, because the same value as the kernel should be the right answer long term.
Oh, I agree that change should be made too. I just suggested an additional fix that could be made to avoid the need for recompiling and replacing old binaries.
Rich
Quoted 34 lines · Rich Felker
Quoted 33 lines · Andreas Barth
Quoted 31 lines · * Rich Felker ([email protected]) [131105 02:22]:
Quoted 21 lines · Joseph S. Myers
Quoted 7 lines · David Miller
From: Aurelien Jarno <[email protected]>
Date: Mon, 4 Nov 2013 22:37:56 +0100Quoted 3 lines
Any news about this issue? It really starts to causes a lot of issues in Debian. I have added a Cc: to libc people so that we can also hear their opinion.
Quoted 5 lines
I had the same exact problem on sparc several years ago, I simply fixed the glibc header value, it's the only way to fix this.
Yes, that means you then have to recompile applications and libraries that reference this value.
Surely you can create new symbol versions for getrlimit64 and setrlimit64, with the old versions just using the 32-bit syscalls (or otherwise translating between conventions, but using the 32-bit syscalls is the simplest approach)? I see no need to break compatibility with existing binaries.
Quoted 5 lines
As I noted in
<https://sourceware.org/ml/libc-ports/2006-05/msg00020.html>, at that time the value ofRLIM64_INFINITYfor o32/n32 was purely a glibc convention the kernel didn't see at all. It's only with the use of newer syscalls that this glibc convention is any sort of problem.Why not just make them convert any value >=
0x7fffffffffffffffto infinity before making the syscall? There's certainly no meaningful use for finite values in that range...
Quoted 8 lines
Quoted 3 lines
Or just replace
0x7fffffffffffffffby kernels infinity - and still fixing glibc, because the same value as the kernel should be the right answer long term.Oh, I agree that change should be made too. I just suggested an additional fix that could be made to avoid the need for recompiling and replacing old binaries.
Why can't the default version of the functions in question be fixed so that they do the right thing? That way you wouldn't have to rebuild old binaries.
Do we really need new function versions at all?
And FWIW: I think Pinski might be looking at fixing this.
David Daney
Quoted 4 lines · David Daney
Why can't the default version of the functions in question be fixed so that they do the right thing? That way you wouldn't have to rebuild old binaries.
Do we really need new function versions at all?
If we change RLIM64_INFINITY to match the kernel, then the right thing for at least getrlimit64 depends on whether it's an old or new binary (for old binaries it should return the old value of RLIM64_INFINITY and for new ones it should return the new value).
Signature · 2 lines
Joseph S. Myers [email protected]
Quoted 11 lines · Joseph S. Myers
Quoted 4 lines · David Daney
Why can't the default version of the functions in question be fixed so that they do the right thing? That way you wouldn't have to rebuild old binaries.
Do we really need new function versions at all?
If we change
RLIM64_INFINITYto match the kernel, then the right thing for at least getrlimit64 depends on whether it's an old or new binary (for old binaries it should return the old value ofRLIM64_INFINITYand for new ones it should return the new value).
BTW, what happens on a distro where -dev packages are separate and the user compiles with old headers (not having upgraded the dev package) but new libc.so? :-)
Rich
Quoted 8 lines · Rich Felker
Quoted 7 lines · Joseph S. Myers
Quoted 4 lines · David Daney
Why can't the default version of the functions in question be fixed so that they do the right thing? That way you wouldn't have to rebuild old binaries.
Do we really need new function versions at all?
Quoted 8 lines
Quoted 4 lines
If we change
RLIM64_INFINITYto match the kernel, then the right thing for at least getrlimit64 depends on whether it's an old or new binary (for old binaries it should return the old value ofRLIM64_INFINITYand for new ones it should return the new value).BTW, what happens on a distro where -dev packages are separate and the user compiles with old headers (not having upgraded the dev package) but new libc.so? :-)
That's a bug in the distribution packaging that it allows such inconsistent versions. glibc only supports the case when the static-link stage happens against the same glibc version as the headers that were used (static libraries built with old headers are expected to break whenever there's some ABI change made through symbol versioning).
Signature · 2 lines
Joseph S. Myers [email protected]
Quoted 3 lines · Rich Felker
BTW, what happens on a distro where -dev packages are separate and the user compiles with old headers (not having upgraded the dev package) but new libc.so? :-)
The devel package must either be self-contained or require the matching non-devel package.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 8 lines · Andreas Schwab
Quoted 3 lines · Rich Felker
BTW, what happens on a distro where -dev packages are separate and the user compiles with old headers (not having upgraded the dev package) but new libc.so? :-)
The devel package must either be self-contained or require the matching non-devel package.
That doesn't help. The problem is that the non-devel package gets upgraded and ldconfig re-links the .so to the .so.X.Y.Z for the new version. Really, the problem is ldconfig. If the .so link were correctly created by the devel package, rather than by ldconfig, then the headers and link-time library version would always match.
So, in short, ldconfig considered harmful.
Rich
Quoted 3 lines · Rich Felker
That doesn't help. The problem is that the non-devel package gets upgraded and ldconfig re-links the .so to the .so.X.Y.Z for the new version.
Require the upgrades happen in lockstep.
Package: libc6-dev
Version: 2.17-93
Depends: libc6 (= 2.17-93), libc-dev-bin (= 2.17-93), linux-libc-dev
Signature · 1 line
Russ Allbery ([email protected]) <http://www.eyrie.org/~eagle/>
Quoted 12 lines · Rich Felker
Quoted 11 lines
Surely you can create new symbol versions for getrlimit64 and setrlimit64, with the old versions just using the 32-bit syscalls (or otherwise translating between conventions, but using the 32-bit syscalls is the simplest approach)? I see no need to break compatibility with existing binaries.
As I noted in
<https://sourceware.org/ml/libc-ports/2006-05/msg00020.html>, at that time the value ofRLIM64_INFINITYfor o32/n32 was purely a glibc convention the kernel didn't see at all. It's only with the use of newer syscalls that this glibc convention is any sort of problem.
Quoted 3 lines
Why not just make them convert any value >=
0x7fffffffffffffffto infinity before making the syscall? There's certainly no meaningful use for finite values in that range...
It might be possible to do such a conversion in setrlimit64 - I'm not sure offhand if such a conversion for large finite values is valid, and a new symbol version is certainly the more conservative option - but getrlimit64 in existing binaries should return results using the existing RLIM64_INFINITY, in case binaries compare against that, so if you change the header value to match the kernel I don't think you can avoid the new symbol version for getrlimit64, and versioning both together seems safer.
Signature · 2 lines
Joseph S. Myers [email protected]