From: Kurt Garloff <garloff@suse.de>
To: linux-arch@vger.kernel.org, linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>, Nick Piggin <NPiggin@suse.de>
Subject: [garloff@suse.de: [PATCH 1/1] default mlock limit 32k->64k]
Date: Thu, 16 Oct 2008 09:43:19 +0200 [thread overview]
Message-ID: <20081016074319.GD5286@tpkurt2.garloff.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 3208 bytes --]
Hi,
this patch does increase the default mlock()able memory from 32k to 64k
on PAGE_SIZE=4k systems. However, on systems with page sizes larger than
8k, the patch actually decreases the default down to 64k (or one page
in case that's larger).
Please speak up if you foresee problems on those platforms.
It would be simple to do
#define MLOCK_LIMIT ((PAGE_SIZE > 4096) ? 8*PAGE_SIZE : 64*1024)
in that case -- but doing min(64k,PAGE_SIZE) seems cleaner to me.
----- Forwarded message from Kurt Garloff <garloff@suse.de> -----
Date: Wed, 15 Oct 2008 11:27:36 +0200
From: Kurt Garloff <garloff@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Nick Piggin <NPiggin@suse.de>
Subject: [PATCH 1/1] default mlock limit 32k->64k
X-Operating-System: Linux 2.6.25.16-0.1-default x86_64
X-PGP-Info: on http://www.garloff.de/kurt/mykeys.pgp
X-PGP-Key: 1024D/1C98774E
Organization: SUSE Linux Products GmbH (a Novell company), Nuernberg, GF:
Markus Rex, HRB 16746 (AG Nuernberg)
User-Agent: Mutt/1.5.17 (2007-11-01)
Precedence: bulk
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org
Hi,
normal users can mlock memory up to the value defined in RLIMIT_MLOCK.
The number used to 0 for a long time and has been changed to 8 pages
(32k on 4k page systems) a number of years ago to accommodate the needs
of gpg, which is one of the few programs that a normal user runs and
which needs mlock (to prevent passphrase and key from leaking into
swap).
Nowadays, we have gpg2, and the need has increased to 64k.
Attached patch does change the default to 64k, independent of the
PAGE_SIZE. (Unless PAGE_SIZE is larger than 64k, then we allow one
page.)
Please apply.
--
Kurt Garloff, VP Business Development -- OPS, Novell Inc.
From: Kurt Garloff <garloff@suse.de>
Subject: Increase default RLIMIT_MEMLOCK to 64k
References: bnc#329675
Patch-Mainline: no (should be submitted)
By default, non-privileged tasks can only mlock() a small amount of
memory to avoid a DoS attack by ordinary users. The Linux kernel
defaulted to 32k (on a 4k page size system) to accommodate the
needs of gpg.
However, newer gpg2 needs 64k in various circumstances and otherwise
fails miserably, see bnc#329675.
Change the default to 64k, and make it more agnostic to PAGE_SIZE.
Signed-off-by: Kurt Garloff <garloff@suse.de>
Signed-off-by: Nick Piggin <npiggin@suse.de>
---
Index: linux-2.6.27/include/linux/resource.h
===================================================================
--- linux-2.6.27.orig/include/linux/resource.h
+++ linux-2.6.27/include/linux/resource.h
@@ -59,10 +59,10 @@ struct rlimit {
#define _STK_LIM (8*1024*1024)
/*
- * GPG wants 32kB of mlocked memory, to make sure pass phrases
+ * GPG2 wants 64kB of mlocked memory, to make sure pass phrases
* and other sensitive information are never written to disk.
*/
-#define MLOCK_LIMIT (8 * PAGE_SIZE)
+#define MLOCK_LIMIT ((PAGE_SIZE > 64*1024) ? PAGE_SIZE : 64*1024)
/*
* Due to binary compatibility, the actual resource numbers
----- End forwarded message -----
--
Kurt Garloff, VP Business Development -- OPS, Novell Inc.
[-- Attachment #2: Type: application/pgp-signature, Size: 194 bytes --]
next reply other threads:[~2008-10-16 7:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-16 7:43 Kurt Garloff [this message]
2008-10-16 22:48 ` Andrew Morton
2008-10-17 4:11 ` Nick Piggin
2008-10-17 16:46 ` Kurt Garloff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081016074319.GD5286@tpkurt2.garloff.de \
--to=garloff@suse.de \
--cc=NPiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox