History

mm/vma: remove mmap_action->success_hook

This hook was introduced to work around code that seemed to absolutely require access to a VMA pointer upon mmap(). However, providing this hook leaves a backdoor to drivers getting access to the very thing mmap_prepare eliminates - a pointer to the VMA. Let's solve this contradiction by removing it. The key intended user was hugetlb, however it seems that the best course now is to avoid allowing all drivers the ability to work around mmap_prepare, and find a different solution there.

Lorenzo Stoakes committed 5 months ago

Commit 8876dc01 parent 17986193 files · +0 −22Browse files

Unified · Split

3 files
  1. include/linux/mm_types.h +0 −10
  2. mm/util.c +0 −2
  3. tools/testing/vma/include/dup.h +0 −10
include/linux/mm_types.h+0−10
@@ -843,16 +843,6 @@ struct mmap_action { · 842 unmodified lines
843 };843 };
844 enum mmap_action_type type;844 enum mmap_action_type type;
845 845
846 /*
847 * If specified, this hook is invoked after the selected action has been
848 * successfully completed. Note that the VMA write lock still held.
849 *
850 * The absolute minimum ought to be done here.
851 *
852 * Returns 0 on success, or an error code.
853 */
854 int (*success_hook)(const struct vm_area_struct *vma);
855
856 /*846 /*
857 * If specified, this hook is invoked when an error occurred when847 * If specified, this hook is invoked when an error occurred when
858 * attempting the selected action.848 * attempting the selected action.
mm/util.c+0−2
@@ -1397,8 +1397,6 @@ static int mmap_action_finish(struct vm_area_struct *vma, · 1396 unmodified lines
1397 1397
1398 if (!err)1398 if (!err)
1399 err = call_vma_mapped(vma);1399 err = call_vma_mapped(vma);
1400 if (!err && action->success_hook)
1401 err = action->success_hook(vma);
1402 1400
1403 /* do_munmap() might take rmap lock, so release if held. */1401 /* do_munmap() might take rmap lock, so release if held. */
1404 maybe_rmap_unlock_action(vma, action);1402 maybe_rmap_unlock_action(vma, action);
tools/testing/vma/include/dup.h+0−10
@@ -482,16 +482,6 @@ struct mmap_action { · 481 unmodified lines
482 };482 };
483 enum mmap_action_type type;483 enum mmap_action_type type;
484 484
485 /*
486 * If specified, this hook is invoked after the selected action has been
487 * successfully completed. Note that the VMA write lock still held.
488 *
489 * The absolute minimum ought to be done here.
490 *
491 * Returns 0 on success, or an error code.
492 */
493 int (*success_hook)(const struct vm_area_struct *vma);
494
495 /*485 /*
496 * If specified, this hook is invoked when an error occurred when486 * If specified, this hook is invoked when an error occurred when
497 * attempting the selection action.487 * attempting the selection action.