Commit 8dd71685 authored by Linus Torvalds's avatar Linus Torvalds

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 <akpm@linux-foundation.org>:
  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
parents f8c7e4ed ddf4b773
...@@ -318,7 +318,7 @@ config ARCH_PROC_KCORE_TEXT ...@@ -318,7 +318,7 @@ config ARCH_PROC_KCORE_TEXT
depends on PROC_KCORE depends on PROC_KCORE
config IA64_MCA_RECOVERY config IA64_MCA_RECOVERY
tristate "MCA recovery from errors other than TLB." bool "MCA recovery from errors other than TLB."
config IA64_PALINFO config IA64_PALINFO
tristate "/proc/pal support" tristate "/proc/pal support"
......
...@@ -817,20 +817,20 @@ static struct file_system_type bm_fs_type = { ...@@ -817,20 +817,20 @@ static struct file_system_type bm_fs_type = {
}; };
MODULE_ALIAS_FS("binfmt_misc"); MODULE_ALIAS_FS("binfmt_misc");
static struct ctl_table_header *binfmt_misc_header;
static int __init init_misc_binfmt(void) static int __init init_misc_binfmt(void)
{ {
int err = register_filesystem(&bm_fs_type); int err = register_filesystem(&bm_fs_type);
if (!err) if (!err)
insert_binfmt(&misc_format); insert_binfmt(&misc_format);
if (!register_sysctl_mount_point("fs/binfmt_misc")) { binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");
pr_warn("Failed to create fs/binfmt_misc sysctl mount point");
return -ENOMEM;
}
return 0; return 0;
} }
static void __exit exit_misc_binfmt(void) static void __exit exit_misc_binfmt(void)
{ {
unregister_sysctl_table(binfmt_misc_header);
unregister_binfmt(&misc_format); unregister_binfmt(&misc_format);
unregister_filesystem(&bm_fs_type); unregister_filesystem(&bm_fs_type);
} }
......
...@@ -2972,6 +2972,7 @@ struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh) ...@@ -2972,6 +2972,7 @@ struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh)
jbd_unlock_bh_journal_head(bh); jbd_unlock_bh_journal_head(bh);
return jh; return jh;
} }
EXPORT_SYMBOL(jbd2_journal_grab_journal_head);
static void __journal_remove_journal_head(struct buffer_head *bh) static void __journal_remove_journal_head(struct buffer_head *bh)
{ {
...@@ -3024,6 +3025,7 @@ void jbd2_journal_put_journal_head(struct journal_head *jh) ...@@ -3024,6 +3025,7 @@ void jbd2_journal_put_journal_head(struct journal_head *jh)
jbd_unlock_bh_journal_head(bh); jbd_unlock_bh_journal_head(bh);
} }
} }
EXPORT_SYMBOL(jbd2_journal_put_journal_head);
/* /*
* Initialize jbd inode head * Initialize jbd inode head
......
...@@ -1251,17 +1251,15 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, ...@@ -1251,17 +1251,15 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
{ {
struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
struct journal_head *jh; struct journal_head *jh;
int ret = 1; int ret;
if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap)) if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
return 0; return 0;
if (!buffer_jbd(bg_bh)) jh = jbd2_journal_grab_journal_head(bg_bh);
if (!jh)
return 1; return 1;
jbd_lock_bh_journal_head(bg_bh);
if (buffer_jbd(bg_bh)) {
jh = bh2jh(bg_bh);
spin_lock(&jh->b_state_lock); spin_lock(&jh->b_state_lock);
bg = (struct ocfs2_group_desc *) jh->b_committed_data; bg = (struct ocfs2_group_desc *) jh->b_committed_data;
if (bg) if (bg)
...@@ -1269,8 +1267,7 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, ...@@ -1269,8 +1267,7 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
else else
ret = 1; ret = 1;
spin_unlock(&jh->b_state_lock); spin_unlock(&jh->b_state_lock);
} jbd2_journal_put_journal_head(jh);
jbd_unlock_bh_journal_head(bg_bh);
return ret; return ret;
} }
......
...@@ -1506,11 +1506,18 @@ static inline u8 page_kasan_tag(const struct page *page) ...@@ -1506,11 +1506,18 @@ static inline u8 page_kasan_tag(const struct page *page)
static inline void page_kasan_tag_set(struct page *page, u8 tag) static inline void page_kasan_tag_set(struct page *page, u8 tag)
{ {
if (kasan_enabled()) { unsigned long old_flags, flags;
if (!kasan_enabled())
return;
tag ^= 0xff; tag ^= 0xff;
page->flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); old_flags = READ_ONCE(page->flags);
page->flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; do {
} flags = old_flags;
flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT);
flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT;
} while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags)));
} }
static inline void page_kasan_tag_reset(struct page *page) static inline void page_kasan_tag_reset(struct page *page)
......
...@@ -261,6 +261,7 @@ static_assert(sizeof(struct page) == sizeof(struct folio)); ...@@ -261,6 +261,7 @@ static_assert(sizeof(struct page) == sizeof(struct folio));
static_assert(offsetof(struct page, pg) == offsetof(struct folio, fl)) static_assert(offsetof(struct page, pg) == offsetof(struct folio, fl))
FOLIO_MATCH(flags, flags); FOLIO_MATCH(flags, flags);
FOLIO_MATCH(lru, lru); FOLIO_MATCH(lru, lru);
FOLIO_MATCH(mapping, mapping);
FOLIO_MATCH(compound_head, lru); FOLIO_MATCH(compound_head, lru);
FOLIO_MATCH(index, index); FOLIO_MATCH(index, index);
FOLIO_MATCH(private, private); FOLIO_MATCH(private, private);
......
...@@ -25,18 +25,17 @@ void psi_memstall_enter(unsigned long *flags); ...@@ -25,18 +25,17 @@ void psi_memstall_enter(unsigned long *flags);
void psi_memstall_leave(unsigned long *flags); void psi_memstall_leave(unsigned long *flags);
int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res); int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
#ifdef CONFIG_CGROUPS
int psi_cgroup_alloc(struct cgroup *cgrp);
void psi_cgroup_free(struct cgroup *cgrp);
void cgroup_move_task(struct task_struct *p, struct css_set *to);
struct psi_trigger *psi_trigger_create(struct psi_group *group, struct psi_trigger *psi_trigger_create(struct psi_group *group,
char *buf, size_t nbytes, enum psi_res res); char *buf, size_t nbytes, enum psi_res res);
void psi_trigger_destroy(struct psi_trigger *t); void psi_trigger_destroy(struct psi_trigger *t);
__poll_t psi_trigger_poll(void **trigger_ptr, struct file *file, __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
poll_table *wait); poll_table *wait);
#ifdef CONFIG_CGROUPS
int psi_cgroup_alloc(struct cgroup *cgrp);
void psi_cgroup_free(struct cgroup *cgrp);
void cgroup_move_task(struct task_struct *p, struct css_set *to);
#endif #endif
#else /* CONFIG_PSI */ #else /* CONFIG_PSI */
......
...@@ -265,7 +265,7 @@ static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * ...@@ -265,7 +265,7 @@ static inline struct ctl_table_header *register_sysctl_table(struct ctl_table *
return NULL; return NULL;
} }
static inline struct sysctl_header *register_sysctl_mount_point(const char *path) static inline struct ctl_table_header *register_sysctl_mount_point(const char *path)
{ {
return NULL; return NULL;
} }
......
...@@ -1082,44 +1082,6 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res) ...@@ -1082,44 +1082,6 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res)
return 0; return 0;
} }
static int psi_io_show(struct seq_file *m, void *v)
{
return psi_show(m, &psi_system, PSI_IO);
}
static int psi_memory_show(struct seq_file *m, void *v)
{
return psi_show(m, &psi_system, PSI_MEM);
}
static int psi_cpu_show(struct seq_file *m, void *v)
{
return psi_show(m, &psi_system, PSI_CPU);
}
static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *))
{
if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE))
return -EPERM;
return single_open(file, psi_show, NULL);
}
static int psi_io_open(struct inode *inode, struct file *file)
{
return psi_open(file, psi_io_show);
}
static int psi_memory_open(struct inode *inode, struct file *file)
{
return psi_open(file, psi_memory_show);
}
static int psi_cpu_open(struct inode *inode, struct file *file)
{
return psi_open(file, psi_cpu_show);
}
struct psi_trigger *psi_trigger_create(struct psi_group *group, struct psi_trigger *psi_trigger_create(struct psi_group *group,
char *buf, size_t nbytes, enum psi_res res) char *buf, size_t nbytes, enum psi_res res)
{ {
...@@ -1278,6 +1240,45 @@ __poll_t psi_trigger_poll(void **trigger_ptr, ...@@ -1278,6 +1240,45 @@ __poll_t psi_trigger_poll(void **trigger_ptr,
return ret; return ret;
} }
#ifdef CONFIG_PROC_FS
static int psi_io_show(struct seq_file *m, void *v)
{
return psi_show(m, &psi_system, PSI_IO);
}
static int psi_memory_show(struct seq_file *m, void *v)
{
return psi_show(m, &psi_system, PSI_MEM);
}
static int psi_cpu_show(struct seq_file *m, void *v)
{
return psi_show(m, &psi_system, PSI_CPU);
}
static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *))
{
if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE))
return -EPERM;
return single_open(file, psi_show, NULL);
}
static int psi_io_open(struct inode *inode, struct file *file)
{
return psi_open(file, psi_io_show);
}
static int psi_memory_open(struct inode *inode, struct file *file)
{
return psi_open(file, psi_memory_show);
}
static int psi_cpu_open(struct inode *inode, struct file *file)
{
return psi_open(file, psi_cpu_show);
}
static ssize_t psi_write(struct file *file, const char __user *user_buf, static ssize_t psi_write(struct file *file, const char __user *user_buf,
size_t nbytes, enum psi_res res) size_t nbytes, enum psi_res res)
{ {
...@@ -1392,3 +1393,5 @@ static int __init psi_proc_init(void) ...@@ -1392,3 +1393,5 @@ static int __init psi_proc_init(void)
return 0; return 0;
} }
module_init(psi_proc_init); module_init(psi_proc_init);
#endif /* CONFIG_PROC_FS */
...@@ -492,6 +492,7 @@ static void kmalloc_oob_in_memset(struct kunit *test) ...@@ -492,6 +492,7 @@ static void kmalloc_oob_in_memset(struct kunit *test)
ptr = kmalloc(size, GFP_KERNEL); ptr = kmalloc(size, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
OPTIMIZER_HIDE_VAR(ptr);
OPTIMIZER_HIDE_VAR(size); OPTIMIZER_HIDE_VAR(size);
KUNIT_EXPECT_KASAN_FAIL(test, KUNIT_EXPECT_KASAN_FAIL(test,
memset(ptr, 0, size + KASAN_GRANULE_SIZE)); memset(ptr, 0, size + KASAN_GRANULE_SIZE));
...@@ -515,6 +516,7 @@ static void kmalloc_memmove_negative_size(struct kunit *test) ...@@ -515,6 +516,7 @@ static void kmalloc_memmove_negative_size(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
memset((char *)ptr, 0, 64); memset((char *)ptr, 0, 64);
OPTIMIZER_HIDE_VAR(ptr);
OPTIMIZER_HIDE_VAR(invalid_size); OPTIMIZER_HIDE_VAR(invalid_size);
KUNIT_EXPECT_KASAN_FAIL(test, KUNIT_EXPECT_KASAN_FAIL(test,
memmove((char *)ptr, (char *)ptr + 4, invalid_size)); memmove((char *)ptr, (char *)ptr + 4, invalid_size));
...@@ -531,6 +533,7 @@ static void kmalloc_memmove_invalid_size(struct kunit *test) ...@@ -531,6 +533,7 @@ static void kmalloc_memmove_invalid_size(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
memset((char *)ptr, 0, 64); memset((char *)ptr, 0, 64);
OPTIMIZER_HIDE_VAR(ptr);
KUNIT_EXPECT_KASAN_FAIL(test, KUNIT_EXPECT_KASAN_FAIL(test,
memmove((char *)ptr, (char *)ptr + 4, invalid_size)); memmove((char *)ptr, (char *)ptr + 4, invalid_size));
kfree(ptr); kfree(ptr);
...@@ -893,6 +896,7 @@ static void kasan_memchr(struct kunit *test) ...@@ -893,6 +896,7 @@ static void kasan_memchr(struct kunit *test)
ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
OPTIMIZER_HIDE_VAR(ptr);
OPTIMIZER_HIDE_VAR(size); OPTIMIZER_HIDE_VAR(size);
KUNIT_EXPECT_KASAN_FAIL(test, KUNIT_EXPECT_KASAN_FAIL(test,
kasan_ptr_result = memchr(ptr, '1', size + 1)); kasan_ptr_result = memchr(ptr, '1', size + 1));
...@@ -919,6 +923,7 @@ static void kasan_memcmp(struct kunit *test) ...@@ -919,6 +923,7 @@ static void kasan_memcmp(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
memset(arr, 0, sizeof(arr)); memset(arr, 0, sizeof(arr));
OPTIMIZER_HIDE_VAR(ptr);
OPTIMIZER_HIDE_VAR(size); OPTIMIZER_HIDE_VAR(size);
KUNIT_EXPECT_KASAN_FAIL(test, KUNIT_EXPECT_KASAN_FAIL(test,
kasan_int_result = memcmp(ptr, arr, size+1)); kasan_int_result = memcmp(ptr, arr, size+1));
......
...@@ -1595,6 +1595,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, ...@@ -1595,6 +1595,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags,
goto out; goto out;
} }
/*
* Pages instantiated by device-dax (not filesystem-dax)
* may be compound pages.
*/
page = compound_head(page);
/* /*
* Prevent the inode from being freed while we are interrogating * Prevent the inode from being freed while we are interrogating
* the address_space, typically this would be handled by * the address_space, typically this would be handled by
......
...@@ -74,7 +74,7 @@ static inline unsigned long page_to_phys(struct page *page) ...@@ -74,7 +74,7 @@ static inline unsigned long page_to_phys(struct page *page)
__UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \
x, y) x, y)
#define preemptible() (1) #define pagefault_disabled() (0)
static inline void *kmap(struct page *page) static inline void *kmap(struct page *page)
{ {
...@@ -127,6 +127,7 @@ kmalloc_array(unsigned int n, unsigned int size, unsigned int flags) ...@@ -127,6 +127,7 @@ kmalloc_array(unsigned int n, unsigned int size, unsigned int flags)
#define kmemleak_free(a) #define kmemleak_free(a)
#define PageSlab(p) (0) #define PageSlab(p) (0)
#define flush_dcache_page(p)
#define MAX_ERRNO 4095 #define MAX_ERRNO 4095
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment