Skip to content

Commit 8dd7168

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "12 patches. Subsystems affected by this patch series: sysctl, binfmt, ia64, mm (memory-failure, folios, kasan, and psi), selftests, and ocfs2" * emailed patches from Andrew Morton <[email protected]>: ocfs2: fix a deadlock when commit trans jbd2: export jbd2_journal_[grab|put]_journal_head psi: fix "defined but not used" warnings when CONFIG_PROC_FS=n psi: fix "no previous prototype" warnings when CONFIG_CGROUPS=n mm, kasan: use compare-exchange operation to set KASAN page tag kasan: test: fix compatibility with FORTIFY_SOURCE tools/testing/scatterlist: add missing defines mm: page->mapping folio->mapping should have the same offset memory-failure: fetch compound_head after pgmap_pfn_valid() ia64: make IA64_MCA_RECOVERY bool instead of tristate binfmt_misc: fix crash when load/unload module include/linux/sysctl.h: fix register_sysctl_mount_point() return type
2 parents f8c7e4e + ddf4b77 commit 8dd7168

File tree

12 files changed

+91
-70
lines changed

12 files changed

+91
-70
lines changed

arch/ia64/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ config ARCH_PROC_KCORE_TEXT
318318
depends on PROC_KCORE
319319

320320
config IA64_MCA_RECOVERY
321-
tristate "MCA recovery from errors other than TLB."
321+
bool "MCA recovery from errors other than TLB."
322322

323323
config IA64_PALINFO
324324
tristate "/proc/pal support"

fs/binfmt_misc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,20 +817,20 @@ static struct file_system_type bm_fs_type = {
817817
};
818818
MODULE_ALIAS_FS("binfmt_misc");
819819

820+
static struct ctl_table_header *binfmt_misc_header;
821+
820822
static int __init init_misc_binfmt(void)
821823
{
822824
int err = register_filesystem(&bm_fs_type);
823825
if (!err)
824826
insert_binfmt(&misc_format);
825-
if (!register_sysctl_mount_point("fs/binfmt_misc")) {
826-
pr_warn("Failed to create fs/binfmt_misc sysctl mount point");
827-
return -ENOMEM;
828-
}
827+
binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");
829828
return 0;
830829
}
831830

832831
static void __exit exit_misc_binfmt(void)
833832
{
833+
unregister_sysctl_table(binfmt_misc_header);
834834
unregister_binfmt(&misc_format);
835835
unregister_filesystem(&bm_fs_type);
836836
}

fs/jbd2/journal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,7 @@ struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh)
29722972
jbd_unlock_bh_journal_head(bh);
29732973
return jh;
29742974
}
2975+
EXPORT_SYMBOL(jbd2_journal_grab_journal_head);
29752976

29762977
static void __journal_remove_journal_head(struct buffer_head *bh)
29772978
{
@@ -3024,6 +3025,7 @@ void jbd2_journal_put_journal_head(struct journal_head *jh)
30243025
jbd_unlock_bh_journal_head(bh);
30253026
}
30263027
}
3028+
EXPORT_SYMBOL(jbd2_journal_put_journal_head);
30273029

30283030
/*
30293031
* Initialize jbd inode head

fs/ocfs2/suballoc.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,26 +1251,23 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
12511251
{
12521252
struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
12531253
struct journal_head *jh;
1254-
int ret = 1;
1254+
int ret;
12551255

12561256
if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
12571257
return 0;
12581258

1259-
if (!buffer_jbd(bg_bh))
1259+
jh = jbd2_journal_grab_journal_head(bg_bh);
1260+
if (!jh)
12601261
return 1;
12611262

1262-
jbd_lock_bh_journal_head(bg_bh);
1263-
if (buffer_jbd(bg_bh)) {
1264-
jh = bh2jh(bg_bh);
1265-
spin_lock(&jh->b_state_lock);
1266-
bg = (struct ocfs2_group_desc *) jh->b_committed_data;
1267-
if (bg)
1268-
ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
1269-
else
1270-
ret = 1;
1271-
spin_unlock(&jh->b_state_lock);
1272-
}
1273-
jbd_unlock_bh_journal_head(bg_bh);
1263+
spin_lock(&jh->b_state_lock);
1264+
bg = (struct ocfs2_group_desc *) jh->b_committed_data;
1265+
if (bg)
1266+
ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
1267+
else
1268+
ret = 1;
1269+
spin_unlock(&jh->b_state_lock);
1270+
jbd2_journal_put_journal_head(jh);
12741271

12751272
return ret;
12761273
}

include/linux/mm.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,11 +1506,18 @@ static inline u8 page_kasan_tag(const struct page *page)
15061506

15071507
static inline void page_kasan_tag_set(struct page *page, u8 tag)
15081508
{
1509-
if (kasan_enabled()) {
1510-
tag ^= 0xff;
1511-
page->flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT);
1512-
page->flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT;
1513-
}
1509+
unsigned long old_flags, flags;
1510+
1511+
if (!kasan_enabled())
1512+
return;
1513+
1514+
tag ^= 0xff;
1515+
old_flags = READ_ONCE(page->flags);
1516+
do {
1517+
flags = old_flags;
1518+
flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT);
1519+
flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT;
1520+
} while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags)));
15141521
}
15151522

15161523
static inline void page_kasan_tag_reset(struct page *page)

include/linux/mm_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ static_assert(sizeof(struct page) == sizeof(struct folio));
261261
static_assert(offsetof(struct page, pg) == offsetof(struct folio, fl))
262262
FOLIO_MATCH(flags, flags);
263263
FOLIO_MATCH(lru, lru);
264+
FOLIO_MATCH(mapping, mapping);
264265
FOLIO_MATCH(compound_head, lru);
265266
FOLIO_MATCH(index, index);
266267
FOLIO_MATCH(private, private);

include/linux/psi.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ void psi_memstall_enter(unsigned long *flags);
2525
void psi_memstall_leave(unsigned long *flags);
2626

2727
int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
28-
29-
#ifdef CONFIG_CGROUPS
30-
int psi_cgroup_alloc(struct cgroup *cgrp);
31-
void psi_cgroup_free(struct cgroup *cgrp);
32-
void cgroup_move_task(struct task_struct *p, struct css_set *to);
33-
3428
struct psi_trigger *psi_trigger_create(struct psi_group *group,
3529
char *buf, size_t nbytes, enum psi_res res);
3630
void psi_trigger_destroy(struct psi_trigger *t);
3731

3832
__poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
3933
poll_table *wait);
34+
35+
#ifdef CONFIG_CGROUPS
36+
int psi_cgroup_alloc(struct cgroup *cgrp);
37+
void psi_cgroup_free(struct cgroup *cgrp);
38+
void cgroup_move_task(struct task_struct *p, struct css_set *to);
4039
#endif
4140

4241
#else /* CONFIG_PSI */

include/linux/sysctl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static inline struct ctl_table_header *register_sysctl_table(struct ctl_table *
265265
return NULL;
266266
}
267267

268-
static inline struct sysctl_header *register_sysctl_mount_point(const char *path)
268+
static inline struct ctl_table_header *register_sysctl_mount_point(const char *path)
269269
{
270270
return NULL;
271271
}

kernel/sched/psi.c

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,44 +1082,6 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res)
10821082
return 0;
10831083
}
10841084

1085-
static int psi_io_show(struct seq_file *m, void *v)
1086-
{
1087-
return psi_show(m, &psi_system, PSI_IO);
1088-
}
1089-
1090-
static int psi_memory_show(struct seq_file *m, void *v)
1091-
{
1092-
return psi_show(m, &psi_system, PSI_MEM);
1093-
}
1094-
1095-
static int psi_cpu_show(struct seq_file *m, void *v)
1096-
{
1097-
return psi_show(m, &psi_system, PSI_CPU);
1098-
}
1099-
1100-
static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *))
1101-
{
1102-
if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE))
1103-
return -EPERM;
1104-
1105-
return single_open(file, psi_show, NULL);
1106-
}
1107-
1108-
static int psi_io_open(struct inode *inode, struct file *file)
1109-
{
1110-
return psi_open(file, psi_io_show);
1111-
}
1112-
1113-
static int psi_memory_open(struct inode *inode, struct file *file)
1114-
{
1115-
return psi_open(file, psi_memory_show);
1116-
}
1117-
1118-
static int psi_cpu_open(struct inode *inode, struct file *file)
1119-
{
1120-
return psi_open(file, psi_cpu_show);
1121-
}
1122-
11231085
struct psi_trigger *psi_trigger_create(struct psi_group *group,
11241086
char *buf, size_t nbytes, enum psi_res res)
11251087
{
@@ -1278,6 +1240,45 @@ __poll_t psi_trigger_poll(void **trigger_ptr,
12781240
return ret;
12791241
}
12801242

1243+
#ifdef CONFIG_PROC_FS
1244+
static int psi_io_show(struct seq_file *m, void *v)
1245+
{
1246+
return psi_show(m, &psi_system, PSI_IO);
1247+
}
1248+
1249+
static int psi_memory_show(struct seq_file *m, void *v)
1250+
{
1251+
return psi_show(m, &psi_system, PSI_MEM);
1252+
}
1253+
1254+
static int psi_cpu_show(struct seq_file *m, void *v)
1255+
{
1256+
return psi_show(m, &psi_system, PSI_CPU);
1257+
}
1258+
1259+
static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *))
1260+
{
1261+
if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE))
1262+
return -EPERM;
1263+
1264+
return single_open(file, psi_show, NULL);
1265+
}
1266+
1267+
static int psi_io_open(struct inode *inode, struct file *file)
1268+
{
1269+
return psi_open(file, psi_io_show);
1270+
}
1271+
1272+
static int psi_memory_open(struct inode *inode, struct file *file)
1273+
{
1274+
return psi_open(file, psi_memory_show);
1275+
}
1276+
1277+
static int psi_cpu_open(struct inode *inode, struct file *file)
1278+
{
1279+
return psi_open(file, psi_cpu_show);
1280+
}
1281+
12811282
static ssize_t psi_write(struct file *file, const char __user *user_buf,
12821283
size_t nbytes, enum psi_res res)
12831284
{
@@ -1392,3 +1393,5 @@ static int __init psi_proc_init(void)
13921393
return 0;
13931394
}
13941395
module_init(psi_proc_init);
1396+
1397+
#endif /* CONFIG_PROC_FS */

lib/test_kasan.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ static void kmalloc_oob_in_memset(struct kunit *test)
492492
ptr = kmalloc(size, GFP_KERNEL);
493493
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
494494

495+
OPTIMIZER_HIDE_VAR(ptr);
495496
OPTIMIZER_HIDE_VAR(size);
496497
KUNIT_EXPECT_KASAN_FAIL(test,
497498
memset(ptr, 0, size + KASAN_GRANULE_SIZE));
@@ -515,6 +516,7 @@ static void kmalloc_memmove_negative_size(struct kunit *test)
515516
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
516517

517518
memset((char *)ptr, 0, 64);
519+
OPTIMIZER_HIDE_VAR(ptr);
518520
OPTIMIZER_HIDE_VAR(invalid_size);
519521
KUNIT_EXPECT_KASAN_FAIL(test,
520522
memmove((char *)ptr, (char *)ptr + 4, invalid_size));
@@ -531,6 +533,7 @@ static void kmalloc_memmove_invalid_size(struct kunit *test)
531533
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
532534

533535
memset((char *)ptr, 0, 64);
536+
OPTIMIZER_HIDE_VAR(ptr);
534537
KUNIT_EXPECT_KASAN_FAIL(test,
535538
memmove((char *)ptr, (char *)ptr + 4, invalid_size));
536539
kfree(ptr);
@@ -893,6 +896,7 @@ static void kasan_memchr(struct kunit *test)
893896
ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
894897
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
895898

899+
OPTIMIZER_HIDE_VAR(ptr);
896900
OPTIMIZER_HIDE_VAR(size);
897901
KUNIT_EXPECT_KASAN_FAIL(test,
898902
kasan_ptr_result = memchr(ptr, '1', size + 1));
@@ -919,6 +923,7 @@ static void kasan_memcmp(struct kunit *test)
919923
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
920924
memset(arr, 0, sizeof(arr));
921925

926+
OPTIMIZER_HIDE_VAR(ptr);
922927
OPTIMIZER_HIDE_VAR(size);
923928
KUNIT_EXPECT_KASAN_FAIL(test,
924929
kasan_int_result = memcmp(ptr, arr, size+1));

mm/memory-failure.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags,
15951595
goto out;
15961596
}
15971597

1598+
/*
1599+
* Pages instantiated by device-dax (not filesystem-dax)
1600+
* may be compound pages.
1601+
*/
1602+
page = compound_head(page);
1603+
15981604
/*
15991605
* Prevent the inode from being freed while we are interrogating
16001606
* the address_space, typically this would be handled by

tools/testing/scatterlist/linux/mm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static inline unsigned long page_to_phys(struct page *page)
7474
__UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \
7575
x, y)
7676

77-
#define preemptible() (1)
77+
#define pagefault_disabled() (0)
7878

7979
static inline void *kmap(struct page *page)
8080
{
@@ -127,6 +127,7 @@ kmalloc_array(unsigned int n, unsigned int size, unsigned int flags)
127127
#define kmemleak_free(a)
128128

129129
#define PageSlab(p) (0)
130+
#define flush_dcache_page(p)
130131

131132
#define MAX_ERRNO 4095
132133

0 commit comments

Comments
 (0)