Skip to content

Commit

Permalink
Merge branch 'akpm' (patches from Andrew)
Browse files Browse the repository at this point in the history
Merge more updates from Andrew Morton:
 "Various misc subsystems, before getting into the post-linux-next
  material.

  41 patches.

  Subsystems affected by this patch series: procfs, misc, core-kernel,
  lib, checkpatch, init, pipe, minix, fat, cgroups, kexec, kdump,
  taskstats, panic, kcov, resource, and ubsan"

* emailed patches from Andrew Morton <[email protected]>: (41 commits)
  Revert "ubsan, kcsan: Don't combine sanitizer with kcov on clang"
  kernel/resource: fix kfree() of bootmem memory again
  kcov: properly handle subsequent mmap calls
  kcov: split ioctl handling into locked and unlocked parts
  panic: move panic_print before kmsg dumpers
  panic: add option to dump all CPUs backtraces in panic_print
  docs: sysctl/kernel: add missing bit to panic_print
  taskstats: remove unneeded dead assignment
  kasan: no need to unset panic_on_warn in end_report()
  ubsan: no need to unset panic_on_warn in ubsan_epilogue()
  panic: unset panic_on_warn inside panic()
  docs: kdump: add scp example to write out the dump file
  docs: kdump: update description about sysfs file system support
  arm64: mm: use IS_ENABLED(CONFIG_KEXEC_CORE) instead of #ifdef
  x86/setup: use IS_ENABLED(CONFIG_KEXEC_CORE) instead of #ifdef
  riscv: mm: init: use IS_ENABLED(CONFIG_KEXEC_CORE) instead of #ifdef
  kexec: make crashk_res, crashk_low_res and crash_notes symbols always visible
  cgroup: use irqsave in cgroup_rstat_flush_locked().
  fat: use pointer to simple type in put_user()
  minix: fix bug when opening a file with O_DIRECT
  ...
  • Loading branch information
torvalds committed Mar 24, 2022
2 parents 169e777 + b027471 commit 52deda9
Show file tree
Hide file tree
Showing 34 changed files with 311 additions and 303 deletions.
10 changes: 7 additions & 3 deletions Documentation/admin-guide/kdump/kdump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ System kernel config options
CONFIG_SYSFS=y

Note that "sysfs file system support" might not appear in the "Pseudo
filesystems" menu if "Configure standard kernel features (for small
systems)" is not enabled in "General Setup." In this case, check the
.config file itself to ensure that sysfs is turned on, as follows::
filesystems" menu if "Configure standard kernel features (expert users)"
is not enabled in "General Setup." In this case, check the .config file
itself to ensure that sysfs is turned on, as follows::

grep 'CONFIG_SYSFS' .config

Expand Down Expand Up @@ -533,6 +533,10 @@ the following command::

cp /proc/vmcore <dump-file>

or use scp to write out the dump file between hosts on a network, e.g::

scp /proc/vmcore remote_username@remote_ip:<dump-file>

You can also use makedumpfile utility to write out the dump file
with specified options to filter out unwanted contents, e.g::

Expand Down
5 changes: 5 additions & 0 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3792,6 +3792,11 @@
bit 3: print locks info if CONFIG_LOCKDEP is on
bit 4: print ftrace buffer
bit 5: print all printk messages in buffer
bit 6: print all CPUs backtrace (if available in the arch)
*Be aware* that this option may print a _lot_ of lines,
so there are risks of losing older messages in the log.
Use this option carefully, maybe worth to setup a
bigger log buffer with "log_buf_len" along with this.

panic_on_taint= Bitmask for conditionally calling panic() in add_taint()
Format: <hex>[,nousertaint]
Expand Down
2 changes: 2 additions & 0 deletions Documentation/admin-guide/sysctl/kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,8 @@ bit 1 print system memory info
bit 2 print timer info
bit 3 print locks info if ``CONFIG_LOCKDEP`` is on
bit 4 print ftrace buffer
bit 5 print all printk messages in buffer
bit 6 print all CPUs backtrace (if available in the arch)
===== ============================================

So for example to print tasks and memory info on panic, user can::
Expand Down
2 changes: 2 additions & 0 deletions Documentation/dev-tools/sparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ have already built it.

The optional make variable CF can be used to pass arguments to sparse. The
build system passes -Wbitwise to sparse automatically.

Note that sparse defines the __CHECKER__ preprocessor symbol.
9 changes: 3 additions & 6 deletions arch/arm64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ phys_addr_t __ro_after_init arm64_dma_phys_limit;
phys_addr_t __ro_after_init arm64_dma_phys_limit = PHYS_MASK + 1;
#endif

#ifdef CONFIG_KEXEC_CORE
/*
* reserve_crashkernel() - reserves memory for crash kernel
*
Expand All @@ -104,6 +103,9 @@ static void __init reserve_crashkernel(void)
unsigned long long crash_max = arm64_dma_phys_limit;
int ret;

if (!IS_ENABLED(CONFIG_KEXEC_CORE))
return;

ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
&crash_size, &crash_base);
/* no crashkernel= or invalid value specified */
Expand Down Expand Up @@ -136,11 +138,6 @@ static void __init reserve_crashkernel(void)
crashk_res.start = crash_base;
crashk_res.end = crash_base + crash_size - 1;
}
#else
static void __init reserve_crashkernel(void)
{
}
#endif /* CONFIG_KEXEC_CORE */

/*
* Return the maximum physical address for a zone accessible by the given bits
Expand Down
6 changes: 2 additions & 4 deletions arch/riscv/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,6 @@ static inline void setup_vm_final(void)
}
#endif /* CONFIG_MMU */

#ifdef CONFIG_KEXEC_CORE
/*
* reserve_crashkernel() - reserves memory for crash kernel
*
Expand All @@ -974,6 +973,8 @@ static void __init reserve_crashkernel(void)

int ret = 0;

if (!IS_ENABLED(CONFIG_KEXEC_CORE))
return;
/*
* Don't reserve a region for a crash kernel on a crash kernel
* since it doesn't make much sense and we have limited memory
Expand Down Expand Up @@ -1023,7 +1024,6 @@ static void __init reserve_crashkernel(void)
crashk_res.start = crash_base;
crashk_res.end = crash_base + crash_size - 1;
}
#endif /* CONFIG_KEXEC_CORE */

void __init paging_init(void)
{
Expand All @@ -1037,9 +1037,7 @@ void __init misc_mem_init(void)
arch_numa_init();
sparse_init();
zone_sizes_init();
#ifdef CONFIG_KEXEC_CORE
reserve_crashkernel();
#endif
memblock_dump_all();
}

Expand Down
10 changes: 3 additions & 7 deletions arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,6 @@ static void __init memblock_x86_reserve_range_setup_data(void)
* --------- Crashkernel reservation ------------------------------
*/

#ifdef CONFIG_KEXEC_CORE

/* 16M alignment for crash kernel regions */
#define CRASH_ALIGN SZ_16M

Expand Down Expand Up @@ -490,6 +488,9 @@ static void __init reserve_crashkernel(void)
bool high = false;
int ret;

if (!IS_ENABLED(CONFIG_KEXEC_CORE))
return;

total_mem = memblock_phys_mem_size();

/* crashkernel=XM */
Expand Down Expand Up @@ -555,11 +556,6 @@ static void __init reserve_crashkernel(void)
crashk_res.end = crash_base + crash_size - 1;
insert_resource(&iomem_resource, &crashk_res);
}
#else
static void __init reserve_crashkernel(void)
{
}
#endif

static struct resource standard_io_resources[] = {
{ .name = "dma1", .start = 0x00, .end = 0x1f,
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ static int func(struct dir_context *ctx, const char *name, int name_len, \
if (name_len >= sizeof(d1->d_name)) \
name_len = sizeof(d1->d_name) - 1; \
\
if (put_user(0, d2->d_name) || \
if (put_user(0, &d2->d_name[0]) || \
put_user(0, &d2->d_reclen) || \
copy_to_user(d1->d_name, name, name_len) || \
put_user(0, d1->d_name + name_len) || \
Expand Down
3 changes: 2 additions & 1 deletion fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ static const struct address_space_operations minix_aops = {
.writepage = minix_writepage,
.write_begin = minix_write_begin,
.write_end = generic_write_end,
.bmap = minix_bmap
.bmap = minix_bmap,
.direct_IO = noop_direct_IO
};

static const struct inode_operations minix_symlink_inode_operations = {
Expand Down
13 changes: 6 additions & 7 deletions fs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct pipe_inode_info *pipe = filp->private_data;
int count, head, tail, mask;
unsigned int count, head, tail, mask;

switch (cmd) {
case FIONREAD:
Expand Down Expand Up @@ -804,7 +804,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
if (too_many_pipe_buffers_hard(user_bufs) && pipe_is_unprivileged_user())
goto out_revert_acct;

pipe->bufs = kcalloc(pipe_bufs, sizeof(struct pipe_buffer),
pipe->bufs = kvcalloc(pipe_bufs, sizeof(struct pipe_buffer),
GFP_KERNEL_ACCOUNT);

if (pipe->bufs) {
Expand All @@ -829,7 +829,7 @@ struct pipe_inode_info *alloc_pipe_info(void)

void free_pipe_info(struct pipe_inode_info *pipe)
{
int i;
unsigned int i;

#ifdef CONFIG_WATCH_QUEUE
if (pipe->watch_queue)
Expand All @@ -849,7 +849,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
#endif
if (pipe->tmp_page)
__free_page(pipe->tmp_page);
kfree(pipe->bufs);
kvfree(pipe->bufs);
kfree(pipe);
}

Expand Down Expand Up @@ -1264,8 +1264,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
if (nr_slots < n)
return -EBUSY;

bufs = kcalloc(nr_slots, sizeof(*bufs),
GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
bufs = kvcalloc(nr_slots, sizeof(*bufs), GFP_KERNEL_ACCOUNT);
if (unlikely(!bufs))
return -ENOMEM;

Expand All @@ -1292,7 +1291,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
head = n;
tail = 0;

kfree(pipe->bufs);
kvfree(pipe->bufs);
pipe->bufs = bufs;
pipe->ring_size = nr_slots;
if (pipe->max_usage > nr_slots)
Expand Down
8 changes: 4 additions & 4 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1764,25 +1764,25 @@ static const char *proc_pid_get_link(struct dentry *dentry,

static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
{
char *tmp = (char *)__get_free_page(GFP_KERNEL);
char *tmp = kmalloc(PATH_MAX, GFP_KERNEL);
char *pathname;
int len;

if (!tmp)
return -ENOMEM;

pathname = d_path(path, tmp, PAGE_SIZE);
pathname = d_path(path, tmp, PATH_MAX);
len = PTR_ERR(pathname);
if (IS_ERR(pathname))
goto out;
len = tmp + PAGE_SIZE - 1 - pathname;
len = tmp + PATH_MAX - 1 - pathname;

if (len > buflen)
len = buflen;
if (copy_to_user(buffer, pathname, len))
len = -EFAULT;
out:
free_page((unsigned long)tmp);
kfree(tmp);
return len;
}

Expand Down
43 changes: 23 additions & 20 deletions fs/proc/vmcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,39 +62,42 @@ core_param(novmcoredd, vmcoredd_disabled, bool, 0);
/* Device Dump Size */
static size_t vmcoredd_orig_sz;

static DECLARE_RWSEM(vmcore_cb_rwsem);
static DEFINE_SPINLOCK(vmcore_cb_lock);
DEFINE_STATIC_SRCU(vmcore_cb_srcu);
/* List of registered vmcore callbacks. */
static LIST_HEAD(vmcore_cb_list);
/* Whether the vmcore has been opened once. */
static bool vmcore_opened;

void register_vmcore_cb(struct vmcore_cb *cb)
{
down_write(&vmcore_cb_rwsem);
INIT_LIST_HEAD(&cb->next);
spin_lock(&vmcore_cb_lock);
list_add_tail(&cb->next, &vmcore_cb_list);
/*
* Registering a vmcore callback after the vmcore was opened is
* very unusual (e.g., manual driver loading).
*/
if (vmcore_opened)
pr_warn_once("Unexpected vmcore callback registration\n");
up_write(&vmcore_cb_rwsem);
spin_unlock(&vmcore_cb_lock);
}
EXPORT_SYMBOL_GPL(register_vmcore_cb);

void unregister_vmcore_cb(struct vmcore_cb *cb)
{
down_write(&vmcore_cb_rwsem);
list_del(&cb->next);
spin_lock(&vmcore_cb_lock);
list_del_rcu(&cb->next);
/*
* Unregistering a vmcore callback after the vmcore was opened is
* very unusual (e.g., forced driver removal), but we cannot stop
* unregistering.
*/
if (vmcore_opened)
pr_warn_once("Unexpected vmcore callback unregistration\n");
up_write(&vmcore_cb_rwsem);
spin_unlock(&vmcore_cb_lock);

synchronize_srcu(&vmcore_cb_srcu);
}
EXPORT_SYMBOL_GPL(unregister_vmcore_cb);

Expand All @@ -103,9 +106,8 @@ static bool pfn_is_ram(unsigned long pfn)
struct vmcore_cb *cb;
bool ret = true;

lockdep_assert_held_read(&vmcore_cb_rwsem);

list_for_each_entry(cb, &vmcore_cb_list, next) {
list_for_each_entry_srcu(cb, &vmcore_cb_list, next,
srcu_read_lock_held(&vmcore_cb_srcu)) {
if (unlikely(!cb->pfn_is_ram))
continue;
ret = cb->pfn_is_ram(cb, pfn);
Expand All @@ -118,9 +120,9 @@ static bool pfn_is_ram(unsigned long pfn)

static int open_vmcore(struct inode *inode, struct file *file)
{
down_read(&vmcore_cb_rwsem);
spin_lock(&vmcore_cb_lock);
vmcore_opened = true;
up_read(&vmcore_cb_rwsem);
spin_unlock(&vmcore_cb_lock);

return 0;
}
Expand All @@ -133,14 +135,15 @@ ssize_t read_from_oldmem(char *buf, size_t count,
unsigned long pfn, offset;
size_t nr_bytes;
ssize_t read = 0, tmp;
int idx;

if (!count)
return 0;

offset = (unsigned long)(*ppos % PAGE_SIZE);
pfn = (unsigned long)(*ppos / PAGE_SIZE);

down_read(&vmcore_cb_rwsem);
idx = srcu_read_lock(&vmcore_cb_srcu);
do {
if (count > (PAGE_SIZE - offset))
nr_bytes = PAGE_SIZE - offset;
Expand All @@ -165,7 +168,7 @@ ssize_t read_from_oldmem(char *buf, size_t count,
offset, userbuf);
}
if (tmp < 0) {
up_read(&vmcore_cb_rwsem);
srcu_read_unlock(&vmcore_cb_srcu, idx);
return tmp;
}

Expand All @@ -176,8 +179,8 @@ ssize_t read_from_oldmem(char *buf, size_t count,
++pfn;
offset = 0;
} while (count);
srcu_read_unlock(&vmcore_cb_srcu, idx);

up_read(&vmcore_cb_rwsem);
return read;
}

Expand Down Expand Up @@ -477,7 +480,7 @@ static const struct vm_operations_struct vmcore_mmap_ops = {

/**
* vmcore_alloc_buf - allocate buffer in vmalloc memory
* @sizez: size of buffer
* @size: size of buffer
*
* If CONFIG_MMU is defined, use vmalloc_user() to allow users to mmap
* the buffer to user-space by means of remap_vmalloc_range().
Expand Down Expand Up @@ -568,18 +571,18 @@ static int vmcore_remap_oldmem_pfn(struct vm_area_struct *vma,
unsigned long from, unsigned long pfn,
unsigned long size, pgprot_t prot)
{
int ret;
int ret, idx;

/*
* Check if oldmem_pfn_is_ram was registered to avoid
* looping over all pages without a reason.
* Check if a callback was registered to avoid looping over all
* pages without a reason.
*/
down_read(&vmcore_cb_rwsem);
idx = srcu_read_lock(&vmcore_cb_srcu);
if (!list_empty(&vmcore_cb_list))
ret = remap_oldmem_pfn_checked(vma, from, pfn, size, prot);
else
ret = remap_oldmem_pfn_range(vma, from, pfn, size, prot);
up_read(&vmcore_cb_rwsem);
srcu_read_unlock(&vmcore_cb_srcu, idx);
return ret;
}

Expand Down
Loading

0 comments on commit 52deda9

Please sign in to comment.