From: microcai <microcai@fedoraproject.org>
To: linux-kernel@vger.kernel.org
Cc: kernel@vger.linux-kernel.cn, microcai <microcai@fedoraproject.org>
Subject: [PATCH] [ipc/shm] make shmget with IPC_PRIVATE initially created with SHM_DEST
Date: Fri, 3 Aug 2012 20:13:10 +0800 [thread overview]
Message-ID: <1343995990-1358-1-git-send-email-microcai@fedoraproject.org> (raw)
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
reply other threads:[~2012-08-03 12:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343995990-1358-1-git-send-email-microcai@fedoraproject.org \
--to=microcai@fedoraproject.org \
--cc=kernel@vger.linux-kernel.cn \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®