Skip to content

Commit

Permalink
shmdt: use i_size_read() instead of ->i_size
Browse files Browse the repository at this point in the history
Andrew Morton noted

	http://lkml.kernel.org/r/[email protected]

that the shmdt uses inode->i_size outside of i_mutex being held.
There is one more case in shm.c in shm_destroy().  This converts
both users over to use i_size_read().

Signed-off-by: Dave Hansen <[email protected]>
Cc: Manfred Spraul <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
hansendc authored and torvalds committed Dec 13, 2014
1 parent d3c9790 commit 07a46ed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ipc/shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
if (!is_file_hugepages(shm_file))
shmem_lock(shm_file, 0, shp->mlock_user);
else if (shp->mlock_user)
user_shm_unlock(file_inode(shm_file)->i_size, shp->mlock_user);
user_shm_unlock(i_size_read(file_inode(shm_file)),
shp->mlock_user);
fput(shm_file);
ipc_rcu_putref(shp, shm_rcu_free);
}
Expand Down Expand Up @@ -1280,7 +1281,7 @@ SYSCALL_DEFINE1(shmdt, char __user *, shmaddr)
* in the range we are unmapping.
*/
file = vma->vm_file;
size = file_inode(file)->i_size;
size = i_size_read(file_inode(vma->vm_file));
do_munmap(mm, vma->vm_start, vma->vm_end - vma->vm_start);
/*
* We discovered the size of the shm segment, so
Expand Down

0 comments on commit 07a46ed

Please sign in to comment.