From: Vasiliy Kulikov <segoon@openwall.com>
To: kernel-hardening@lists.openwall.com
Subject: [kernel-hardening] destroy unused shmem segments
Date: Mon, 13 Jun 2011 10:42:52 +0400 [thread overview]
Message-ID: <20110613064252.GB3877@albatros> (raw)
Solar,
I'm looking into the -ow patch and I see this code:
#ifdef CONFIG_HARDEN_SHM
void shm_exit (void)
{
int i;
struct shmid_kernel *shp;
for (i = 0; i <= shm_ids.max_id; i++) {
shp = shm_get(i);
if (!shp) continue;
if (shp->shm_cprid != current->pid) continue;
if (shp->shm_nattch <= 0) {
shp->shm_flags |= SHM_DEST;
shm_destroy (shp);
}
}
}
#endif
NORET_TYPE void do_exit(long code)
{
...
#ifdef CONFIG_HARDEN_SHM
shm_exit();
#endif
...
}
However, the shm segment should be already freed by exit_mm() => vma->close():
static struct vm_operations_struct shm_vm_ops = {
open: shm_open, /* callback for a new vm-area open */
close: shm_close, /* callback for when the vm-area is released */
nopage: shmem_nopage,
};
static void shm_close (struct vm_area_struct *shmd)
{
...
shp->shm_nattch--;
#ifdef CONFIG_HARDEN_SHM
if(shp->shm_nattch == 0) {
shp->shm_flags |= SHM_DEST;
shm_destroy (shp);
}
#else
if(shp->shm_nattch == 0 &&
shp->shm_flags & SHM_DEST)
shm_destroy (shp);
#endif
...
}
Is it some additional "safety" check or a workaround for some dubious
race? I see no explicit need of such freeing cycle in do_exit().
Thanks,
--
Vasiliy
next reply other threads:[~2011-06-13 6:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-13 6:42 Vasiliy Kulikov [this message]
2011-06-13 7:07 ` [kernel-hardening] destroy unused shmem segments Solar Designer
2011-06-14 8:33 ` Vasiliy Kulikov
2011-06-15 14:42 ` Solar Designer
-- strict thread matches above, loose matches on Subject: below --
2011-06-14 17:51 Vasiliy Kulikov
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=20110613064252.GB3877@albatros \
--to=segoon@openwall.com \
--cc=kernel-hardening@lists.openwall.com \
/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