Re: [patch] mlock-as-nonroot revisted

From: Rik van Riel
Date: Tue Aug 03 2004 - 15:56:51 EST


On Thu, 29 Jul 2004, Chris Wright wrote:

> 2) mlock_user isn't ever set, so SHM_LOCK accounting looks broken
> (trivial to fix).

Should be fixed by the patch below. Does this look
acceptable ?

--- ipc/shm.c.mlock 2004-08-03 10:19:49.470575891 -0400
+++ ipc/shm.c 2004-08-03 11:44:10.047294881 -0400
@@ -524,15 +524,19 @@
goto out_unlock;

if(cmd==SHM_LOCK) {
+ struct user_struct * user = current->user;
if (!is_file_hugepages(shp->shm_file)) {
err = shmem_lock(shp->shm_file, 1, current->user);
- if (!err)
+ if (!err) {
shp->shm_flags |= SHM_LOCKED;
+ shp->mlock_user = user;
+ }
}
} else {
if (!is_file_hugepages(shp->shm_file))
shmem_lock(shp->shm_file, 0, shp->mlock_user);
shp->shm_flags &= ~SHM_LOCKED;
+ shp->mlock_user = NULL;
}
shm_unlock(shp);
goto out;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/