Skip to content

Commit ad26fc0

Browse files
committed
Merge tag 'mm-hotfixes-stable-2025-01-16-21-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "7 singleton hotfixes. 6 are MM. Two are cc:stable and the remainder address post-6.12 issues" * tag 'mm-hotfixes-stable-2025-01-16-21-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: ocfs2: check dir i_size in ocfs2_find_entry mailmap: update entry for Ethan Carter Edwards mm: zswap: move allocations during CPU init outside the lock mm: khugepaged: fix call hpage_collapse_scan_file() for anonymous vma mm: shmem: use signed int for version handling in casefold option alloc_tag: skip pgalloc_tag_swap if profiling is disabled mm: page_alloc: fix missed updates of lowmem_reserve in adjust_managed_page_count
2 parents 9ca2729 + b0fce54 commit ad26fc0

File tree

7 files changed

+55
-25
lines changed

7 files changed

+55
-25
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ Elliot Berman <[email protected]> <[email protected]>
202202
Enric Balletbo i Serra <[email protected]> <[email protected]>
203203
Enric Balletbo i Serra <[email protected]> <[email protected]>
204204
205+
Ethan Carter Edwards <[email protected]> Ethan Edwards <[email protected]>
205206
206207
207208
Evgeniy Polyakov <[email protected]>

fs/ocfs2/dir.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,26 +1065,39 @@ int ocfs2_find_entry(const char *name, int namelen,
10651065
{
10661066
struct buffer_head *bh;
10671067
struct ocfs2_dir_entry *res_dir = NULL;
1068+
int ret = 0;
10681069

10691070
if (ocfs2_dir_indexed(dir))
10701071
return ocfs2_find_entry_dx(name, namelen, dir, lookup);
10711072

1073+
if (unlikely(i_size_read(dir) <= 0)) {
1074+
ret = -EFSCORRUPTED;
1075+
mlog_errno(ret);
1076+
goto out;
1077+
}
10721078
/*
10731079
* The unindexed dir code only uses part of the lookup
10741080
* structure, so there's no reason to push it down further
10751081
* than this.
10761082
*/
1077-
if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
1083+
if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
1084+
if (unlikely(i_size_read(dir) > dir->i_sb->s_blocksize)) {
1085+
ret = -EFSCORRUPTED;
1086+
mlog_errno(ret);
1087+
goto out;
1088+
}
10781089
bh = ocfs2_find_entry_id(name, namelen, dir, &res_dir);
1079-
else
1090+
} else {
10801091
bh = ocfs2_find_entry_el(name, namelen, dir, &res_dir);
1092+
}
10811093

10821094
if (bh == NULL)
10831095
return -ENOENT;
10841096

10851097
lookup->dl_leaf_bh = bh;
10861098
lookup->dl_entry = res_dir;
1087-
return 0;
1099+
out:
1100+
return ret;
10881101
}
10891102

10901103
/*
@@ -2010,6 +2023,7 @@ int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
20102023
*
20112024
* Return 0 if the name does not exist
20122025
* Return -EEXIST if the directory contains the name
2026+
* Return -EFSCORRUPTED if found corruption
20132027
*
20142028
* Callers should have i_rwsem + a cluster lock on dir
20152029
*/
@@ -2023,9 +2037,12 @@ int ocfs2_check_dir_for_entry(struct inode *dir,
20232037
trace_ocfs2_check_dir_for_entry(
20242038
(unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name);
20252039

2026-
if (ocfs2_find_entry(name, namelen, dir, &lookup) == 0) {
2040+
ret = ocfs2_find_entry(name, namelen, dir, &lookup);
2041+
if (ret == 0) {
20272042
ret = -EEXIST;
20282043
mlog_errno(ret);
2044+
} else if (ret == -ENOENT) {
2045+
ret = 0;
20292046
}
20302047

20312048
ocfs2_free_dir_lookup_result(&lookup);

lib/alloc_tag.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ void pgalloc_tag_swap(struct folio *new, struct folio *old)
195195
union codetag_ref ref_old, ref_new;
196196
struct alloc_tag *tag_old, *tag_new;
197197

198+
if (!mem_alloc_profiling_enabled())
199+
return;
200+
198201
tag_old = pgalloc_tag_get(&old->page);
199202
if (!tag_old)
200203
return;

mm/khugepaged.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,7 +2422,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
24222422
VM_BUG_ON(khugepaged_scan.address < hstart ||
24232423
khugepaged_scan.address + HPAGE_PMD_SIZE >
24242424
hend);
2425-
if (IS_ENABLED(CONFIG_SHMEM) && vma->vm_file) {
2425+
if (IS_ENABLED(CONFIG_SHMEM) && !vma_is_anonymous(vma)) {
24262426
struct file *file = get_file(vma->vm_file);
24272427
pgoff_t pgoff = linear_page_index(vma,
24282428
khugepaged_scan.address);
@@ -2768,7 +2768,7 @@ int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev,
27682768
mmap_assert_locked(mm);
27692769
memset(cc->node_load, 0, sizeof(cc->node_load));
27702770
nodes_clear(cc->alloc_nmask);
2771-
if (IS_ENABLED(CONFIG_SHMEM) && vma->vm_file) {
2771+
if (IS_ENABLED(CONFIG_SHMEM) && !vma_is_anonymous(vma)) {
27722772
struct file *file = get_file(vma->vm_file);
27732773
pgoff_t pgoff = linear_page_index(vma, addr);
27742774

mm/page_alloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5692,10 +5692,13 @@ __meminit void zone_pcp_init(struct zone *zone)
56925692
zone->present_pages, zone_batchsize(zone));
56935693
}
56945694

5695+
static void setup_per_zone_lowmem_reserve(void);
5696+
56955697
void adjust_managed_page_count(struct page *page, long count)
56965698
{
56975699
atomic_long_add(count, &page_zone(page)->managed_pages);
56985700
totalram_pages_add(count);
5701+
setup_per_zone_lowmem_reserve();
56995702
}
57005703
EXPORT_SYMBOL(adjust_managed_page_count);
57015704

mm/shmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4368,7 +4368,7 @@ static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *
43684368
bool latest_version)
43694369
{
43704370
struct shmem_options *ctx = fc->fs_private;
4371-
unsigned int version = UTF8_LATEST;
4371+
int version = UTF8_LATEST;
43724372
struct unicode_map *encoding;
43734373
char *version_str = param->string + 5;
43744374

mm/zswap.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -820,37 +820,41 @@ static int zswap_cpu_comp_prepare(unsigned int cpu, struct hlist_node *node)
820820
{
821821
struct zswap_pool *pool = hlist_entry(node, struct zswap_pool, node);
822822
struct crypto_acomp_ctx *acomp_ctx = per_cpu_ptr(pool->acomp_ctx, cpu);
823-
struct crypto_acomp *acomp;
824-
struct acomp_req *req;
823+
struct crypto_acomp *acomp = NULL;
824+
struct acomp_req *req = NULL;
825+
u8 *buffer = NULL;
825826
int ret;
826827

827-
mutex_lock(&acomp_ctx->mutex);
828-
acomp_ctx->buffer = kmalloc_node(PAGE_SIZE * 2, GFP_KERNEL, cpu_to_node(cpu));
829-
if (!acomp_ctx->buffer) {
828+
buffer = kmalloc_node(PAGE_SIZE * 2, GFP_KERNEL, cpu_to_node(cpu));
829+
if (!buffer) {
830830
ret = -ENOMEM;
831-
goto buffer_fail;
831+
goto fail;
832832
}
833833

834834
acomp = crypto_alloc_acomp_node(pool->tfm_name, 0, 0, cpu_to_node(cpu));
835835
if (IS_ERR(acomp)) {
836836
pr_err("could not alloc crypto acomp %s : %ld\n",
837837
pool->tfm_name, PTR_ERR(acomp));
838838
ret = PTR_ERR(acomp);
839-
goto acomp_fail;
839+
goto fail;
840840
}
841-
acomp_ctx->acomp = acomp;
842-
acomp_ctx->is_sleepable = acomp_is_async(acomp);
843841

844-
req = acomp_request_alloc(acomp_ctx->acomp);
842+
req = acomp_request_alloc(acomp);
845843
if (!req) {
846844
pr_err("could not alloc crypto acomp_request %s\n",
847845
pool->tfm_name);
848846
ret = -ENOMEM;
849-
goto req_fail;
847+
goto fail;
850848
}
851-
acomp_ctx->req = req;
852849

850+
/*
851+
* Only hold the mutex after completing allocations, otherwise we may
852+
* recurse into zswap through reclaim and attempt to hold the mutex
853+
* again resulting in a deadlock.
854+
*/
855+
mutex_lock(&acomp_ctx->mutex);
853856
crypto_init_wait(&acomp_ctx->wait);
857+
854858
/*
855859
* if the backend of acomp is async zip, crypto_req_done() will wakeup
856860
* crypto_wait_req(); if the backend of acomp is scomp, the callback
@@ -859,15 +863,17 @@ static int zswap_cpu_comp_prepare(unsigned int cpu, struct hlist_node *node)
859863
acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
860864
crypto_req_done, &acomp_ctx->wait);
861865

866+
acomp_ctx->buffer = buffer;
867+
acomp_ctx->acomp = acomp;
868+
acomp_ctx->is_sleepable = acomp_is_async(acomp);
869+
acomp_ctx->req = req;
862870
mutex_unlock(&acomp_ctx->mutex);
863871
return 0;
864872

865-
req_fail:
866-
crypto_free_acomp(acomp_ctx->acomp);
867-
acomp_fail:
868-
kfree(acomp_ctx->buffer);
869-
buffer_fail:
870-
mutex_unlock(&acomp_ctx->mutex);
873+
fail:
874+
if (acomp)
875+
crypto_free_acomp(acomp);
876+
kfree(buffer);
871877
return ret;
872878
}
873879

0 commit comments

Comments
 (0)