mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: Rationale for RLIMIT_MEMLOCK?
@ 2006-02-03 20:49 Michael Kerrisk
  0 siblings, 0 replies; 31+ messages in thread
From: Michael Kerrisk @ 2006-02-03 20:49 UTC (permalink / raw)
  To: matthias.andree
  Cc: Theodore Ts'o, linux-kernel, arjan, Joerg Schilling, michael.kerrisk

> > Matthias Andree <matthias.andree@gmx.de> wrote:

[...]

> The complete story is, condensed, and with return values, for a
> setuid-root application:
> 
>   geteuid() == 0;
>   mlockall(MLC_CURRENT|MLC_FUTURE) == (success);
>   seteuid(500) == (success);
>   valloc(64512 + pagesize) == NULL (failure);

[...]

A late follow-up to this thread. I've added the following text
to the mlockall() manual pag under BUGS:

    Since kernel 2.6.9, if a privileged process calls 
    mlockall(MCL_FUTURE) and later drops privileges
    (CAP_IPC_LOCK), then subsequent memory allocations
    (e.g., mmap(2), sbrk(2)) will fail if the 
    RLIMIT_MEMLOCK resource limit is encountered.
    
The change will be in man-pages 2.23.

Cheers,

Michael

-- 
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7 

Want to help with man page maintenance?  
Grab the latest tarball at
ftp://ftp.win.tue.nl/pub/linux-local/manpages/, 
read the HOWTOHELP file and grep the source 
files for 'FIXME'.

^ permalink raw reply	[flat|nested] 31+ messages in thread
[parent not found: <5yddh-1pA-47@gated-at.bofh.it>]
* Rationale for RLIMIT_MEMLOCK?
@ 2006-01-23 10:56 Matthias Andree
  2006-01-23 11:05 ` Arjan van de Ven
  0 siblings, 1 reply; 31+ messages in thread
From: Matthias Andree @ 2006-01-23 10:56 UTC (permalink / raw)
  To: Linux-Kernel mailing list

Greetings,

debugging an application problem that used to mlockall(...FUTURE) and
failed with a subsequent mmap(), I came across the manual page for
setrlimit (see below for the relevant excerpt). I have several questions
concerning the rationale:

1. What is the reason we're having special treatment
   for the super-user here?

2. Why is it the opposite of what 2.6.8.1 and earlier did?

3. Why is this inconsistent with all other RLIMIT_*?
   Neither of which cares if a process is privileged or not.

4. Is the default hard limit of 32 kB initialized by the kernel or
   by some script in SUSE 10.0? If it's the kernel: why is the limit so
   low, and why isn't just the soft limit set?

   "[...]
    RLIMIT_MEMLOCK
      The maximum number of bytes of memory that may  be  locked  into
      RAM.  In effect this limit is rounded down to the nearest multi-
      ple of the system page size.  This limit  affects  mlock(2)  and
      mlockall(2)  and  the mmap(2) MAP_LOCKED operation.  Since Linux
      2.6.9 it also affects the shmctl(2) SHM_LOCK operation, where it
      sets a maximum on the total bytes in shared memory segments (see
      shmget(2)) that may be locked by the real user ID of the calling
      process.   The  shmctl(2) SHM_LOCK locks are accounted for sepa-
      rately  from  the  per-process  memory  locks   established   by
      mlock(2),  mlockall(2),  and  mmap(2)  MAP_LOCKED; a process can
      lock bytes up to this limit in each of these two categories.  In
      Linux  kernels before 2.6.9, this limit controlled the amount of
      memory that could be locked  by  a  privileged  process.   Since
      Linux 2.6.9, no limits are placed on the amount of memory that a
      privileged process may lock, and this limit instead governs  the
      amount of memory that an unprivileged process may lock. [...]"
   (getrlimit(2), man-pages-2.07)

-- 
Matthias Andree

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2006-02-03 20:49 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-03 20:49 Rationale for RLIMIT_MEMLOCK? Michael Kerrisk
     [not found] <5yddh-1pA-47@gated-at.bofh.it>
     [not found] ` <5ydni-1Qq-3@gated-at.bofh.it>
     [not found]   ` <5yek1-3iP-53@gated-at.bofh.it>
     [not found]     ` <5yeth-3us-33@gated-at.bofh.it>
     [not found]       ` <5yf5O-4iF-19@gated-at.bofh.it>
     [not found]         ` <5yfI4-5kU-11@gated-at.bofh.it>
     [not found]           ` <5ygDT-6LK-3@gated-at.bofh.it>
     [not found]             ` <5yscc-68j-5@gated-at.bofh.it>
     [not found]               ` <5ysvk-6JI-5@gated-at.bofh.it>
     [not found]                 ` <5ysvk-6JI-3@gated-at.bofh.it>
     [not found]                   ` <5yEn7-7Or-21@gated-at.bofh.it>
     [not found]                     ` <5yUUI-6JR-15@gated-at.bofh.it>
2006-01-26  0:12                       ` Bodo Eggert
  -- strict thread matches above, loose matches on Subject: below --
2006-01-23 10:56 Matthias Andree
2006-01-23 11:05 ` Arjan van de Ven
2006-01-23 16:54   ` Matthias Andree
2006-01-23 17:00     ` Arjan van de Ven
2006-01-23 18:01       ` Matthias Andree
2006-01-23 18:13         ` Arjan van de Ven
2006-01-23 18:55           ` Matthias Andree
2006-01-23 19:04             ` Arjan van de Ven
2006-01-23 19:38             ` Joerg Schilling
2006-01-23 20:30               ` Matthias Andree
2006-01-23 21:23                 ` Joerg Schilling
2006-01-23 22:05                   ` Matthias Andree
2006-01-24  8:52                 ` Arjan van de Ven
2006-01-24  9:08                   ` Joerg Schilling
2006-01-24  9:15                     ` Arjan van de Ven
2006-01-24  9:18                       ` Joerg Schilling
2006-01-24 21:28                       ` Theodore Ts'o
2006-01-24 23:19                         ` Edgar Toernig
2006-01-25 15:38                           ` Joerg Schilling
2006-01-24 23:26                         ` Matthias Andree
2006-01-24 23:27                           ` Matthias Andree
2006-01-25 15:33                         ` Joerg Schilling
2006-01-25 16:01                           ` Matthias Andree
2006-01-24 10:51                     ` Matthias Andree
2006-01-23 20:30               ` Lee Revell
2006-01-23 21:33                 ` Joerg Schilling
2006-01-23 19:57             ` Lee Revell
2006-01-23 21:34             ` Theodore Ts'o
2006-01-24 11:06               ` Matthias Andree

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®