Skip to content

Commit 66d6489

Browse files
committed
Merge tag 'mm-hotfixes-stable-2026-04-06-15-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "Eight hotfixes. All are cc:stable and seven are for MM. All are singletons - please see the changelogs for details" * tag 'mm-hotfixes-stable-2026-04-06-15-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: ocfs2: fix out-of-bounds write in ocfs2_write_end_inline mm/damon/stat: deallocate damon_call() failure leaking damon_ctx mm/vma: fix memory leak in __mmap_region() mm/memory_hotplug: maintain N_NORMAL_MEMORY during hotplug mm/damon/sysfs: dealloc repeat_call_control if damon_call() fails mm: reinstate unconditional writeback start in balance_dirty_pages() liveupdate: propagate file deserialization failures mm: filemap: fix nr_pages calculation overflow in filemap_map_pages()
2 parents bfe62a4 + 7bc5da4 commit 66d6489

8 files changed

Lines changed: 82 additions & 6 deletions

File tree

fs/ocfs2/inode.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,16 @@ int ocfs2_validate_inode_block(struct super_block *sb,
15051505
goto bail;
15061506
}
15071507

1508+
if (le16_to_cpu(data->id_count) >
1509+
ocfs2_max_inline_data_with_xattr(sb, di)) {
1510+
rc = ocfs2_error(sb,
1511+
"Invalid dinode #%llu: inline data id_count %u exceeds max %d\n",
1512+
(unsigned long long)bh->b_blocknr,
1513+
le16_to_cpu(data->id_count),
1514+
ocfs2_max_inline_data_with_xattr(sb, di));
1515+
goto bail;
1516+
}
1517+
15081518
if (le64_to_cpu(di->i_size) > le16_to_cpu(data->id_count)) {
15091519
rc = ocfs2_error(sb,
15101520
"Invalid dinode #%llu: inline data i_size %llu exceeds id_count %u\n",

kernel/liveupdate/luo_session.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,13 @@ int luo_session_deserialize(void)
558558
}
559559

560560
scoped_guard(mutex, &session->mutex) {
561-
luo_file_deserialize(&session->file_set,
562-
&sh->ser[i].file_set_ser);
561+
err = luo_file_deserialize(&session->file_set,
562+
&sh->ser[i].file_set_ser);
563+
}
564+
if (err) {
565+
pr_warn("Failed to deserialize files for session [%s] %pe\n",
566+
session->name, ERR_PTR(err));
567+
return err;
563568
}
564569
}
565570

mm/damon/stat.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ static int damon_stat_start(void)
245245
{
246246
int err;
247247

248+
if (damon_stat_context) {
249+
if (damon_is_running(damon_stat_context))
250+
return -EAGAIN;
251+
damon_destroy_ctx(damon_stat_context);
252+
}
253+
248254
damon_stat_context = damon_stat_build_ctx();
249255
if (!damon_stat_context)
250256
return -ENOMEM;
@@ -261,6 +267,7 @@ static void damon_stat_stop(void)
261267
{
262268
damon_stop(&damon_stat_context, 1);
263269
damon_destroy_ctx(damon_stat_context);
270+
damon_stat_context = NULL;
264271
}
265272

266273
static int damon_stat_enabled_store(

mm/damon/sysfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,8 @@ static int damon_sysfs_turn_damon_on(struct damon_sysfs_kdamond *kdamond)
16701670
repeat_call_control->data = kdamond;
16711671
repeat_call_control->repeat = true;
16721672
repeat_call_control->dealloc_on_cancel = true;
1673-
damon_call(ctx, repeat_call_control);
1673+
if (damon_call(ctx, repeat_call_control))
1674+
kfree(repeat_call_control);
16741675
return err;
16751676
}
16761677

mm/filemap.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3883,14 +3883,19 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
38833883
unsigned int nr_pages = 0, folio_type;
38843884
unsigned short mmap_miss = 0, mmap_miss_saved;
38853885

3886+
/*
3887+
* Recalculate end_pgoff based on file_end before calling
3888+
* next_uptodate_folio() to avoid races with concurrent
3889+
* truncation.
3890+
*/
3891+
file_end = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE) - 1;
3892+
end_pgoff = min(end_pgoff, file_end);
3893+
38863894
rcu_read_lock();
38873895
folio = next_uptodate_folio(&xas, mapping, end_pgoff);
38883896
if (!folio)
38893897
goto out;
38903898

3891-
file_end = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE) - 1;
3892-
end_pgoff = min(end_pgoff, file_end);
3893-
38943899
/*
38953900
* Do not allow to map with PMD across i_size to preserve
38963901
* SIGBUS semantics.

mm/memory_hotplug.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,13 @@ int online_pages(unsigned long pfn, unsigned long nr_pages,
12091209

12101210
if (node_arg.nid >= 0)
12111211
node_set_state(nid, N_MEMORY);
1212+
/*
1213+
* Check whether we are adding normal memory to the node for the first
1214+
* time.
1215+
*/
1216+
if (!node_state(nid, N_NORMAL_MEMORY) && zone_idx(zone) <= ZONE_NORMAL)
1217+
node_set_state(nid, N_NORMAL_MEMORY);
1218+
12121219
if (need_zonelists_rebuild)
12131220
build_all_zonelists(NULL);
12141221

@@ -1908,6 +1915,8 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages,
19081915
unsigned long flags;
19091916
char *reason;
19101917
int ret;
1918+
unsigned long normal_pages = 0;
1919+
enum zone_type zt;
19111920

19121921
/*
19131922
* {on,off}lining is constrained to full memory sections (or more
@@ -2055,6 +2064,17 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages,
20552064
/* reinitialise watermarks and update pcp limits */
20562065
init_per_zone_wmark_min();
20572066

2067+
/*
2068+
* Check whether this operation removes the last normal memory from
2069+
* the node. We do this before clearing N_MEMORY to avoid the possible
2070+
* transient "!N_MEMORY && N_NORMAL_MEMORY" state.
2071+
*/
2072+
if (zone_idx(zone) <= ZONE_NORMAL) {
2073+
for (zt = 0; zt <= ZONE_NORMAL; zt++)
2074+
normal_pages += pgdat->node_zones[zt].present_pages;
2075+
if (!normal_pages)
2076+
node_clear_state(node, N_NORMAL_MEMORY);
2077+
}
20582078
/*
20592079
* Make sure to mark the node as memory-less before rebuilding the zone
20602080
* list. Otherwise this node would still appear in the fallback lists.

mm/page-writeback.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,27 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
18581858
break;
18591859
}
18601860

1861+
/*
1862+
* Unconditionally start background writeback if it's not
1863+
* already in progress. We need to do this because the global
1864+
* dirty threshold check above (nr_dirty > gdtc->bg_thresh)
1865+
* doesn't account for these cases:
1866+
*
1867+
* a) strictlimit BDIs: throttling is calculated using per-wb
1868+
* thresholds. The per-wb threshold can be exceeded even when
1869+
* nr_dirty < gdtc->bg_thresh
1870+
*
1871+
* b) memcg-based throttling: memcg uses its own dirty count and
1872+
* thresholds and can trigger throttling even when global
1873+
* nr_dirty < gdtc->bg_thresh
1874+
*
1875+
* Writeback needs to be started else the writer stalls in the
1876+
* throttle loop waiting for dirty pages to be written back
1877+
* while no writeback is running.
1878+
*/
1879+
if (unlikely(!writeback_in_progress(wb)))
1880+
wb_start_background_writeback(wb);
1881+
18611882
mem_cgroup_flush_foreign(wb);
18621883

18631884
/*

mm/vma.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,6 +2781,13 @@ static unsigned long __mmap_region(struct file *file, unsigned long addr,
27812781
if (map.charged)
27822782
vm_unacct_memory(map.charged);
27832783
abort_munmap:
2784+
/*
2785+
* This indicates that .mmap_prepare has set a new file, differing from
2786+
* desc->vm_file. But since we're aborting the operation, only the
2787+
* original file will be cleaned up. Ensure we clean up both.
2788+
*/
2789+
if (map.file_doesnt_need_get)
2790+
fput(map.file);
27842791
vms_abort_munmap_vmas(&map.vms, &map.mas_detach);
27852792
return error;
27862793
}

0 commit comments

Comments
 (0)