Skip to contentSkip to conversation

shmem: init on stack vmas

PATCH In review Josef Bacik 2 participants 3 messages Jan 13, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shmem: init on stack vmas

We were hitting a weird bug with our cgroup stuff because shmem uses on stack vmas. These aren't properly init'ed so we'd have garbage in vma->mm and bad things would happen. Fix this by just init'ing to empty structs. Thanks,

---
 mm/shmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/shmem.c +2 -2
index 902a148..ee6b834 100644
@@ -911,7 +911,7 @@ static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
 static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp,
 			struct shmem_inode_info *info, pgoff_t index)
 {
-	struct vm_area_struct pvma;
+	struct vm_area_struct pvma = {};
 	struct page *page;
 
 	/* Create a pseudo vma that just contains the policy */
@@ -932,7 +932,7 @@ static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp,
 static struct page *shmem_alloc_page(gfp_t gfp,
 			struct shmem_inode_info *info, pgoff_t index)
 {
-	struct vm_area_struct pvma;
+	struct vm_area_struct pvma = {};
 	struct page *page;
 
 	/* Create a pseudo vma that just contains the policy */
Signature · 7 lines
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 3 lines · Josef Bacik

We were hitting a weird bug with our cgroup stuff because shmem uses on stack vmas. These aren't properly init'ed so we'd have garbage in vma->mm and bad things would happen. Fix this by just init'ing to empty structs. Thanks,

...

mm/shmem.c static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo) · line 914

Quoted 5 lines

static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp,

mm/shmem.c +1 -1
 			struct shmem_inode_info *info, pgoff_t index)
 {
-	struct vm_area_struct pvma;
+	struct vm_area_struct pvma = {};

What does that code do if it needs an mm and doesn't find one?

#2 lore raw
Quoted 11 lines · Dave Hansen
Quoted 3 lines · Josef Bacik

We were hitting a weird bug with our cgroup stuff because shmem uses on stack vmas. These aren't properly init'ed so we'd have garbage in vma->mm and bad things would happen. Fix this by just init'ing to empty structs. Thanks,

...

Review

Quoted 5 lines

static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp,
struct shmem_inode_info *info, pgoff_t index)
{

(quoted diff) +1 -1
-	struct vm_area_struct pvma;
+	struct vm_area_struct pvma = {};

What does that code do if it needs an mm and doesn't find one?

We have checks for if (vma->mm && some other shit) so we expect NULLs for stuff we don't care about. Thanks,

Josef