* [PATCH] [ipc/shm] make shmget with IPC_PRIVATE initially created with SHM_DEST
@ 2012-08-03 12:13 microcai
0 siblings, 0 replies; only message in thread
From: microcai @ 2012-08-03 12:13 UTC (permalink / raw)
To: linux-kernel; +Cc: kernel, microcai
The problem is SysV SHM is that , it will cause kernel resource leak.
Initailly set shm mode to SHM_DEST when create with key_t IPC_PRIVATE,
then the resource leak is fixed.
If program want the shmid live longer, they will probably use non
IPC_PRIVATE nor call shmctl that remove SHM_DEST bit.
---
ipc/shm.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/ipc/shm.c b/ipc/shm.c
index 41c1285..1abc031 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -480,6 +480,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
shp->shm_perm.key = key;
shp->shm_perm.mode = (shmflg & S_IRWXUGO);
+ if(key == IPC_PRIVATE)
+ shp->shm_perm.mode |= SHM_DEST;
shp->mlock_user = NULL;
shp->shm_perm.security = NULL;
--
1.7.8.6
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-08-03 12:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-03 12:13 [PATCH] [ipc/shm] make shmget with IPC_PRIVATE initially created with SHM_DEST microcai
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®