Bug 222623 - mlock call needs root previlage to lock the memory pages.
Summary: mlock call needs root previlage to lock the memory pages.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel
Version: 4.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Kernel Maintainer List
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-01-15 11:09 UTC by Pramila
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-02-09 20:36:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Pramila 2007-01-15 11:09:16 UTC
Description of problem: Our requirement is that mlock should work for normal
users. Other OS like Solaris support this.


Version-Release number of selected component (if applicable): RHEL 4.


How reproducible: Always



Steps to Reproduce:
1.
#include <unistd.h>
#include <sys/shm.h>
main()
    {
    int id;
    key_t key;
    char proc_id = 'C';
    int size = 0x5000;
    int flags = 0664 | IPC_CREAT;              /* read-only for others */
    int mlock_status;
    int shmdt_status;
    void        *addr;
    int         shmctl_status;
    struct      shmid_ds foo;

    key = ftok ("~creator/ipckey", proc_id);
    id = shmget (key, size, flags);
    addr = shmat(id, (const void *) NULL, (int) 0);
    
    /*shmctl_status = shmctl( id, SHM_LOCK, &foo);*/
    if ( (mlock( (const void *)addr, (size_t) size)) != 0)
		printf("mlock failed!");

    shmdt_status = shmdt( (const void *) addr);
    shmctl (id, IPC_RMID, NULL);
    }

2.run this program as a non root users.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Dennis Gregorovic 2007-01-15 15:49:24 UTC
redhat-release is not the correct component for this.  Perhaps you meant 'kernel'?

Comment 2 Jason Baron 2007-02-09 20:36:18 UTC
hmmm, you can set user limits in the shell using the 'ulimit' command up to the
hard limit which is 32 kb by default for mlock. HOwever, the administrator can
up thish limit per-user vi /etc/security/limits.conf file.


Note You need to log in before you can comment on or make changes to this bug.