[lustre-devel] [PATCH 18/24] lustre: llite: don't touch vma after filemap_fault
James Simmons
jsimmons at infradead.org
Tue Sep 21 19:19:55 PDT 2021
From: Alexander Boyko <alexander.boyko at hpe.com>
In case of error filemap_fault unlock mutex vma->vm_mm->mmap_sem,
so touching vma is dangerous, it could be reused or freed.
The patch uses local file variable to skip vma.
HPE-bug-id: LUS-10240
WC-bug-id: https://jira.whamcloud.com/browse/LU-14021
Lustre-commit: 0f5d3c4b954da2f6b ("LU-14021 llite: don't touch vma after filemap_fault")
Signed-off-by: Alexander Boyko <alexander.boyko at hpe.com>
Reviewed-on: https://review.whamcloud.com/44558
Reviewed-by: Andrew Perepechko <andrew.perepechko at hpe.com>
Reviewed-by: Patrick Farrell <pfarrell at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
fs/lustre/llite/llite_mmap.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/fs/lustre/llite/llite_mmap.c b/fs/lustre/llite/llite_mmap.c
index ebcb8d9..85a082c 100644
--- a/fs/lustre/llite/llite_mmap.c
+++ b/fs/lustre/llite/llite_mmap.c
@@ -38,9 +38,9 @@
#include <linux/unistd.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
-
#include <linux/fs.h>
#include <linux/pagemap.h>
+#include <linux/file.h>
#define DEBUG_SUBSYSTEM S_LLITE
@@ -317,6 +317,8 @@ static vm_fault_t __ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
result = io->ci_result;
if (result == 0) {
+ struct file *vm_file = vma->vm_file;
+
vio = vvp_env_io(env);
vio->u.fault.ft_vma = vma;
vio->u.fault.ft_vmpage = NULL;
@@ -324,13 +326,15 @@ static vm_fault_t __ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
vio->u.fault.ft_flags = 0;
vio->u.fault.ft_flags_valid = false;
+ get_file(vm_file);
+
/* May call ll_readpage() */
- ll_cl_add(vma->vm_file, env, io, LCC_MMAP);
+ ll_cl_add(vm_file, env, io, LCC_MMAP);
result = cl_io_loop(env, io);
- ll_cl_remove(vma->vm_file, env);
-
+ ll_cl_remove(vm_file, env);
+ fput(vm_file);
/* ft_flags are only valid if we reached
* the call to filemap_fault
*/
--
1.8.3.1
More information about the lustre-devel
mailing list