Bug 222623

Summary: mlock call needs root previlage to lock the memory pages.
Product: Red Hat Enterprise Linux 4 Reporter: Pramila <kvenics>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-02-09 20:36:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.