We forgot to port this patch. This results in KP on an attempt to mmap a
char device on ext4.

=============================================================================
Author: Vladimir Davydov
Email: [email protected]
Subject: mmap: call mmap prep only for regular files
Date: Mon, 17 Feb 2014 12:59:36 +0400

To give FS a chance to clear pfcache csum on shared mmap, we issue
->mmap(vma=NULL) for those FS's that want it (FS_HAS_MMAP_PREP) before
taking mmap_sem (we can't do it under mmap_sem due to lockdep, see
PSBM-23133). There we haven't checked arguments properly yet. In
particular, the file can refer to a device, in which case we will
crash, because devices' ->mmap (e.g. /dev/zero) is not supposed to be
called with vma=NULL. Fix this by checking if the file refers to a
regular file before calling mmap prep for it.

https://bugzilla.openvz.org/show_bug.cgi?id=2886
https://jira.sw.ru/browse/PSBM-25031

Signed-off-by: Vladimir Davydov <[email protected]>
Acked-by: Dmitry Monakhov <[email protected]>
=============================================================================

Reported-by: Andrew Perepechko <[email protected]>
Signed-off-by: Vladimir Davydov <[email protected]>
Cc: Andrew Perepechko <[email protected]>
Cc: Alex Lyashkov <[email protected]>
Cc: Igor Seletskiy <[email protected]>
---
 mm/util.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/util.c b/mm/util.c
index 31cd9d73417c..e0ac8ae736ff 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -367,6 +367,7 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned 
long addr,
        if (!ret) {
                /* Ugly fix for PSBM-23133 vdavydov@ */
                if (file && file->f_op && (flag & MAP_TYPE) == MAP_SHARED &&
+                   S_ISREG(file_inode(file)->i_mode) &&
                    (file_inode(file)->i_sb->s_type->fs_flags & 
FS_HAS_MMAP_PREP))
                        file->f_op->mmap(file, NULL);
                down_write(&mm->mmap_sem);
-- 
2.1.4

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to