consolidate arch specific resource.h headers
RFC PATCH 1/1 consolidate arch specific resource.h headers
Most of the include/asm-*/resource.h headers are the same as one another. This patch makes one generic version, include/asm-generic/resource.h, and uses that when appropriate. The only vaguely interesting thing here is that the generic version introduces a new _STK_LIM_MAX macro, which can be populated by an arch (ia64 and parisc needed that). Also, some arches hid RLIM_INFINITY under __KERNEL__, while others did not. The generic version does not, so the following arches will see that change:
arm, arm26, ppc, ppc64, sh (and hence sh64)
The following arches are left untouched:
alpha: untouched (arch specific resource numbers)
m68knommu: untouched (uses m68k/resource.h)
mips: untouched (arch specific resource numbers)
sh64: untouched (uses asm-sh/resource.h)
sparc: untouched (arch specific resource numbers)
sparc64: untouched (arch specific resource numbers)
um: unoutched (uses arch code already)
Thoughts?
asm-arm/resource.h | 47 ---------------------------------------- asm-arm26/resource.h | 47 ---------------------------------------- asm-cris/resource.h | 47 ---------------------------------------- asm-frv/resource.h | 48 ----------------------------------------- asm-generic/resource.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ asm-h8300/resource.h | 47 ---------------------------------------- asm-i386/resource.h | 48 ----------------------------------------- asm-ia64/resource.h | 54 +--------------------------------------------- asm-m32r/resource.h | 51 ------------------------------------------- asm-m68k/resource.h | 47 ---------------------------------------- asm-parisc/resource.h | 48 +---------------------------------------- asm-ppc/resource.h | 44 ------------------------------------- asm-ppc64/resource.h | 53 --------------------------------------------- asm-s390/resource.h | 47 ---------------------------------------- asm-sh/resource.h | 47 ---------------------------------------- asm-v850/resource.h | 47 ---------------------------------------- asm-x86_64/resource.h | 47 ---------------------------------------- 17 files changed, 75 insertions(+), 751 deletions(-)
include/asm-generic/resource.h new file +57 -0
@@ -0,0 +1,57 @@ +#ifndef _ASM_GENERIC_RESOURCE_H +#define _ASM_GENERIC_RESOURCE_H + +/* +* Resource limits +*/ + +#define RLIMIT_CPU 0/* CPU time in ms */ +#define RLIMIT_FSIZE 1/* Maximum filesize */ +#define RLIMIT_DATA 2/* max data size */ +#define RLIMIT_STACK 3/* max stack size */ +#define RLIMIT_CORE 4/* max core file size */ +#define RLIMIT_RSS 5/* max resident set size */ +#define RLIMIT_NPROC 6/* max number of processes */ +#define RLIMIT_NOFILE 7/* max number of open files */ +#define RLIMIT_MEMLOCK 8/* max locked-in-memory address space */ +#define RLIMIT_AS 9/* address space limit */ +#define RLIMIT_LOCKS 10/* maximum file locks held */ +#define RLIMIT_SIGPENDING 11/* max number of pending signals */ +#define RLIMIT_MSGQUEUE 12/* maximum bytes in POSIX mqueues */ + +#define RLIM_NLIMITS 13 + +/* +* SuS says limits have to be unsigned. +* Which makes a ton more sense anyway. +*/ +#ifndef RLIM_INFINITY +#define RLIM_INFINITY (~0UL) +#endif + +#ifndef _STK_LIM_MAX +#define _STK_LIM_MAX RLIM_INFINITY +#endif + +#ifdef __KERNEL__ + +#define INIT_RLIMITS \ +{ \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { _STK_LIM, _STK_LIM_MAX }, \ + { 0, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { 0, 0 }, \ + { INR_OPEN, INR_OPEN }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { MAX_SIGPENDING, MAX_SIGPENDING }, \ + { MQ_BYTES_MAX, MQ_BYTES_MAX }, \ +} + +#endif /* __KERNEL__ */ + +#endif
===== include/asm-arm26/resource.h 1.5 vs edited =====
include/asm-arm26/resource.h +1 -46
52 lines not on this page · raw message
===== include/asm-arm/resource.h 1.5 vs edited =====
include/asm-arm/resource.h +1 -46
52 lines not on this page · raw message
===== include/asm-cris/resource.h 1.5 vs edited =====
include/asm-cris/resource.h +1 -46
52 lines not on this page · raw message
===== include/asm-frv/resource.h 1.1 vs edited =====
include/asm-frv/resource.h +1 -47
54 lines not on this page · raw message
===== include/asm-h8300/resource.h 1.5 vs edited =====
include/asm-h8300/resource.h +1 -46
52 lines not on this page · raw message
===== include/asm-i386/resource.h 1.5 vs edited =====
include/asm-i386/resource.h +1 -47
53 lines not on this page · raw message
===== include/asm-ia64/resource.h 1.7 vs edited =====
include/asm-ia64/resource.h +2 -52
60 lines not on this page · raw message
===== include/asm-m32r/resource.h 1.3 vs edited =====
include/asm-m32r/resource.h +1 -50
56 lines not on this page · raw message
===== include/asm-m68k/resource.h 1.6 vs edited =====
include/asm-m68k/resource.h +1 -46
52 lines not on this page · raw message
===== include/asm-parisc/resource.h 1.5 vs edited =====
include/asm-parisc/resource.h +2 -46
53 lines not on this page · raw message
===== include/asm-ppc64/resource.h 1.5 vs edited =====
include/asm-ppc64/resource.h +1 -52
58 lines not on this page · raw message
===== include/asm-ppc/resource.h 1.7 vs edited =====
include/asm-ppc/resource.h +1 -43
49 lines not on this page · raw message
===== include/asm-s390/resource.h 1.6 vs edited =====
include/asm-s390/resource.h +1 -46
53 lines not on this page · raw message
===== include/asm-sh/resource.h 1.5 vs edited =====
include/asm-sh/resource.h +1 -46
52 lines not on this page · raw message
===== include/asm-v850/resource.h 1.5 vs edited =====
include/asm-v850/resource.h +1 -46
52 lines not on this page · raw message
===== include/asm-x86_64/resource.h 1.5 vs edited =====
include/asm-x86_64/resource.h +1 -46
52 lines not on this page · raw message
Quoted 6 lines · Chris Wright
include/asm-generic/resource.h new file +6
-0+#define INIT_RLIMITS \ +{ \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { _STK_LIM, _STK_LIM_MAX }, \
include/asm-generic/resource.h line 53
Quoted 10 lines
include/asm-generic/resource.h new file +10
-0+ { 0, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { 0, 0 }, \ + { INR_OPEN, INR_OPEN }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { MAX_SIGPENDING, MAX_SIGPENDING }, \ + { MQ_BYTES_MAX, MQ_BYTES_MAX }, \ +}
While you are rooting around in there, perhaps this block should be converted to C99 initializer syntax, to avoid problems if arch-specific changes are later introduced?
Regards,
Bill Rugolsky
Quoted 13 lines · * Bill Rugolsky Jr. ([email protected]) wrote:
Quoted 12 lines · Chris Wright
include/asm-generic/resource.h new file +12
-0+#define INIT_RLIMITS \ +{ \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { _STK_LIM, _STK_LIM_MAX }, \ + { 0, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { 0, 0 }, \ + { INR_OPEN, INR_OPEN }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \
Quoted 8 lines
include/asm-generic/resource.h line 53
Quoted 4 lines
include/asm-generic/resource.h new file +4
-0+ { RLIM_INFINITY, RLIM_INFINITY }, \ + { MAX_SIGPENDING, MAX_SIGPENDING }, \ + { MQ_BYTES_MAX, MQ_BYTES_MAX }, \ +}While you are rooting around in there, perhaps this block should be converted to C99 initializer syntax, to avoid problems if arch-specific changes are later introduced?
Yes, I had considered the same. I had checked a couple arches and with proper designated initializers, that bit would not need to be duplicated.
thanks,
-chris
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net