From f947ff8af30f75cb9cf0e966caf8f4809ad1b92e Mon Sep 17 00:00:00 2001 From: Rik van Riel Date: Sun, 22 Aug 2004 23:06:58 -0700 Subject: [PATCH] [PATCH] increase per-user mlock limit default to 32k Since various gnupg users have indicated that gpg wants to mlock 32kB of memory, I created the patch below that increases the default mlock ulimit to 32kB. This is no security problem because it's trivial for processes to lock way more memory than this in page tables, network buffers, etc. In fact, since this patch allows gnupg to mlock to prevent passphrase data from being swapped out, the security people will probably like it ;) This gets the new per-user mlock limit a bit more testing, too. Signed-off-by: Rik van Riel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-alpha/resource.h | 2 +- include/asm-arm/resource.h | 2 +- include/asm-arm26/resource.h | 2 +- include/asm-cris/resource.h | 2 +- include/asm-h8300/resource.h | 2 +- include/asm-i386/resource.h | 2 +- include/asm-ia64/resource.h | 2 +- include/asm-m68k/resource.h | 2 +- include/asm-mips/resource.h | 2 +- include/asm-parisc/resource.h | 2 +- include/asm-ppc/resource.h | 2 +- include/asm-ppc64/resource.h | 2 +- include/asm-s390/resource.h | 2 +- include/asm-sh/resource.h | 2 +- include/asm-sparc/resource.h | 2 +- include/asm-sparc64/resource.h | 2 +- include/asm-v850/resource.h | 2 +- include/asm-x86_64/resource.h | 2 +- include/linux/resource.h | 6 ++++++ 19 files changed, 24 insertions(+), 18 deletions(-) diff --git a/include/asm-alpha/resource.h b/include/asm-alpha/resource.h index 2b0f4bcf2644c..bfacb0aa27b53 100644 --- a/include/asm-alpha/resource.h +++ b/include/asm-alpha/resource.h @@ -41,7 +41,7 @@ {INR_OPEN, INR_OPEN}, /* RLIMIT_NOFILE */ \ {LONG_MAX, LONG_MAX}, /* RLIMIT_AS */ \ {LONG_MAX, LONG_MAX}, /* RLIMIT_NPROC */ \ - {0, 0 }, /* RLIMIT_MEMLOCK */ \ + {MLOCK_LIMIT, MLOCK_LIMIT }, /* RLIMIT_MEMLOCK */ \ {LONG_MAX, LONG_MAX}, /* RLIMIT_LOCKS */ \ {MAX_SIGPENDING, MAX_SIGPENDING}, /* RLIMIT_SIGPENDING */ \ {MQ_BYTES_MAX, MQ_BYTES_MAX}, /* RLIMIT_MSGQUEUE */ \ diff --git a/include/asm-arm/resource.h b/include/asm-arm/resource.h index 323167464b976..354afada3807a 100644 --- a/include/asm-arm/resource.h +++ b/include/asm-arm/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING}, \ diff --git a/include/asm-arm26/resource.h b/include/asm-arm26/resource.h index 28a05990277d8..354afada3807a 100644 --- a/include/asm-arm26/resource.h +++ b/include/asm-arm26/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING}, \ diff --git a/include/asm-cris/resource.h b/include/asm-cris/resource.h index 606a4c9a95798..7a83ad536124e 100644 --- a/include/asm-cris/resource.h +++ b/include/asm-cris/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-h8300/resource.h b/include/asm-h8300/resource.h index 65cf2c6962f26..2031e3ce4bfda 100644 --- a/include/asm-h8300/resource.h +++ b/include/asm-h8300/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-i386/resource.h b/include/asm-i386/resource.h index 47bdff24d040d..5c3505a4a52e2 100644 --- a/include/asm-i386/resource.h +++ b/include/asm-i386/resource.h @@ -40,7 +40,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-ia64/resource.h b/include/asm-ia64/resource.h index c0a403a8a42e0..52a737eabf243 100644 --- a/include/asm-ia64/resource.h +++ b/include/asm-ia64/resource.h @@ -46,7 +46,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-m68k/resource.h b/include/asm-m68k/resource.h index 51ef4bbb8e6ad..92a8ff5c82941 100644 --- a/include/asm-m68k/resource.h +++ b/include/asm-m68k/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-mips/resource.h b/include/asm-mips/resource.h index 2453e0d1c35c7..62e1ce0282f8d 100644 --- a/include/asm-mips/resource.h +++ b/include/asm-mips/resource.h @@ -53,7 +53,7 @@ { INR_OPEN, INR_OPEN }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-parisc/resource.h b/include/asm-parisc/resource.h index ac9de533eb622..491f29e492396 100644 --- a/include/asm-parisc/resource.h +++ b/include/asm-parisc/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-ppc/resource.h b/include/asm-ppc/resource.h index a8392167ae6e6..2953d9bdc8c57 100644 --- a/include/asm-ppc/resource.h +++ b/include/asm-ppc/resource.h @@ -36,7 +36,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-ppc64/resource.h b/include/asm-ppc64/resource.h index d23ea5ba1b9b0..f5d6b2e8c659f 100644 --- a/include/asm-ppc64/resource.h +++ b/include/asm-ppc64/resource.h @@ -45,7 +45,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-s390/resource.h b/include/asm-s390/resource.h index 837ed3ab12756..05720dbdfe89f 100644 --- a/include/asm-s390/resource.h +++ b/include/asm-s390/resource.h @@ -47,7 +47,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-sh/resource.h b/include/asm-sh/resource.h index 690f83a92b210..bf6152e115614 100644 --- a/include/asm-sh/resource.h +++ b/include/asm-sh/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-sparc/resource.h b/include/asm-sparc/resource.h index 098bfa7145f80..d4fb2b4d3b9f2 100644 --- a/include/asm-sparc/resource.h +++ b/include/asm-sparc/resource.h @@ -44,7 +44,7 @@ { 0, RLIM_INFINITY}, \ {RLIM_INFINITY, RLIM_INFINITY}, \ {INR_OPEN, INR_OPEN}, {0, 0}, \ - {0, 0}, \ + {MLOCK_LIMIT, MLOCK_LIMIT}, \ {RLIM_INFINITY, RLIM_INFINITY}, \ {RLIM_INFINITY, RLIM_INFINITY}, \ {MAX_SIGPENDING, MAX_SIGPENDING}, \ diff --git a/include/asm-sparc64/resource.h b/include/asm-sparc64/resource.h index 60afa3362b7fd..f33d38bccab2e 100644 --- a/include/asm-sparc64/resource.h +++ b/include/asm-sparc64/resource.h @@ -43,7 +43,7 @@ { 0, RLIM_INFINITY}, \ {RLIM_INFINITY, RLIM_INFINITY}, \ {INR_OPEN, INR_OPEN}, {0, 0}, \ - {0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT}, \ {RLIM_INFINITY, RLIM_INFINITY}, \ {RLIM_INFINITY, RLIM_INFINITY}, \ {MAX_SIGPENDING, MAX_SIGPENDING}, \ diff --git a/include/asm-v850/resource.h b/include/asm-v850/resource.h index 0b757f33dd921..adcbbb8963696 100644 --- a/include/asm-v850/resource.h +++ b/include/asm-v850/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/asm-x86_64/resource.h b/include/asm-x86_64/resource.h index 4ed168acafb8e..f1b71c3209340 100644 --- a/include/asm-x86_64/resource.h +++ b/include/asm-x86_64/resource.h @@ -39,7 +39,7 @@ { RLIM_INFINITY, RLIM_INFINITY }, \ { 0, 0 }, \ { INR_OPEN, INR_OPEN }, \ - { 0, 0 }, \ + { MLOCK_LIMIT, MLOCK_LIMIT }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { MAX_SIGPENDING, MAX_SIGPENDING }, \ diff --git a/include/linux/resource.h b/include/linux/resource.h index 94494789e0af5..b930c9cb77271 100644 --- a/include/linux/resource.h +++ b/include/linux/resource.h @@ -55,6 +55,12 @@ struct rlimit { */ #define _STK_LIM (8*1024*1024) +/* + * GPG wants 32kB of mlocked memory, to make sure pass phrases + * and other sensitive information are never written to disk. + */ +#define MLOCK_LIMIT (32*1024) + /* * Due to binary compatibility, the actual resource numbers * may be different for different linux versions.. -- 2.53.0