Skip to content

Commit 6e50979

Browse files
committed
Merge tag 'mm-hotfixes-stable-2023-01-16-15-23' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc hotfixes from Andrew Morton: "21 hotfixes. Thirteen of these address pre-6.1 issues and hence have the cc:stable tag" * tag 'mm-hotfixes-stable-2023-01-16-15-23' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (21 commits) init/Kconfig: fix typo (usafe -> unsafe) nommu: fix split_vma() map_count error nommu: fix do_munmap() error path nommu: fix memory leak in do_mmap() error path MAINTAINERS: update Robert Foss' email address proc: fix PIE proc-empty-vm, proc-pid-vm tests mm: update mmap_sem comments to refer to mmap_lock include/linux/mm: fix release_pages_arg kernel doc comment lib/win_minmax: use /* notation for regular comments kasan: mark kasan_kunit_executing as static nilfs2: fix general protection fault in nilfs_btree_insert() Docs/admin-guide/mm/zswap: remove zsmalloc's lack of writeback warning mm/hugetlb: pre-allocate pgtable pages for uffd wr-protects hugetlb: unshare some PMDs when splitting VMAs mm: fix vma->anon_name memory leak for anonymous shmem VMAs mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE mm/MADV_COLLAPSE: don't expand collapse when vm_end is past requested end mm/userfaultfd: enable writenotify while userfaultfd-wp is enabled for a VMA mm/khugepaged: fix collapse_pte_mapped_thp() to allow anon_vma mm/hugetlb: fix uffd-wp handling for migration entries in hugetlb_change_protection() ...
2 parents d532dd1 + 19fa92f commit 6e50979

File tree

20 files changed

+146
-88
lines changed

20 files changed

+146
-88
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ Rémi Denis-Courmont <[email protected]>
371371
372372
Ricardo Ribalda <[email protected]> Ricardo Ribalda Delgado <[email protected]>
373373
374+
374375
375376
376377

Documentation/admin-guide/mm/zswap.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ e.g. ``zswap.zpool=zbud``. It can also be changed at runtime using the sysfs
7070
The zbud type zpool allocates exactly 1 page to store 2 compressed pages, which
7171
means the compression ratio will always be 2:1 or worse (because of half-full
7272
zbud pages). The zsmalloc type zpool has a more complex compressed page
73-
storage method, and it can achieve greater storage densities. However,
74-
zsmalloc does not implement compressed page eviction, so once zswap fills it
75-
cannot evict the oldest page, it can only reject new pages.
73+
storage method, and it can achieve greater storage densities.
7674

7775
When a swap page is passed from frontswap to zswap, zswap maintains a mapping
7876
of the swap entry, a combination of the swap type and swap offset, to the zpool

MAINTAINERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6948,7 +6948,7 @@ F: drivers/gpu/drm/atmel-hlcdc/
69486948
DRM DRIVERS FOR BRIDGE CHIPS
69496949
M: Andrzej Hajda <[email protected]>
69506950
M: Neil Armstrong <[email protected]>
6951-
M: Robert Foss <robert.foss@linaro.org>
6951+
M: Robert Foss <rfoss@kernel.org>
69526952
R: Laurent Pinchart <[email protected]>
69536953
R: Jonas Karlman <[email protected]>
69546954
R: Jernej Skrabec <[email protected]>
@@ -17238,7 +17238,7 @@ F: Documentation/devicetree/bindings/net/qcom,bam-dmux.yaml
1723817238
F: drivers/net/wwan/qcom_bam_dmux.c
1723917239

1724017240
QUALCOMM CAMERA SUBSYSTEM DRIVER
17241-
M: Robert Foss <robert.foss@linaro.org>
17241+
M: Robert Foss <rfoss@kernel.org>
1724217242
M: Todor Tomov <[email protected]>
1724317243
1724417244
S: Maintained
@@ -17318,7 +17318,7 @@ F: drivers/dma/qcom/hidma*
1731817318

1731917319
QUALCOMM I2C CCI DRIVER
1732017320
M: Loic Poulain <[email protected]>
17321-
M: Robert Foss <robert.foss@linaro.org>
17321+
M: Robert Foss <rfoss@kernel.org>
1732217322
1732317323
1732417324
S: Maintained

fs/nilfs2/btree.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,18 @@ static int __nilfs_btree_get_block(const struct nilfs_bmap *btree, __u64 ptr,
480480
ret = nilfs_btnode_submit_block(btnc, ptr, 0, REQ_OP_READ, &bh,
481481
&submit_ptr);
482482
if (ret) {
483-
if (ret != -EEXIST)
484-
return ret;
485-
goto out_check;
483+
if (likely(ret == -EEXIST))
484+
goto out_check;
485+
if (ret == -ENOENT) {
486+
/*
487+
* Block address translation failed due to invalid
488+
* value of 'ptr'. In this case, return internal code
489+
* -EINVAL (broken bmap) to notify bmap layer of fatal
490+
* metadata corruption.
491+
*/
492+
ret = -EINVAL;
493+
}
494+
return ret;
486495
}
487496

488497
if (ra) {

fs/userfaultfd.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ static bool userfaultfd_is_initialized(struct userfaultfd_ctx *ctx)
108108
return ctx->features & UFFD_FEATURE_INITIALIZED;
109109
}
110110

111+
static void userfaultfd_set_vm_flags(struct vm_area_struct *vma,
112+
vm_flags_t flags)
113+
{
114+
const bool uffd_wp_changed = (vma->vm_flags ^ flags) & VM_UFFD_WP;
115+
116+
vma->vm_flags = flags;
117+
/*
118+
* For shared mappings, we want to enable writenotify while
119+
* userfaultfd-wp is enabled (see vma_wants_writenotify()). We'll simply
120+
* recalculate vma->vm_page_prot whenever userfaultfd-wp changes.
121+
*/
122+
if ((vma->vm_flags & VM_SHARED) && uffd_wp_changed)
123+
vma_set_page_prot(vma);
124+
}
125+
111126
static int userfaultfd_wake_function(wait_queue_entry_t *wq, unsigned mode,
112127
int wake_flags, void *key)
113128
{
@@ -618,7 +633,8 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
618633
for_each_vma(vmi, vma) {
619634
if (vma->vm_userfaultfd_ctx.ctx == release_new_ctx) {
620635
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
621-
vma->vm_flags &= ~__VM_UFFD_FLAGS;
636+
userfaultfd_set_vm_flags(vma,
637+
vma->vm_flags & ~__VM_UFFD_FLAGS);
622638
}
623639
}
624640
mmap_write_unlock(mm);
@@ -652,7 +668,7 @@ int dup_userfaultfd(struct vm_area_struct *vma, struct list_head *fcs)
652668
octx = vma->vm_userfaultfd_ctx.ctx;
653669
if (!octx || !(octx->features & UFFD_FEATURE_EVENT_FORK)) {
654670
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
655-
vma->vm_flags &= ~__VM_UFFD_FLAGS;
671+
userfaultfd_set_vm_flags(vma, vma->vm_flags & ~__VM_UFFD_FLAGS);
656672
return 0;
657673
}
658674

@@ -733,7 +749,7 @@ void mremap_userfaultfd_prep(struct vm_area_struct *vma,
733749
} else {
734750
/* Drop uffd context if remap feature not enabled */
735751
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
736-
vma->vm_flags &= ~__VM_UFFD_FLAGS;
752+
userfaultfd_set_vm_flags(vma, vma->vm_flags & ~__VM_UFFD_FLAGS);
737753
}
738754
}
739755

@@ -895,7 +911,7 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
895911
prev = vma;
896912
}
897913

898-
vma->vm_flags = new_flags;
914+
userfaultfd_set_vm_flags(vma, new_flags);
899915
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
900916
}
901917
mmap_write_unlock(mm);
@@ -1463,7 +1479,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
14631479
* the next vma was merged into the current one and
14641480
* the current one has not been updated yet.
14651481
*/
1466-
vma->vm_flags = new_flags;
1482+
userfaultfd_set_vm_flags(vma, new_flags);
14671483
vma->vm_userfaultfd_ctx.ctx = ctx;
14681484

14691485
if (is_vm_hugetlb_page(vma) && uffd_disable_huge_pmd_share(vma))
@@ -1651,7 +1667,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
16511667
* the next vma was merged into the current one and
16521668
* the current one has not been updated yet.
16531669
*/
1654-
vma->vm_flags = new_flags;
1670+
userfaultfd_set_vm_flags(vma, new_flags);
16551671
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
16561672

16571673
skip:

include/linux/mm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,10 +1270,10 @@ static inline void folio_put_refs(struct folio *folio, int refs)
12701270
__folio_put(folio);
12711271
}
12721272

1273-
/**
1274-
* release_pages - release an array of pages or folios
1273+
/*
1274+
* union release_pages_arg - an array of pages or folios
12751275
*
1276-
* This just releases a simple array of multiple pages, and
1276+
* release_pages() releases a simple array of multiple pages, and
12771277
* accepts various different forms of said page array: either
12781278
* a regular old boring array of pages, an array of folios, or
12791279
* an array of encoded page pointers.

include/linux/mm_inline.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,7 @@ static inline void free_anon_vma_name(struct vm_area_struct *vma)
413413
* Not using anon_vma_name because it generates a warning if mmap_lock
414414
* is not held, which might be the case here.
415415
*/
416-
if (!vma->vm_file)
417-
anon_vma_name_put(vma->anon_name);
416+
anon_vma_name_put(vma->anon_name);
418417
}
419418

420419
static inline bool anon_vma_name_eq(struct anon_vma_name *anon_name1,

include/linux/mm_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ struct vm_area_struct {
581581
/*
582582
* For private and shared anonymous mappings, a pointer to a null
583583
* terminated string containing the name given to the vma, or NULL if
584-
* unnamed. Serialized by mmap_sem. Use anon_vma_name to access.
584+
* unnamed. Serialized by mmap_lock. Use anon_vma_name to access.
585585
*/
586586
struct anon_vma_name *anon_name;
587587
#endif

include/linux/page_ref.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static inline bool folio_ref_try_add_rcu(struct folio *folio, int count)
301301
*
302302
* You can also use this function if you're holding a lock that prevents
303303
* pages being frozen & removed; eg the i_pages lock for the page cache
304-
* or the mmap_sem or page table lock for page tables. In this case,
304+
* or the mmap_lock or page table lock for page tables. In this case,
305305
* it will always succeed, and you could have used a plain folio_get(),
306306
* but it's sometimes more convenient to have a common function called
307307
* from both locked and RCU-protected contexts.

init/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ config PRINTK_SAFE_LOG_BUF_SHIFT
776776
depends on PRINTK
777777
help
778778
Select the size of an alternate printk per-CPU buffer where messages
779-
printed from usafe contexts are temporary stored. One example would
779+
printed from unsafe contexts are temporary stored. One example would
780780
be NMI messages, another one - printk recursion. The messages are
781781
copied to the main log buffer in a safe context to avoid a deadlock.
782782
The value defines the size as a power of 2.

0 commit comments

Comments
 (0)