Skip to content

Commit fb05409

Browse files
committed
Merge tag 'mm-hotfixes-stable-2023-06-12-12-22' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "19 hotfixes. 14 are cc:stable and the remainder address issues which were introduced during this development cycle or which were considered inappropriate for a backport" * tag 'mm-hotfixes-stable-2023-06-12-12-22' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: zswap: do not shrink if cgroup may not zswap page cache: fix page_cache_next/prev_miss off by one ocfs2: check new file size on fallocate call mailmap: add entry for John Keeping mm/damon/core: fix divide error in damon_nr_accesses_to_accesses_bp() epoll: ep_autoremove_wake_function should use list_del_init_careful mm/gup_test: fix ioctl fail for compat task nilfs2: reject devices with insufficient block count ocfs2: fix use-after-free when unmounting read-only filesystem lib/test_vmalloc.c: avoid garbage in page array nilfs2: fix possible out-of-bounds segment allocation in resize ioctl riscv/purgatory: remove PGO flags powerpc/purgatory: remove PGO flags x86/purgatory: remove PGO flags kexec: support purgatories with .text.hot sections mm/uffd: allow vma to merge as much as possible mm/uffd: fix vma operation where start addr cuts part of vma radix-tree: move declarations to header nilfs2: fix incomplete buffer cleanup in nilfs_btnode_abort_change_key()
2 parents fd37b88 + 0bdf0ef commit fb05409

File tree

21 files changed

+161
-29
lines changed

21 files changed

+161
-29
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ Jisheng Zhang <[email protected]> <[email protected]>
233233
234234
235235
236+
236237
John Paul Adrian Glaubitz <[email protected]>
237238
John Stultz <[email protected]>
238239

arch/powerpc/purgatory/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ KCSAN_SANITIZE := n
55

66
targets += trampoline_$(BITS).o purgatory.ro
77

8+
# When profile-guided optimization is enabled, llvm emits two different
9+
# overlapping text sections, which is not supported by kexec. Remove profile
10+
# optimization flags.
11+
KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
12+
813
LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined
914

1015
$(obj)/purgatory.ro: $(obj)/trampoline_$(BITS).o FORCE

arch/riscv/purgatory/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS
3535
CFLAGS_string.o := -D__DISABLE_EXPORTS
3636
CFLAGS_ctype.o := -D__DISABLE_EXPORTS
3737

38+
# When profile-guided optimization is enabled, llvm emits two different
39+
# overlapping text sections, which is not supported by kexec. Remove profile
40+
# optimization flags.
41+
KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
42+
3843
# When linking purgatory.ro with -r unresolved symbols are not checked,
3944
# also link a purgatory.chk binary without -r to check for unresolved symbols.
4045
PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib

arch/x86/purgatory/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
1414

1515
CFLAGS_sha256.o := -D__DISABLE_EXPORTS
1616

17+
# When profile-guided optimization is enabled, llvm emits two different
18+
# overlapping text sections, which is not supported by kexec. Remove profile
19+
# optimization flags.
20+
KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
21+
1722
# When linking purgatory.ro with -r unresolved symbols are not checked,
1823
# also link a purgatory.chk binary without -r to check for unresolved symbols.
1924
PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib

fs/eventpoll.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,11 @@ static int ep_autoremove_wake_function(struct wait_queue_entry *wq_entry,
18051805
{
18061806
int ret = default_wake_function(wq_entry, mode, sync, key);
18071807

1808-
list_del_init(&wq_entry->entry);
1808+
/*
1809+
* Pairs with list_empty_careful in ep_poll, and ensures future loop
1810+
* iterations see the cause of this wakeup.
1811+
*/
1812+
list_del_init_careful(&wq_entry->entry);
18091813
return ret;
18101814
}
18111815

fs/nilfs2/btnode.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,14 @@ void nilfs_btnode_abort_change_key(struct address_space *btnc,
285285
if (nbh == NULL) { /* blocksize == pagesize */
286286
xa_erase_irq(&btnc->i_pages, newkey);
287287
unlock_page(ctxt->bh->b_page);
288-
} else
289-
brelse(nbh);
288+
} else {
289+
/*
290+
* When canceling a buffer that a prepare operation has
291+
* allocated to copy a node block to another location, use
292+
* nilfs_btnode_delete() to initialize and release the buffer
293+
* so that the buffer flags will not be in an inconsistent
294+
* state when it is reallocated.
295+
*/
296+
nilfs_btnode_delete(nbh);
297+
}
290298
}

fs/nilfs2/sufile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,15 @@ int nilfs_sufile_resize(struct inode *sufile, __u64 newnsegs)
779779
goto out_header;
780780

781781
sui->ncleansegs -= nsegs - newnsegs;
782+
783+
/*
784+
* If the sufile is successfully truncated, immediately adjust
785+
* the segment allocation space while locking the semaphore
786+
* "mi_sem" so that nilfs_sufile_alloc() never allocates
787+
* segments in the truncated space.
788+
*/
789+
sui->allocmax = newnsegs - 1;
790+
sui->allocmin = 0;
782791
}
783792

784793
kaddr = kmap_atomic(header_bh->b_page);

fs/nilfs2/the_nilfs.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,18 @@ unsigned long nilfs_nrsvsegs(struct the_nilfs *nilfs, unsigned long nsegs)
405405
100));
406406
}
407407

408+
/**
409+
* nilfs_max_segment_count - calculate the maximum number of segments
410+
* @nilfs: nilfs object
411+
*/
412+
static u64 nilfs_max_segment_count(struct the_nilfs *nilfs)
413+
{
414+
u64 max_count = U64_MAX;
415+
416+
do_div(max_count, nilfs->ns_blocks_per_segment);
417+
return min_t(u64, max_count, ULONG_MAX);
418+
}
419+
408420
void nilfs_set_nsegments(struct the_nilfs *nilfs, unsigned long nsegs)
409421
{
410422
nilfs->ns_nsegments = nsegs;
@@ -414,6 +426,8 @@ void nilfs_set_nsegments(struct the_nilfs *nilfs, unsigned long nsegs)
414426
static int nilfs_store_disk_layout(struct the_nilfs *nilfs,
415427
struct nilfs_super_block *sbp)
416428
{
429+
u64 nsegments, nblocks;
430+
417431
if (le32_to_cpu(sbp->s_rev_level) < NILFS_MIN_SUPP_REV) {
418432
nilfs_err(nilfs->ns_sb,
419433
"unsupported revision (superblock rev.=%d.%d, current rev.=%d.%d). Please check the version of mkfs.nilfs(2).",
@@ -457,7 +471,34 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs,
457471
return -EINVAL;
458472
}
459473

460-
nilfs_set_nsegments(nilfs, le64_to_cpu(sbp->s_nsegments));
474+
nsegments = le64_to_cpu(sbp->s_nsegments);
475+
if (nsegments > nilfs_max_segment_count(nilfs)) {
476+
nilfs_err(nilfs->ns_sb,
477+
"segment count %llu exceeds upper limit (%llu segments)",
478+
(unsigned long long)nsegments,
479+
(unsigned long long)nilfs_max_segment_count(nilfs));
480+
return -EINVAL;
481+
}
482+
483+
nblocks = sb_bdev_nr_blocks(nilfs->ns_sb);
484+
if (nblocks) {
485+
u64 min_block_count = nsegments * nilfs->ns_blocks_per_segment;
486+
/*
487+
* To avoid failing to mount early device images without a
488+
* second superblock, exclude that block count from the
489+
* "min_block_count" calculation.
490+
*/
491+
492+
if (nblocks < min_block_count) {
493+
nilfs_err(nilfs->ns_sb,
494+
"total number of segment blocks %llu exceeds device size (%llu blocks)",
495+
(unsigned long long)min_block_count,
496+
(unsigned long long)nblocks);
497+
return -EINVAL;
498+
}
499+
}
500+
501+
nilfs_set_nsegments(nilfs, nsegments);
461502
nilfs->ns_crc_seed = le32_to_cpu(sbp->s_crc_seed);
462503
return 0;
463504
}

fs/ocfs2/file.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,14 +2100,20 @@ static long ocfs2_fallocate(struct file *file, int mode, loff_t offset,
21002100
struct ocfs2_space_resv sr;
21012101
int change_size = 1;
21022102
int cmd = OCFS2_IOC_RESVSP64;
2103+
int ret = 0;
21032104

21042105
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
21052106
return -EOPNOTSUPP;
21062107
if (!ocfs2_writes_unwritten_extents(osb))
21072108
return -EOPNOTSUPP;
21082109

2109-
if (mode & FALLOC_FL_KEEP_SIZE)
2110+
if (mode & FALLOC_FL_KEEP_SIZE) {
21102111
change_size = 0;
2112+
} else {
2113+
ret = inode_newsize_ok(inode, offset + len);
2114+
if (ret)
2115+
return ret;
2116+
}
21112117

21122118
if (mode & FALLOC_FL_PUNCH_HOLE)
21132119
cmd = OCFS2_IOC_UNRESVSP64;

fs/ocfs2/super.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,10 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb)
952952
for (type = 0; type < OCFS2_MAXQUOTAS; type++) {
953953
if (!sb_has_quota_loaded(sb, type))
954954
continue;
955-
oinfo = sb_dqinfo(sb, type)->dqi_priv;
956-
cancel_delayed_work_sync(&oinfo->dqi_sync_work);
955+
if (!sb_has_quota_suspended(sb, type)) {
956+
oinfo = sb_dqinfo(sb, type)->dqi_priv;
957+
cancel_delayed_work_sync(&oinfo->dqi_sync_work);
958+
}
957959
inode = igrab(sb->s_dquot.files[type]);
958960
/* Turn off quotas. This will remove all dquot structures from
959961
* memory and so they will be automatically synced to global

0 commit comments

Comments
 (0)