Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: afs: revert mmap_prepare() change

Partially reverts commit 9d5403b1036c ("fs: convert most other
generic_file_*mmap() users to .mmap_prepare()").

This is because the .mmap invocation establishes a refcount, but
.mmap_prepare is called at a point where a merge or an allocation failure
might happen after the call, which would leak the refcount increment.

Functionality is being added to permit the use of .mmap_prepare in this
case, but in the interim, we need to fix this.

Link: https://lkml.kernel.org/r/08804c94e39d9102a3a8fbd12385e8aa079ba1d3.1774045440.git.ljs@kernel.org
Fixes: 9d5403b1036c ("fs: convert most other generic_file_*mmap() users to .mmap_prepare()")
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bodo Stroesser <bostroesser@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Long Li <longli@microsoft.com>
Cc: Marc Dionne <marc.dionne@auristor.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Richard Weinberger <richard@nod.at>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes (Oracle) and committed by
Andrew Morton
fbfc6578 c50ca15d

+6 -6
+6 -6
fs/afs/file.c
··· 19 19 #include <trace/events/netfs.h> 20 20 #include "internal.h" 21 21 22 - static int afs_file_mmap_prepare(struct vm_area_desc *desc); 22 + static int afs_file_mmap(struct file *file, struct vm_area_struct *vma); 23 23 24 24 static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter); 25 25 static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos, ··· 35 35 .llseek = generic_file_llseek, 36 36 .read_iter = afs_file_read_iter, 37 37 .write_iter = netfs_file_write_iter, 38 - .mmap_prepare = afs_file_mmap_prepare, 38 + .mmap = afs_file_mmap, 39 39 .splice_read = afs_file_splice_read, 40 40 .splice_write = iter_file_splice_write, 41 41 .fsync = afs_fsync, ··· 492 492 /* 493 493 * Handle setting up a memory mapping on an AFS file. 494 494 */ 495 - static int afs_file_mmap_prepare(struct vm_area_desc *desc) 495 + static int afs_file_mmap(struct file *file, struct vm_area_struct *vma) 496 496 { 497 - struct afs_vnode *vnode = AFS_FS_I(file_inode(desc->file)); 497 + struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); 498 498 int ret; 499 499 500 500 afs_add_open_mmap(vnode); 501 501 502 - ret = generic_file_mmap_prepare(desc); 502 + ret = generic_file_mmap(file, vma); 503 503 if (ret == 0) 504 - desc->vm_ops = &afs_vm_ops; 504 + vma->vm_ops = &afs_vm_ops; 505 505 else 506 506 afs_drop_open_mmap(vnode); 507 507 return ret;