[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    shm: fix shmctl(SHM_INFO) lockup with !CONFIG_SHMEM
From:       Linux Kernel Mailing List <linux-kernel () vger ! kernel ! org>
Date:       2009-02-05 22:59:45
Message-ID: 200902052259.n15Mxjnt009290 () hera ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a68e61e8ff2d46327a37b69056998b47745db6fa
Commit:     a68e61e8ff2d46327a37b69056998b47745db6fa
Parent:     1f5e31d7e55ac7fbd4ec5e5b20c8868b0e4564c9
Author:     Tony Battersby <tonyb@cybernetics.com>
AuthorDate: Wed Feb 4 15:12:04 2009 -0800
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Thu Feb 5 12:56:47 2009 -0800

    shm: fix shmctl(SHM_INFO) lockup with !CONFIG_SHMEM
    
    shm_get_stat() assumes that the inode is a "struct shmem_inode_info",
    which is incorrect for !CONFIG_SHMEM (see fs/ramfs/inode.c:
    ramfs_get_inode() vs.  mm/shmem.c: shmem_get_inode()).
    
    This bad assumption can cause shmctl(SHM_INFO) to lockup when
    shm_get_stat() tries to spin_lock(&info->lock).  Users of !CONFIG_SHMEM
    may encounter this lockup simply by invoking the 'ipcs' command.
    
    Reported by Jiri Olsa back in February 2008:
    http://lkml.org/lkml/2008/2/29/74
    
    Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
    Cc: Jiri Kosina <jkosina@suse.cz>
    Reported-by: Jiri Olsa <olsajiri@gmail.com>
    Cc: Hugh Dickins <hugh@veritas.com>
    Cc: <stable@kernel.org>		[2.6.everything]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 ipc/shm.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/ipc/shm.c b/ipc/shm.c
index c0a021f..f8f69fa 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -565,11 +565,15 @@ static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss,
 			struct hstate *h = hstate_file(shp->shm_file);
 			*rss += pages_per_huge_page(h) * mapping->nrpages;
 		} else {
+#ifdef CONFIG_SHMEM
 			struct shmem_inode_info *info = SHMEM_I(inode);
 			spin_lock(&info->lock);
 			*rss += inode->i_mapping->nrpages;
 			*swp += info->swapped;
 			spin_unlock(&info->lock);
+#else
+			*rss += inode->i_mapping->nrpages;
+#endif
 		}
 
 		total++;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic