Skip to content

Commit 52deda9

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
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 ...
2 parents 169e777 + b027471 commit 52deda9

File tree

34 files changed

+311
-303
lines changed

34 files changed

+311
-303
lines changed

Documentation/admin-guide/kdump/kdump.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ System kernel config options
146146
CONFIG_SYSFS=y
147147

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

153153
grep 'CONFIG_SYSFS' .config
154154

@@ -533,6 +533,10 @@ the following command::
533533

534534
cp /proc/vmcore <dump-file>
535535

536+
or use scp to write out the dump file between hosts on a network, e.g::
537+
538+
scp /proc/vmcore remote_username@remote_ip:<dump-file>
539+
536540
You can also use makedumpfile utility to write out the dump file
537541
with specified options to filter out unwanted contents, e.g::
538542

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3792,6 +3792,11 @@
37923792
bit 3: print locks info if CONFIG_LOCKDEP is on
37933793
bit 4: print ftrace buffer
37943794
bit 5: print all printk messages in buffer
3795+
bit 6: print all CPUs backtrace (if available in the arch)
3796+
*Be aware* that this option may print a _lot_ of lines,
3797+
so there are risks of losing older messages in the log.
3798+
Use this option carefully, maybe worth to setup a
3799+
bigger log buffer with "log_buf_len" along with this.
37953800

37963801
panic_on_taint= Bitmask for conditionally calling panic() in add_taint()
37973802
Format: <hex>[,nousertaint]

Documentation/admin-guide/sysctl/kernel.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ bit 1 print system memory info
763763
bit 2 print timer info
764764
bit 3 print locks info if ``CONFIG_LOCKDEP`` is on
765765
bit 4 print ftrace buffer
766+
bit 5 print all printk messages in buffer
767+
bit 6 print all CPUs backtrace (if available in the arch)
766768
===== ============================================
767769

768770
So for example to print tasks and memory info on panic, user can::

Documentation/dev-tools/sparse.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,5 @@ have already built it.
100100

101101
The optional make variable CF can be used to pass arguments to sparse. The
102102
build system passes -Wbitwise to sparse automatically.
103+
104+
Note that sparse defines the __CHECKER__ preprocessor symbol.

arch/arm64/mm/init.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ phys_addr_t __ro_after_init arm64_dma_phys_limit;
9090
phys_addr_t __ro_after_init arm64_dma_phys_limit = PHYS_MASK + 1;
9191
#endif
9292

93-
#ifdef CONFIG_KEXEC_CORE
9493
/*
9594
* reserve_crashkernel() - reserves memory for crash kernel
9695
*
@@ -104,6 +103,9 @@ static void __init reserve_crashkernel(void)
104103
unsigned long long crash_max = arm64_dma_phys_limit;
105104
int ret;
106105

106+
if (!IS_ENABLED(CONFIG_KEXEC_CORE))
107+
return;
108+
107109
ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
108110
&crash_size, &crash_base);
109111
/* no crashkernel= or invalid value specified */
@@ -136,11 +138,6 @@ static void __init reserve_crashkernel(void)
136138
crashk_res.start = crash_base;
137139
crashk_res.end = crash_base + crash_size - 1;
138140
}
139-
#else
140-
static void __init reserve_crashkernel(void)
141-
{
142-
}
143-
#endif /* CONFIG_KEXEC_CORE */
144141

145142
/*
146143
* Return the maximum physical address for a zone accessible by the given bits

arch/riscv/mm/init.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,6 @@ static inline void setup_vm_final(void)
957957
}
958958
#endif /* CONFIG_MMU */
959959

960-
#ifdef CONFIG_KEXEC_CORE
961960
/*
962961
* reserve_crashkernel() - reserves memory for crash kernel
963962
*
@@ -974,6 +973,8 @@ static void __init reserve_crashkernel(void)
974973

975974
int ret = 0;
976975

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

10281028
void __init paging_init(void)
10291029
{
@@ -1037,9 +1037,7 @@ void __init misc_mem_init(void)
10371037
arch_numa_init();
10381038
sparse_init();
10391039
zone_sizes_init();
1040-
#ifdef CONFIG_KEXEC_CORE
10411040
reserve_crashkernel();
1042-
#endif
10431041
memblock_dump_all();
10441042
}
10451043

arch/x86/kernel/setup.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ static void __init memblock_x86_reserve_range_setup_data(void)
411411
* --------- Crashkernel reservation ------------------------------
412412
*/
413413

414-
#ifdef CONFIG_KEXEC_CORE
415-
416414
/* 16M alignment for crash kernel regions */
417415
#define CRASH_ALIGN SZ_16M
418416

@@ -490,6 +488,9 @@ static void __init reserve_crashkernel(void)
490488
bool high = false;
491489
int ret;
492490

491+
if (!IS_ENABLED(CONFIG_KEXEC_CORE))
492+
return;
493+
493494
total_mem = memblock_phys_mem_size();
494495

495496
/* crashkernel=XM */
@@ -555,11 +556,6 @@ static void __init reserve_crashkernel(void)
555556
crashk_res.end = crash_base + crash_size - 1;
556557
insert_resource(&iomem_resource, &crashk_res);
557558
}
558-
#else
559-
static void __init reserve_crashkernel(void)
560-
{
561-
}
562-
#endif
563559

564560
static struct resource standard_io_resources[] = {
565561
{ .name = "dma1", .start = 0x00, .end = 0x1f,

fs/fat/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ static int func(struct dir_context *ctx, const char *name, int name_len, \
722722
if (name_len >= sizeof(d1->d_name)) \
723723
name_len = sizeof(d1->d_name) - 1; \
724724
\
725-
if (put_user(0, d2->d_name) || \
725+
if (put_user(0, &d2->d_name[0]) || \
726726
put_user(0, &d2->d_reclen) || \
727727
copy_to_user(d1->d_name, name, name_len) || \
728728
put_user(0, d1->d_name + name_len) || \

fs/minix/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ static const struct address_space_operations minix_aops = {
448448
.writepage = minix_writepage,
449449
.write_begin = minix_write_begin,
450450
.write_end = generic_write_end,
451-
.bmap = minix_bmap
451+
.bmap = minix_bmap,
452+
.direct_IO = noop_direct_IO
452453
};
453454

454455
static const struct inode_operations minix_symlink_inode_operations = {

fs/pipe.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
607607
static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
608608
{
609609
struct pipe_inode_info *pipe = filp->private_data;
610-
int count, head, tail, mask;
610+
unsigned int count, head, tail, mask;
611611

612612
switch (cmd) {
613613
case FIONREAD:
@@ -804,7 +804,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
804804
if (too_many_pipe_buffers_hard(user_bufs) && pipe_is_unprivileged_user())
805805
goto out_revert_acct;
806806

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

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

830830
void free_pipe_info(struct pipe_inode_info *pipe)
831831
{
832-
int i;
832+
unsigned int i;
833833

834834
#ifdef CONFIG_WATCH_QUEUE
835835
if (pipe->watch_queue)
@@ -849,7 +849,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
849849
#endif
850850
if (pipe->tmp_page)
851851
__free_page(pipe->tmp_page);
852-
kfree(pipe->bufs);
852+
kvfree(pipe->bufs);
853853
kfree(pipe);
854854
}
855855

@@ -1264,8 +1264,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
12641264
if (nr_slots < n)
12651265
return -EBUSY;
12661266

1267-
bufs = kcalloc(nr_slots, sizeof(*bufs),
1268-
GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
1267+
bufs = kvcalloc(nr_slots, sizeof(*bufs), GFP_KERNEL_ACCOUNT);
12691268
if (unlikely(!bufs))
12701269
return -ENOMEM;
12711270

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

1295-
kfree(pipe->bufs);
1294+
kvfree(pipe->bufs);
12961295
pipe->bufs = bufs;
12971296
pipe->ring_size = nr_slots;
12981297
if (pipe->max_usage > nr_slots)

fs/proc/base.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,25 +1764,25 @@ static const char *proc_pid_get_link(struct dentry *dentry,
17641764

17651765
static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
17661766
{
1767-
char *tmp = (char *)__get_free_page(GFP_KERNEL);
1767+
char *tmp = kmalloc(PATH_MAX, GFP_KERNEL);
17681768
char *pathname;
17691769
int len;
17701770

17711771
if (!tmp)
17721772
return -ENOMEM;
17731773

1774-
pathname = d_path(path, tmp, PAGE_SIZE);
1774+
pathname = d_path(path, tmp, PATH_MAX);
17751775
len = PTR_ERR(pathname);
17761776
if (IS_ERR(pathname))
17771777
goto out;
1778-
len = tmp + PAGE_SIZE - 1 - pathname;
1778+
len = tmp + PATH_MAX - 1 - pathname;
17791779

17801780
if (len > buflen)
17811781
len = buflen;
17821782
if (copy_to_user(buffer, pathname, len))
17831783
len = -EFAULT;
17841784
out:
1785-
free_page((unsigned long)tmp);
1785+
kfree(tmp);
17861786
return len;
17871787
}
17881788

fs/proc/vmcore.c

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,42 @@ core_param(novmcoredd, vmcoredd_disabled, bool, 0);
6262
/* Device Dump Size */
6363
static size_t vmcoredd_orig_sz;
6464

65-
static DECLARE_RWSEM(vmcore_cb_rwsem);
65+
static DEFINE_SPINLOCK(vmcore_cb_lock);
66+
DEFINE_STATIC_SRCU(vmcore_cb_srcu);
6667
/* List of registered vmcore callbacks. */
6768
static LIST_HEAD(vmcore_cb_list);
6869
/* Whether the vmcore has been opened once. */
6970
static bool vmcore_opened;
7071

7172
void register_vmcore_cb(struct vmcore_cb *cb)
7273
{
73-
down_write(&vmcore_cb_rwsem);
7474
INIT_LIST_HEAD(&cb->next);
75+
spin_lock(&vmcore_cb_lock);
7576
list_add_tail(&cb->next, &vmcore_cb_list);
7677
/*
7778
* Registering a vmcore callback after the vmcore was opened is
7879
* very unusual (e.g., manual driver loading).
7980
*/
8081
if (vmcore_opened)
8182
pr_warn_once("Unexpected vmcore callback registration\n");
82-
up_write(&vmcore_cb_rwsem);
83+
spin_unlock(&vmcore_cb_lock);
8384
}
8485
EXPORT_SYMBOL_GPL(register_vmcore_cb);
8586

8687
void unregister_vmcore_cb(struct vmcore_cb *cb)
8788
{
88-
down_write(&vmcore_cb_rwsem);
89-
list_del(&cb->next);
89+
spin_lock(&vmcore_cb_lock);
90+
list_del_rcu(&cb->next);
9091
/*
9192
* Unregistering a vmcore callback after the vmcore was opened is
9293
* very unusual (e.g., forced driver removal), but we cannot stop
9394
* unregistering.
9495
*/
9596
if (vmcore_opened)
9697
pr_warn_once("Unexpected vmcore callback unregistration\n");
97-
up_write(&vmcore_cb_rwsem);
98+
spin_unlock(&vmcore_cb_lock);
99+
100+
synchronize_srcu(&vmcore_cb_srcu);
98101
}
99102
EXPORT_SYMBOL_GPL(unregister_vmcore_cb);
100103

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

106-
lockdep_assert_held_read(&vmcore_cb_rwsem);
107-
108-
list_for_each_entry(cb, &vmcore_cb_list, next) {
109+
list_for_each_entry_srcu(cb, &vmcore_cb_list, next,
110+
srcu_read_lock_held(&vmcore_cb_srcu)) {
109111
if (unlikely(!cb->pfn_is_ram))
110112
continue;
111113
ret = cb->pfn_is_ram(cb, pfn);
@@ -118,9 +120,9 @@ static bool pfn_is_ram(unsigned long pfn)
118120

119121
static int open_vmcore(struct inode *inode, struct file *file)
120122
{
121-
down_read(&vmcore_cb_rwsem);
123+
spin_lock(&vmcore_cb_lock);
122124
vmcore_opened = true;
123-
up_read(&vmcore_cb_rwsem);
125+
spin_unlock(&vmcore_cb_lock);
124126

125127
return 0;
126128
}
@@ -133,14 +135,15 @@ ssize_t read_from_oldmem(char *buf, size_t count,
133135
unsigned long pfn, offset;
134136
size_t nr_bytes;
135137
ssize_t read = 0, tmp;
138+
int idx;
136139

137140
if (!count)
138141
return 0;
139142

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

143-
down_read(&vmcore_cb_rwsem);
146+
idx = srcu_read_lock(&vmcore_cb_srcu);
144147
do {
145148
if (count > (PAGE_SIZE - offset))
146149
nr_bytes = PAGE_SIZE - offset;
@@ -165,7 +168,7 @@ ssize_t read_from_oldmem(char *buf, size_t count,
165168
offset, userbuf);
166169
}
167170
if (tmp < 0) {
168-
up_read(&vmcore_cb_rwsem);
171+
srcu_read_unlock(&vmcore_cb_srcu, idx);
169172
return tmp;
170173
}
171174

@@ -176,8 +179,8 @@ ssize_t read_from_oldmem(char *buf, size_t count,
176179
++pfn;
177180
offset = 0;
178181
} while (count);
182+
srcu_read_unlock(&vmcore_cb_srcu, idx);
179183

180-
up_read(&vmcore_cb_rwsem);
181184
return read;
182185
}
183186

@@ -477,7 +480,7 @@ static const struct vm_operations_struct vmcore_mmap_ops = {
477480

478481
/**
479482
* vmcore_alloc_buf - allocate buffer in vmalloc memory
480-
* @sizez: size of buffer
483+
* @size: size of buffer
481484
*
482485
* If CONFIG_MMU is defined, use vmalloc_user() to allow users to mmap
483486
* the buffer to user-space by means of remap_vmalloc_range().
@@ -568,18 +571,18 @@ static int vmcore_remap_oldmem_pfn(struct vm_area_struct *vma,
568571
unsigned long from, unsigned long pfn,
569572
unsigned long size, pgprot_t prot)
570573
{
571-
int ret;
574+
int ret, idx;
572575

573576
/*
574-
* Check if oldmem_pfn_is_ram was registered to avoid
575-
* looping over all pages without a reason.
577+
* Check if a callback was registered to avoid looping over all
578+
* pages without a reason.
576579
*/
577-
down_read(&vmcore_cb_rwsem);
580+
idx = srcu_read_lock(&vmcore_cb_srcu);
578581
if (!list_empty(&vmcore_cb_list))
579582
ret = remap_oldmem_pfn_checked(vma, from, pfn, size, prot);
580583
else
581584
ret = remap_oldmem_pfn_range(vma, from, pfn, size, prot);
582-
up_read(&vmcore_cb_rwsem);
585+
srcu_read_unlock(&vmcore_cb_srcu, idx);
583586
return ret;
584587
}
585588

0 commit comments

Comments
 (0)