Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'akpm' (patches from Andrew)

Merge more updates from Andrew Morton:
"87 patches.

Subsystems affected by this patch series: mm (pagecache and hugetlb),
procfs, misc, MAINTAINERS, lib, checkpatch, binfmt, kallsyms, ramfs,
init, codafs, nilfs2, hfs, crash_dump, signals, seq_file, fork,
sysvfs, kcov, gdb, resource, selftests, and ipc"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (87 commits)
ipc/ipc_sysctl.c: remove fallback for !CONFIG_PROC_SYSCTL
ipc: check checkpoint_restore_ns_capable() to modify C/R proc files
selftests/kselftest/runner/run_one(): allow running non-executable files
virtio-mem: disallow mapping virtio-mem memory via /dev/mem
kernel/resource: disallow access to exclusive system RAM regions
kernel/resource: clean up and optimize iomem_is_exclusive()
scripts/gdb: handle split debug for vmlinux
kcov: replace local_irq_save() with a local_lock_t
kcov: avoid enable+disable interrupts if !in_task()
kcov: allocate per-CPU memory on the relevant node
Documentation/kcov: define `ip' in the example
Documentation/kcov: include types.h in the example
sysv: use BUILD_BUG_ON instead of runtime check
kernel/fork.c: unshare(): use swap() to make code cleaner
seq_file: fix passing wrong private data
seq_file: move seq_escape() to a header
signal: remove duplicate include in signal.h
crash_dump: remove duplicate include in crash_dump.h
crash_dump: fix boolreturn.cocci warning
hfs/hfsplus: use WARN_ON for sanity check
...

+1178 -654
+2
.mailmap
··· 73 73 Chris Chiu <chris.chiu@canonical.com> <chiu@endlessos.org> 74 74 Christophe Ricard <christophe.ricard@gmail.com> 75 75 Christoph Hellwig <hch@lst.de> 76 + Colin Ian King <colin.king@intel.com> <colin.king@canonical.com> 77 + Colin Ian King <colin.king@intel.com> <colin.i.king@gmail.com> 76 78 Corey Minyard <minyard@acm.org> 77 79 Damian Hobson-Garcia <dhobsong@igel.co.jp> 78 80 Daniel Borkmann <daniel@iogearbox.net> <danborkmann@googlemail.com>
+5
Documentation/dev-tools/kcov.rst
··· 50 50 #include <sys/mman.h> 51 51 #include <unistd.h> 52 52 #include <fcntl.h> 53 + #include <linux/types.h> 53 54 54 55 #define KCOV_INIT_TRACE _IOR('c', 1, unsigned long) 55 56 #define KCOV_ENABLE _IO('c', 100) ··· 178 177 /* Read number of comparisons collected. */ 179 178 n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED); 180 179 for (i = 0; i < n; i++) { 180 + uint64_t ip; 181 + 181 182 type = cover[i * KCOV_WORDS_PER_CMP + 1]; 182 183 /* arg1 and arg2 - operands of the comparison. */ 183 184 arg1 = cover[i * KCOV_WORDS_PER_CMP + 2]; ··· 253 250 selectively from different subsystems. 254 251 255 252 .. code-block:: c 253 + 254 + /* Same includes and defines as above. */ 256 255 257 256 struct kcov_remote_arg { 258 257 __u32 trace_mode;
+17 -4
MAINTAINERS
··· 767 767 ALLWINNER HARDWARE SPINLOCK SUPPORT 768 768 M: Wilken Gottwalt <wilken.gottwalt@posteo.net> 769 769 S: Maintained 770 - F: Documentation/devicetree/bindings/hwlock/allwinner,sun6i-hwspinlock.yaml 770 + F: Documentation/devicetree/bindings/hwlock/allwinner,sun6i-a31-hwspinlock.yaml 771 771 F: drivers/hwspinlock/sun6i_hwspinlock.c 772 772 773 773 ALLWINNER THERMAL DRIVER ··· 2783 2783 F: Documentation/devicetree/bindings/net/toshiba,visconti-dwmac.yaml 2784 2784 F: Documentation/devicetree/bindings/gpio/toshiba,gpio-visconti.yaml 2785 2785 F: Documentation/devicetree/bindings/pci/toshiba,visconti-pcie.yaml 2786 - F: Documentation/devicetree/bindings/pinctrl/toshiba,tmpv7700-pinctrl.yaml 2786 + F: Documentation/devicetree/bindings/pinctrl/toshiba,visconti-pinctrl.yaml 2787 2787 F: Documentation/devicetree/bindings/watchdog/toshiba,visconti-wdt.yaml 2788 2788 F: arch/arm64/boot/dts/toshiba/ 2789 2789 F: drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c ··· 7119 7119 F: include/uapi/linux/mii.h 7120 7120 F: net/core/of_net.c 7121 7121 7122 + EXEC & BINFMT API 7123 + R: Eric Biederman <ebiederm@xmission.com> 7124 + R: Kees Cook <keescook@chromium.org> 7125 + F: arch/alpha/kernel/binfmt_loader.c 7126 + F: arch/x86/ia32/ia32_aout.c 7127 + F: fs/*binfmt_*.c 7128 + F: fs/exec.c 7129 + F: include/linux/binfmts.h 7130 + F: include/linux/elf.h 7131 + F: include/uapi/linux/binfmts.h 7132 + F: tools/testing/selftests/exec/ 7133 + N: asm/elf.h 7134 + N: binfmt 7135 + 7122 7136 EXFAT FILE SYSTEM 7123 7137 M: Namjae Jeon <linkinjeon@kernel.org> 7124 7138 M: Sungjong Seo <sj1557.seo@samsung.com> ··· 8576 8562 L: linux-kernel@vger.kernel.org 8577 8563 S: Maintained 8578 8564 F: drivers/misc/hisi_hikey_usb.c 8579 - F: Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.yaml 8580 8565 8581 8566 HISILICON PMU DRIVER 8582 8567 M: Shaokun Zhang <zhangshaokun@hisilicon.com> ··· 9634 9621 M: Anitha Chrisanthus <anitha.chrisanthus@intel.com> 9635 9622 M: Edmund Dea <edmund.j.dea@intel.com> 9636 9623 S: Maintained 9637 - F: Documentation/devicetree/bindings/display/intel,kmb_display.yaml 9624 + F: Documentation/devicetree/bindings/display/intel,keembay-display.yaml 9638 9625 F: drivers/gpu/drm/kmb/ 9639 9626 9640 9627 INTEL KEEM BAY OCS AES/SM4 CRYPTO DRIVER
+1 -3
arch/alpha/kernel/traps.c
··· 129 129 extern char _stext[], _etext[]; 130 130 unsigned long tmp = *sp; 131 131 sp++; 132 - if (tmp < (unsigned long) &_stext) 133 - continue; 134 - if (tmp >= (unsigned long) &_etext) 132 + if (!is_kernel_text(tmp)) 135 133 continue; 136 134 printk("%s[<%lx>] %pSR\n", loglvl, tmp, (void *)tmp); 137 135 if (i > 40) {
+2 -1
arch/microblaze/mm/pgtable.c
··· 34 34 #include <linux/mm_types.h> 35 35 #include <linux/pgtable.h> 36 36 #include <linux/memblock.h> 37 + #include <linux/kallsyms.h> 37 38 38 39 #include <asm/pgalloc.h> 39 40 #include <linux/io.h> ··· 172 171 for (s = 0; s < lowmem_size; s += PAGE_SIZE) { 173 172 f = _PAGE_PRESENT | _PAGE_ACCESSED | 174 173 _PAGE_SHARED | _PAGE_HWEXEC; 175 - if ((char *) v < _stext || (char *) v >= _etext) 174 + if (!is_kernel_text(v)) 176 175 f |= _PAGE_WRENABLE; 177 176 else 178 177 /* On the MicroBlaze, no user access
+2 -5
arch/powerpc/mm/pgtable_32.c
··· 33 33 34 34 #include <mm/mmu_decl.h> 35 35 36 - extern char etext[], _stext[], _sinittext[], _einittext[]; 37 - 38 36 static u8 early_fixmap_pagetable[FIXMAP_PTE_SIZE] __page_aligned_data; 39 37 40 38 notrace void __init early_ioremap_init(void) ··· 102 104 { 103 105 unsigned long v, s; 104 106 phys_addr_t p; 105 - int ktext; 107 + bool ktext; 106 108 107 109 s = offset; 108 110 v = PAGE_OFFSET + s; 109 111 p = memstart_addr + s; 110 112 for (; s < top; s += PAGE_SIZE) { 111 - ktext = ((char *)v >= _stext && (char *)v < etext) || 112 - ((char *)v >= _sinittext && (char *)v < _einittext); 113 + ktext = core_kernel_text(v); 113 114 map_kernel_page(v, p, ktext ? PAGE_KERNEL_TEXT : PAGE_KERNEL); 114 115 v += PAGE_SIZE; 115 116 p += PAGE_SIZE;
+4
arch/riscv/lib/delay.c
··· 4 4 */ 5 5 6 6 #include <linux/delay.h> 7 + #include <linux/math.h> 7 8 #include <linux/param.h> 8 9 #include <linux/timex.h> 10 + #include <linux/types.h> 9 11 #include <linux/export.h> 12 + 13 + #include <asm/processor.h> 10 14 11 15 /* 12 16 * This is copies from arch/arm/include/asm/delay.h
+4
arch/s390/include/asm/facility.h
··· 9 9 #define __ASM_FACILITY_H 10 10 11 11 #include <asm/facility-defs.h> 12 + 13 + #include <linux/minmax.h> 12 14 #include <linux/string.h> 15 + #include <linux/types.h> 13 16 #include <linux/preempt.h> 17 + 14 18 #include <asm/lowcore.h> 15 19 16 20 #define MAX_FACILITY_BIT (sizeof(stfle_fac_list) * 8)
+12 -1
arch/x86/kernel/aperture_64.c
··· 73 73 (pfn >= aperture_pfn_start + aperture_page_count)); 74 74 } 75 75 76 + #ifdef CONFIG_PROC_VMCORE 77 + static bool gart_oldmem_pfn_is_ram(struct vmcore_cb *cb, unsigned long pfn) 78 + { 79 + return !!gart_mem_pfn_is_ram(pfn); 80 + } 81 + 82 + static struct vmcore_cb gart_vmcore_cb = { 83 + .pfn_is_ram = gart_oldmem_pfn_is_ram, 84 + }; 85 + #endif 86 + 76 87 static void __init exclude_from_core(u64 aper_base, u32 aper_order) 77 88 { 78 89 aperture_pfn_start = aper_base >> PAGE_SHIFT; 79 90 aperture_page_count = (32 * 1024 * 1024) << aper_order >> PAGE_SHIFT; 80 91 #ifdef CONFIG_PROC_VMCORE 81 - WARN_ON(register_oldmem_pfn_is_ram(&gart_mem_pfn_is_ram)); 92 + register_vmcore_cb(&gart_vmcore_cb); 82 93 #endif 83 94 #ifdef CONFIG_PROC_KCORE 84 95 WARN_ON(register_mem_pfn_is_ram(&gart_mem_pfn_is_ram));
+1 -1
arch/x86/kernel/unwind_orc.c
··· 175 175 } 176 176 177 177 /* vmlinux .init slow lookup: */ 178 - if (init_kernel_text(ip)) 178 + if (is_kernel_inittext(ip)) 179 179 return __orc_find(__start_orc_unwind_ip, __start_orc_unwind, 180 180 __stop_orc_unwind_ip - __start_orc_unwind_ip, ip); 181 181
+5 -9
arch/x86/mm/init_32.c
··· 238 238 } 239 239 } 240 240 241 - /* 242 - * The <linux/kallsyms.h> already defines is_kernel_text, 243 - * using '__' prefix not to get in conflict. 244 - */ 245 - static inline int __is_kernel_text(unsigned long addr) 241 + static inline int is_x86_32_kernel_text(unsigned long addr) 246 242 { 247 243 if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end) 248 244 return 1; ··· 329 333 addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE + 330 334 PAGE_OFFSET + PAGE_SIZE-1; 331 335 332 - if (__is_kernel_text(addr) || 333 - __is_kernel_text(addr2)) 336 + if (is_x86_32_kernel_text(addr) || 337 + is_x86_32_kernel_text(addr2)) 334 338 prot = PAGE_KERNEL_LARGE_EXEC; 335 339 336 340 pages_2m++; ··· 355 359 */ 356 360 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR); 357 361 358 - if (__is_kernel_text(addr)) 362 + if (is_x86_32_kernel_text(addr)) 359 363 prot = PAGE_KERNEL_EXEC; 360 364 361 365 pages_4k++; ··· 785 789 */ 786 790 unsigned long start = PFN_ALIGN(_etext); 787 791 /* 788 - * This comes from __is_kernel_text upper limit. Also HPAGE where used: 792 + * This comes from is_x86_32_kernel_text upper limit. Also HPAGE where used: 789 793 */ 790 794 unsigned long size = (((unsigned long)__init_end + HPAGE_SIZE) & HPAGE_MASK) - start; 791 795
+13 -24
arch/x86/xen/mmu_hvm.c
··· 9 9 10 10 #ifdef CONFIG_PROC_VMCORE 11 11 /* 12 - * This function is used in two contexts: 13 - * - the kdump kernel has to check whether a pfn of the crashed kernel 14 - * was a ballooned page. vmcore is using this function to decide 15 - * whether to access a pfn of the crashed kernel. 16 - * - the kexec kernel has to check whether a pfn was ballooned by the 17 - * previous kernel. If the pfn is ballooned, handle it properly. 18 - * Returns 0 if the pfn is not backed by a RAM page, the caller may 12 + * The kdump kernel has to check whether a pfn of the crashed kernel 13 + * was a ballooned page. vmcore is using this function to decide 14 + * whether to access a pfn of the crashed kernel. 15 + * Returns "false" if the pfn is not backed by a RAM page, the caller may 19 16 * handle the pfn special in this case. 20 17 */ 21 - static int xen_oldmem_pfn_is_ram(unsigned long pfn) 18 + static bool xen_vmcore_pfn_is_ram(struct vmcore_cb *cb, unsigned long pfn) 22 19 { 23 20 struct xen_hvm_get_mem_type a = { 24 21 .domid = DOMID_SELF, 25 22 .pfn = pfn, 26 23 }; 27 - int ram; 28 24 29 - if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a)) 30 - return -ENXIO; 31 - 32 - switch (a.mem_type) { 33 - case HVMMEM_mmio_dm: 34 - ram = 0; 35 - break; 36 - case HVMMEM_ram_rw: 37 - case HVMMEM_ram_ro: 38 - default: 39 - ram = 1; 40 - break; 25 + if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a)) { 26 + pr_warn_once("Unexpected HVMOP_get_mem_type failure\n"); 27 + return true; 41 28 } 42 - 43 - return ram; 29 + return a.mem_type != HVMMEM_mmio_dm; 44 30 } 31 + static struct vmcore_cb xen_vmcore_cb = { 32 + .pfn_is_ram = xen_vmcore_pfn_is_ram, 33 + }; 45 34 #endif 46 35 47 36 static void xen_hvm_exit_mmap(struct mm_struct *mm) ··· 64 75 if (is_pagetable_dying_supported()) 65 76 pv_ops.mmu.exit_mmap = xen_hvm_exit_mmap; 66 77 #ifdef CONFIG_PROC_VMCORE 67 - WARN_ON(register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram)); 78 + register_vmcore_cb(&xen_vmcore_cb); 68 79 #endif 69 80 }
+1 -4
drivers/gpu/drm/drm_dp_mst_topology.c
··· 1668 1668 for (i = 0; i < history->len; i++) { 1669 1669 const struct drm_dp_mst_topology_ref_entry *entry = 1670 1670 &history->entries[i]; 1671 - ulong *entries; 1672 - uint nr_entries; 1673 1671 u64 ts_nsec = entry->ts_nsec; 1674 1672 u32 rem_nsec = do_div(ts_nsec, 1000000000); 1675 1673 1676 - nr_entries = stack_depot_fetch(entry->backtrace, &entries); 1677 - stack_trace_snprint(buf, PAGE_SIZE, entries, nr_entries, 4); 1674 + stack_depot_snprint(entry->backtrace, buf, PAGE_SIZE, 4); 1678 1675 1679 1676 drm_printf(&p, " %d %ss (last at %5llu.%06u):\n%s", 1680 1677 entry->count,
+1 -4
drivers/gpu/drm/drm_mm.c
··· 118 118 static void show_leaks(struct drm_mm *mm) 119 119 { 120 120 struct drm_mm_node *node; 121 - unsigned long *entries; 122 - unsigned int nr_entries; 123 121 char *buf; 124 122 125 123 buf = kmalloc(BUFSZ, GFP_KERNEL); ··· 131 133 continue; 132 134 } 133 135 134 - nr_entries = stack_depot_fetch(node->stack, &entries); 135 - stack_trace_snprint(buf, BUFSZ, entries, nr_entries, 0); 136 + stack_depot_snprint(node->stack, buf, BUFSZ, 0); 136 137 DRM_ERROR("node [%08llx + %08llx]: inserted at\n%s", 137 138 node->start, node->size, buf); 138 139 }
+1 -4
drivers/gpu/drm/i915/i915_vma.c
··· 56 56 57 57 static void vma_print_allocator(struct i915_vma *vma, const char *reason) 58 58 { 59 - unsigned long *entries; 60 - unsigned int nr_entries; 61 59 char buf[512]; 62 60 63 61 if (!vma->node.stack) { ··· 64 66 return; 65 67 } 66 68 67 - nr_entries = stack_depot_fetch(vma->node.stack, &entries); 68 - stack_trace_snprint(buf, sizeof(buf), entries, nr_entries, 0); 69 + stack_depot_snprint(vma->node.stack, buf, sizeof(buf), 0); 69 70 DRM_DEBUG_DRIVER("vma.node [%08llx + %08llx] %s: inserted at %s\n", 70 71 vma->node.start, vma->node.size, reason, buf); 71 72 }
+5 -15
drivers/gpu/drm/i915/intel_runtime_pm.c
··· 65 65 return stack_depot_save(entries, n, GFP_NOWAIT | __GFP_NOWARN); 66 66 } 67 67 68 - static void __print_depot_stack(depot_stack_handle_t stack, 69 - char *buf, int sz, int indent) 70 - { 71 - unsigned long *entries; 72 - unsigned int nr_entries; 73 - 74 - nr_entries = stack_depot_fetch(stack, &entries); 75 - stack_trace_snprint(buf, sz, entries, nr_entries, indent); 76 - } 77 - 78 68 static void init_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm) 79 69 { 80 70 spin_lock_init(&rpm->debug.lock); ··· 136 146 if (!buf) 137 147 return; 138 148 139 - __print_depot_stack(stack, buf, PAGE_SIZE, 2); 149 + stack_depot_snprint(stack, buf, PAGE_SIZE, 2); 140 150 DRM_DEBUG_DRIVER("wakeref %x from\n%s", stack, buf); 141 151 142 152 stack = READ_ONCE(rpm->debug.last_release); 143 153 if (stack) { 144 - __print_depot_stack(stack, buf, PAGE_SIZE, 2); 154 + stack_depot_snprint(stack, buf, PAGE_SIZE, 2); 145 155 DRM_DEBUG_DRIVER("wakeref last released at\n%s", buf); 146 156 } 147 157 ··· 173 183 return; 174 184 175 185 if (dbg->last_acquire) { 176 - __print_depot_stack(dbg->last_acquire, buf, PAGE_SIZE, 2); 186 + stack_depot_snprint(dbg->last_acquire, buf, PAGE_SIZE, 2); 177 187 drm_printf(p, "Wakeref last acquired:\n%s", buf); 178 188 } 179 189 180 190 if (dbg->last_release) { 181 - __print_depot_stack(dbg->last_release, buf, PAGE_SIZE, 2); 191 + stack_depot_snprint(dbg->last_release, buf, PAGE_SIZE, 2); 182 192 drm_printf(p, "Wakeref last released:\n%s", buf); 183 193 } 184 194 ··· 193 203 rep = 1; 194 204 while (i + 1 < dbg->count && dbg->owners[i + 1] == stack) 195 205 rep++, i++; 196 - __print_depot_stack(stack, buf, PAGE_SIZE, 2); 206 + stack_depot_snprint(stack, buf, PAGE_SIZE, 2); 197 207 drm_printf(p, "Wakeref x%lu taken at:\n%s", rep, buf); 198 208 } 199 209
+1
drivers/media/dvb-frontends/cxd2880/cxd2880_common.h
··· 12 12 #include <linux/types.h> 13 13 #include <linux/errno.h> 14 14 #include <linux/delay.h> 15 + #include <linux/bits.h> 15 16 #include <linux/string.h> 16 17 17 18 int cxd2880_convert2s_complement(u32 value, u32 bitlen);
+1
drivers/virtio/Kconfig
··· 111 111 depends on MEMORY_HOTPLUG 112 112 depends on MEMORY_HOTREMOVE 113 113 depends on CONTIG_ALLOC 114 + depends on EXCLUSIVE_SYSTEM_RAM 114 115 help 115 116 This driver provides access to virtio-mem paravirtualized memory 116 117 devices, allowing to hotplug and hotunplug memory.
+216 -85
drivers/virtio/virtio_mem.c
··· 223 223 * When this lock is held the pointers can't change, ONLINE and 224 224 * OFFLINE blocks can't change the state and no subblocks will get 225 225 * plugged/unplugged. 226 + * 227 + * In kdump mode, used to serialize requests, last_block_addr and 228 + * last_block_plugged. 226 229 */ 227 230 struct mutex hotplug_mutex; 228 231 bool hotplug_active; 229 232 230 233 /* An error occurred we cannot handle - stop processing requests. */ 231 234 bool broken; 235 + 236 + /* Cached valued of is_kdump_kernel() when the device was probed. */ 237 + bool in_kdump; 232 238 233 239 /* The driver is being removed. */ 234 240 spinlock_t removal_lock; ··· 248 242 249 243 /* Memory notifier (online/offline events). */ 250 244 struct notifier_block memory_notifier; 245 + 246 + #ifdef CONFIG_PROC_VMCORE 247 + /* vmcore callback for /proc/vmcore handling in kdump mode */ 248 + struct vmcore_cb vmcore_cb; 249 + uint64_t last_block_addr; 250 + bool last_block_plugged; 251 + #endif /* CONFIG_PROC_VMCORE */ 251 252 252 253 /* Next device in the list of virtio-mem devices. */ 253 254 struct list_head next; ··· 273 260 static void virtio_mem_fake_offline_cancel_offline(unsigned long pfn, 274 261 unsigned long nr_pages); 275 262 static void virtio_mem_retry(struct virtio_mem *vm); 263 + static int virtio_mem_create_resource(struct virtio_mem *vm); 264 + static void virtio_mem_delete_resource(struct virtio_mem *vm); 276 265 277 266 /* 278 267 * Register a virtio-mem device so it will be considered for the online_page ··· 2306 2291 uint64_t diff; 2307 2292 int rc; 2308 2293 2294 + if (unlikely(vm->in_kdump)) { 2295 + dev_warn_once(&vm->vdev->dev, 2296 + "unexpected workqueue run in kdump kernel\n"); 2297 + return; 2298 + } 2299 + 2309 2300 hrtimer_cancel(&vm->retry_timer); 2310 2301 2311 2302 if (vm->broken) ··· 2413 2392 return 0; 2414 2393 } 2415 2394 2416 - static int virtio_mem_init(struct virtio_mem *vm) 2395 + static int virtio_mem_init_hotplug(struct virtio_mem *vm) 2417 2396 { 2418 2397 const struct range pluggable_range = mhp_get_pluggable_range(true); 2419 - uint64_t sb_size, addr; 2420 - uint16_t node_id; 2421 - 2422 - if (!vm->vdev->config->get) { 2423 - dev_err(&vm->vdev->dev, "config access disabled\n"); 2424 - return -EINVAL; 2425 - } 2426 - 2427 - /* 2428 - * We don't want to (un)plug or reuse any memory when in kdump. The 2429 - * memory is still accessible (but not mapped). 2430 - */ 2431 - if (is_kdump_kernel()) { 2432 - dev_warn(&vm->vdev->dev, "disabled in kdump kernel\n"); 2433 - return -EBUSY; 2434 - } 2435 - 2436 - /* Fetch all properties that can't change. */ 2437 - virtio_cread_le(vm->vdev, struct virtio_mem_config, plugged_size, 2438 - &vm->plugged_size); 2439 - virtio_cread_le(vm->vdev, struct virtio_mem_config, block_size, 2440 - &vm->device_block_size); 2441 - virtio_cread_le(vm->vdev, struct virtio_mem_config, node_id, 2442 - &node_id); 2443 - vm->nid = virtio_mem_translate_node_id(vm, node_id); 2444 - virtio_cread_le(vm->vdev, struct virtio_mem_config, addr, &vm->addr); 2445 - virtio_cread_le(vm->vdev, struct virtio_mem_config, region_size, 2446 - &vm->region_size); 2447 - 2448 - /* Determine the nid for the device based on the lowest address. */ 2449 - if (vm->nid == NUMA_NO_NODE) 2450 - vm->nid = memory_add_physaddr_to_nid(vm->addr); 2398 + uint64_t unit_pages, sb_size, addr; 2399 + int rc; 2451 2400 2452 2401 /* bad device setup - warn only */ 2453 2402 if (!IS_ALIGNED(vm->addr, memory_block_size_bytes())) ··· 2487 2496 vm->offline_threshold); 2488 2497 } 2489 2498 2490 - dev_info(&vm->vdev->dev, "start address: 0x%llx", vm->addr); 2491 - dev_info(&vm->vdev->dev, "region size: 0x%llx", vm->region_size); 2492 - dev_info(&vm->vdev->dev, "device block size: 0x%llx", 2493 - (unsigned long long)vm->device_block_size); 2494 2499 dev_info(&vm->vdev->dev, "memory block size: 0x%lx", 2495 2500 memory_block_size_bytes()); 2496 2501 if (vm->in_sbm) ··· 2495 2508 else 2496 2509 dev_info(&vm->vdev->dev, "big block size: 0x%llx", 2497 2510 (unsigned long long)vm->bbm.bb_size); 2511 + 2512 + /* create the parent resource for all memory */ 2513 + rc = virtio_mem_create_resource(vm); 2514 + if (rc) 2515 + return rc; 2516 + 2517 + /* use a single dynamic memory group to cover the whole memory device */ 2518 + if (vm->in_sbm) 2519 + unit_pages = PHYS_PFN(memory_block_size_bytes()); 2520 + else 2521 + unit_pages = PHYS_PFN(vm->bbm.bb_size); 2522 + rc = memory_group_register_dynamic(vm->nid, unit_pages); 2523 + if (rc < 0) 2524 + goto out_del_resource; 2525 + vm->mgid = rc; 2526 + 2527 + /* 2528 + * If we still have memory plugged, we have to unplug all memory first. 2529 + * Registering our parent resource makes sure that this memory isn't 2530 + * actually in use (e.g., trying to reload the driver). 2531 + */ 2532 + if (vm->plugged_size) { 2533 + vm->unplug_all_required = true; 2534 + dev_info(&vm->vdev->dev, "unplugging all memory is required\n"); 2535 + } 2536 + 2537 + /* register callbacks */ 2538 + vm->memory_notifier.notifier_call = virtio_mem_memory_notifier_cb; 2539 + rc = register_memory_notifier(&vm->memory_notifier); 2540 + if (rc) 2541 + goto out_unreg_group; 2542 + rc = register_virtio_mem_device(vm); 2543 + if (rc) 2544 + goto out_unreg_mem; 2545 + 2546 + return 0; 2547 + out_unreg_mem: 2548 + unregister_memory_notifier(&vm->memory_notifier); 2549 + out_unreg_group: 2550 + memory_group_unregister(vm->mgid); 2551 + out_del_resource: 2552 + virtio_mem_delete_resource(vm); 2553 + return rc; 2554 + } 2555 + 2556 + #ifdef CONFIG_PROC_VMCORE 2557 + static int virtio_mem_send_state_request(struct virtio_mem *vm, uint64_t addr, 2558 + uint64_t size) 2559 + { 2560 + const uint64_t nb_vm_blocks = size / vm->device_block_size; 2561 + const struct virtio_mem_req req = { 2562 + .type = cpu_to_virtio16(vm->vdev, VIRTIO_MEM_REQ_STATE), 2563 + .u.state.addr = cpu_to_virtio64(vm->vdev, addr), 2564 + .u.state.nb_blocks = cpu_to_virtio16(vm->vdev, nb_vm_blocks), 2565 + }; 2566 + int rc = -ENOMEM; 2567 + 2568 + dev_dbg(&vm->vdev->dev, "requesting state: 0x%llx - 0x%llx\n", addr, 2569 + addr + size - 1); 2570 + 2571 + switch (virtio_mem_send_request(vm, &req)) { 2572 + case VIRTIO_MEM_RESP_ACK: 2573 + return virtio16_to_cpu(vm->vdev, vm->resp.u.state.state); 2574 + case VIRTIO_MEM_RESP_ERROR: 2575 + rc = -EINVAL; 2576 + break; 2577 + default: 2578 + break; 2579 + } 2580 + 2581 + dev_dbg(&vm->vdev->dev, "requesting state failed: %d\n", rc); 2582 + return rc; 2583 + } 2584 + 2585 + static bool virtio_mem_vmcore_pfn_is_ram(struct vmcore_cb *cb, 2586 + unsigned long pfn) 2587 + { 2588 + struct virtio_mem *vm = container_of(cb, struct virtio_mem, 2589 + vmcore_cb); 2590 + uint64_t addr = PFN_PHYS(pfn); 2591 + bool is_ram; 2592 + int rc; 2593 + 2594 + if (!virtio_mem_contains_range(vm, addr, PAGE_SIZE)) 2595 + return true; 2596 + if (!vm->plugged_size) 2597 + return false; 2598 + 2599 + /* 2600 + * We have to serialize device requests and access to the information 2601 + * about the block queried last. 2602 + */ 2603 + mutex_lock(&vm->hotplug_mutex); 2604 + 2605 + addr = ALIGN_DOWN(addr, vm->device_block_size); 2606 + if (addr != vm->last_block_addr) { 2607 + rc = virtio_mem_send_state_request(vm, addr, 2608 + vm->device_block_size); 2609 + /* On any kind of error, we're going to signal !ram. */ 2610 + if (rc == VIRTIO_MEM_STATE_PLUGGED) 2611 + vm->last_block_plugged = true; 2612 + else 2613 + vm->last_block_plugged = false; 2614 + vm->last_block_addr = addr; 2615 + } 2616 + 2617 + is_ram = vm->last_block_plugged; 2618 + mutex_unlock(&vm->hotplug_mutex); 2619 + return is_ram; 2620 + } 2621 + #endif /* CONFIG_PROC_VMCORE */ 2622 + 2623 + static int virtio_mem_init_kdump(struct virtio_mem *vm) 2624 + { 2625 + #ifdef CONFIG_PROC_VMCORE 2626 + dev_info(&vm->vdev->dev, "memory hot(un)plug disabled in kdump kernel\n"); 2627 + vm->vmcore_cb.pfn_is_ram = virtio_mem_vmcore_pfn_is_ram; 2628 + register_vmcore_cb(&vm->vmcore_cb); 2629 + return 0; 2630 + #else /* CONFIG_PROC_VMCORE */ 2631 + dev_warn(&vm->vdev->dev, "disabled in kdump kernel without vmcore\n"); 2632 + return -EBUSY; 2633 + #endif /* CONFIG_PROC_VMCORE */ 2634 + } 2635 + 2636 + static int virtio_mem_init(struct virtio_mem *vm) 2637 + { 2638 + uint16_t node_id; 2639 + 2640 + if (!vm->vdev->config->get) { 2641 + dev_err(&vm->vdev->dev, "config access disabled\n"); 2642 + return -EINVAL; 2643 + } 2644 + 2645 + /* Fetch all properties that can't change. */ 2646 + virtio_cread_le(vm->vdev, struct virtio_mem_config, plugged_size, 2647 + &vm->plugged_size); 2648 + virtio_cread_le(vm->vdev, struct virtio_mem_config, block_size, 2649 + &vm->device_block_size); 2650 + virtio_cread_le(vm->vdev, struct virtio_mem_config, node_id, 2651 + &node_id); 2652 + vm->nid = virtio_mem_translate_node_id(vm, node_id); 2653 + virtio_cread_le(vm->vdev, struct virtio_mem_config, addr, &vm->addr); 2654 + virtio_cread_le(vm->vdev, struct virtio_mem_config, region_size, 2655 + &vm->region_size); 2656 + 2657 + /* Determine the nid for the device based on the lowest address. */ 2658 + if (vm->nid == NUMA_NO_NODE) 2659 + vm->nid = memory_add_physaddr_to_nid(vm->addr); 2660 + 2661 + dev_info(&vm->vdev->dev, "start address: 0x%llx", vm->addr); 2662 + dev_info(&vm->vdev->dev, "region size: 0x%llx", vm->region_size); 2663 + dev_info(&vm->vdev->dev, "device block size: 0x%llx", 2664 + (unsigned long long)vm->device_block_size); 2498 2665 if (vm->nid != NUMA_NO_NODE && IS_ENABLED(CONFIG_NUMA)) 2499 2666 dev_info(&vm->vdev->dev, "nid: %d", vm->nid); 2500 2667 2501 - return 0; 2668 + /* 2669 + * We don't want to (un)plug or reuse any memory when in kdump. The 2670 + * memory is still accessible (but not exposed to Linux). 2671 + */ 2672 + if (vm->in_kdump) 2673 + return virtio_mem_init_kdump(vm); 2674 + return virtio_mem_init_hotplug(vm); 2502 2675 } 2503 2676 2504 2677 static int virtio_mem_create_resource(struct virtio_mem *vm) ··· 2672 2525 if (!name) 2673 2526 return -ENOMEM; 2674 2527 2528 + /* Disallow mapping device memory via /dev/mem completely. */ 2675 2529 vm->parent_resource = __request_mem_region(vm->addr, vm->region_size, 2676 - name, IORESOURCE_SYSTEM_RAM); 2530 + name, IORESOURCE_SYSTEM_RAM | 2531 + IORESOURCE_EXCLUSIVE); 2677 2532 if (!vm->parent_resource) { 2678 2533 kfree(name); 2679 2534 dev_warn(&vm->vdev->dev, "could not reserve device region\n"); ··· 2720 2571 static int virtio_mem_probe(struct virtio_device *vdev) 2721 2572 { 2722 2573 struct virtio_mem *vm; 2723 - uint64_t unit_pages; 2724 2574 int rc; 2725 2575 2726 2576 BUILD_BUG_ON(sizeof(struct virtio_mem_req) != 24); ··· 2738 2590 hrtimer_init(&vm->retry_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 2739 2591 vm->retry_timer.function = virtio_mem_timer_expired; 2740 2592 vm->retry_timer_ms = VIRTIO_MEM_RETRY_TIMER_MIN_MS; 2593 + vm->in_kdump = is_kdump_kernel(); 2741 2594 2742 2595 /* register the virtqueue */ 2743 2596 rc = virtio_mem_init_vq(vm); ··· 2750 2601 if (rc) 2751 2602 goto out_del_vq; 2752 2603 2753 - /* create the parent resource for all memory */ 2754 - rc = virtio_mem_create_resource(vm); 2755 - if (rc) 2756 - goto out_del_vq; 2757 - 2758 - /* use a single dynamic memory group to cover the whole memory device */ 2759 - if (vm->in_sbm) 2760 - unit_pages = PHYS_PFN(memory_block_size_bytes()); 2761 - else 2762 - unit_pages = PHYS_PFN(vm->bbm.bb_size); 2763 - rc = memory_group_register_dynamic(vm->nid, unit_pages); 2764 - if (rc < 0) 2765 - goto out_del_resource; 2766 - vm->mgid = rc; 2767 - 2768 - /* 2769 - * If we still have memory plugged, we have to unplug all memory first. 2770 - * Registering our parent resource makes sure that this memory isn't 2771 - * actually in use (e.g., trying to reload the driver). 2772 - */ 2773 - if (vm->plugged_size) { 2774 - vm->unplug_all_required = true; 2775 - dev_info(&vm->vdev->dev, "unplugging all memory is required\n"); 2776 - } 2777 - 2778 - /* register callbacks */ 2779 - vm->memory_notifier.notifier_call = virtio_mem_memory_notifier_cb; 2780 - rc = register_memory_notifier(&vm->memory_notifier); 2781 - if (rc) 2782 - goto out_unreg_group; 2783 - rc = register_virtio_mem_device(vm); 2784 - if (rc) 2785 - goto out_unreg_mem; 2786 - 2787 2604 virtio_device_ready(vdev); 2788 2605 2789 2606 /* trigger a config update to start processing the requested_size */ 2790 - atomic_set(&vm->config_changed, 1); 2791 - queue_work(system_freezable_wq, &vm->wq); 2607 + if (!vm->in_kdump) { 2608 + atomic_set(&vm->config_changed, 1); 2609 + queue_work(system_freezable_wq, &vm->wq); 2610 + } 2792 2611 2793 2612 return 0; 2794 - out_unreg_mem: 2795 - unregister_memory_notifier(&vm->memory_notifier); 2796 - out_unreg_group: 2797 - memory_group_unregister(vm->mgid); 2798 - out_del_resource: 2799 - virtio_mem_delete_resource(vm); 2800 2613 out_del_vq: 2801 2614 vdev->config->del_vqs(vdev); 2802 2615 out_free_vm: ··· 2768 2657 return rc; 2769 2658 } 2770 2659 2771 - static void virtio_mem_remove(struct virtio_device *vdev) 2660 + static void virtio_mem_deinit_hotplug(struct virtio_mem *vm) 2772 2661 { 2773 - struct virtio_mem *vm = vdev->priv; 2774 2662 unsigned long mb_id; 2775 2663 int rc; 2776 2664 ··· 2816 2706 * away. Warn at least. 2817 2707 */ 2818 2708 if (virtio_mem_has_memory_added(vm)) { 2819 - dev_warn(&vdev->dev, "device still has system memory added\n"); 2709 + dev_warn(&vm->vdev->dev, 2710 + "device still has system memory added\n"); 2820 2711 } else { 2821 2712 virtio_mem_delete_resource(vm); 2822 2713 kfree_const(vm->resource_name); ··· 2831 2720 } else { 2832 2721 vfree(vm->bbm.bb_states); 2833 2722 } 2723 + } 2724 + 2725 + static void virtio_mem_deinit_kdump(struct virtio_mem *vm) 2726 + { 2727 + #ifdef CONFIG_PROC_VMCORE 2728 + unregister_vmcore_cb(&vm->vmcore_cb); 2729 + #endif /* CONFIG_PROC_VMCORE */ 2730 + } 2731 + 2732 + static void virtio_mem_remove(struct virtio_device *vdev) 2733 + { 2734 + struct virtio_mem *vm = vdev->priv; 2735 + 2736 + if (vm->in_kdump) 2737 + virtio_mem_deinit_kdump(vm); 2738 + else 2739 + virtio_mem_deinit_hotplug(vm); 2834 2740 2835 2741 /* reset the device and cleanup the queues */ 2836 2742 vdev->config->reset(vdev); ··· 2860 2732 static void virtio_mem_config_changed(struct virtio_device *vdev) 2861 2733 { 2862 2734 struct virtio_mem *vm = vdev->priv; 2735 + 2736 + if (unlikely(vm->in_kdump)) 2737 + return; 2863 2738 2864 2739 atomic_set(&vm->config_changed, 1); 2865 2740 virtio_mem_retry(vm);
+23 -10
fs/binfmt_elf.c
··· 156 156 #define STACK_ADD(sp, items) ((elf_addr_t __user *)(sp) - (items)) 157 157 #define STACK_ROUND(sp, items) \ 158 158 (((unsigned long) (sp - items)) &~ 15UL) 159 - #define STACK_ALLOC(sp, len) ({ sp -= len ; sp; }) 159 + #define STACK_ALLOC(sp, len) (sp -= len) 160 160 #endif 161 161 162 162 #ifndef ELF_BASE_PLATFORM ··· 1074 1074 1075 1075 vaddr = elf_ppnt->p_vaddr; 1076 1076 /* 1077 - * If we are loading ET_EXEC or we have already performed 1078 - * the ET_DYN load_addr calculations, proceed normally. 1077 + * The first time through the loop, load_addr_set is false: 1078 + * layout will be calculated. Once set, use MAP_FIXED since 1079 + * we know we've already safely mapped the entire region with 1080 + * MAP_FIXED_NOREPLACE in the once-per-binary logic following. 1079 1081 */ 1080 - if (elf_ex->e_type == ET_EXEC || load_addr_set) { 1082 + if (load_addr_set) { 1081 1083 elf_flags |= MAP_FIXED; 1084 + } else if (elf_ex->e_type == ET_EXEC) { 1085 + /* 1086 + * This logic is run once for the first LOAD Program 1087 + * Header for ET_EXEC binaries. No special handling 1088 + * is needed. 1089 + */ 1090 + elf_flags |= MAP_FIXED_NOREPLACE; 1082 1091 } else if (elf_ex->e_type == ET_DYN) { 1083 1092 /* 1084 1093 * This logic is run once for the first LOAD Program 1085 1094 * Header for ET_DYN binaries to calculate the 1086 1095 * randomization (load_bias) for all the LOAD 1087 - * Program Headers, and to calculate the entire 1088 - * size of the ELF mapping (total_size). (Note that 1089 - * load_addr_set is set to true later once the 1090 - * initial mapping is performed.) 1096 + * Program Headers. 1091 1097 * 1092 1098 * There are effectively two types of ET_DYN 1093 1099 * binaries: programs (i.e. PIE: ET_DYN with INTERP) ··· 1114 1108 * Therefore, programs are loaded offset from 1115 1109 * ELF_ET_DYN_BASE and loaders are loaded into the 1116 1110 * independently randomized mmap region (0 load_bias 1117 - * without MAP_FIXED). 1111 + * without MAP_FIXED nor MAP_FIXED_NOREPLACE). 1118 1112 */ 1119 1113 if (interpreter) { 1120 1114 load_bias = ELF_ET_DYN_BASE; ··· 1123 1117 alignment = maximum_alignment(elf_phdata, elf_ex->e_phnum); 1124 1118 if (alignment) 1125 1119 load_bias &= ~(alignment - 1); 1126 - elf_flags |= MAP_FIXED; 1120 + elf_flags |= MAP_FIXED_NOREPLACE; 1127 1121 } else 1128 1122 load_bias = 0; 1129 1123 ··· 1135 1129 * is then page aligned. 1136 1130 */ 1137 1131 load_bias = ELF_PAGESTART(load_bias - vaddr); 1132 + } 1138 1133 1134 + /* 1135 + * Calculate the entire size of the ELF mapping (total_size). 1136 + * (Note that load_addr_set is set to true later once the 1137 + * initial mapping is performed.) 1138 + */ 1139 + if (!load_addr_set) { 1139 1140 total_size = total_mapping_size(elf_phdata, 1140 1141 elf_ex->e_phnum); 1141 1142 if (!total_size) {
+9 -4
fs/coda/cnode.c
··· 63 63 struct inode *inode; 64 64 struct coda_inode_info *cii; 65 65 unsigned long hash = coda_f2i(fid); 66 + umode_t inode_type = coda_inode_type(attr); 66 67 68 + retry: 67 69 inode = iget5_locked(sb, hash, coda_test_inode, coda_set_inode, fid); 68 - 69 70 if (!inode) 70 71 return ERR_PTR(-ENOMEM); 71 72 ··· 76 75 inode->i_ino = hash; 77 76 /* inode is locked and unique, no need to grab cii->c_lock */ 78 77 cii->c_mapcount = 0; 78 + coda_fill_inode(inode, attr); 79 79 unlock_new_inode(inode); 80 + } else if ((inode->i_mode & S_IFMT) != inode_type) { 81 + /* Inode has changed type, mark bad and grab a new one */ 82 + remove_inode_hash(inode); 83 + coda_flag_inode(inode, C_PURGE); 84 + iput(inode); 85 + goto retry; 80 86 } 81 - 82 - /* always replace the attributes, type might have changed */ 83 - coda_fill_inode(inode, attr); 84 87 return inode; 85 88 } 86 89
+19 -20
fs/coda/coda_linux.c
··· 87 87 } 88 88 89 89 /* utility functions below */ 90 + umode_t coda_inode_type(struct coda_vattr *attr) 91 + { 92 + switch (attr->va_type) { 93 + case C_VREG: 94 + return S_IFREG; 95 + case C_VDIR: 96 + return S_IFDIR; 97 + case C_VLNK: 98 + return S_IFLNK; 99 + case C_VNON: 100 + default: 101 + return 0; 102 + } 103 + } 104 + 90 105 void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr) 91 106 { 92 - int inode_type; 93 - /* inode's i_flags, i_ino are set by iget 94 - XXX: is this all we need ?? 95 - */ 96 - switch (attr->va_type) { 97 - case C_VNON: 98 - inode_type = 0; 99 - break; 100 - case C_VREG: 101 - inode_type = S_IFREG; 102 - break; 103 - case C_VDIR: 104 - inode_type = S_IFDIR; 105 - break; 106 - case C_VLNK: 107 - inode_type = S_IFLNK; 108 - break; 109 - default: 110 - inode_type = 0; 111 - } 107 + /* inode's i_flags, i_ino are set by iget 108 + * XXX: is this all we need ?? 109 + */ 110 + umode_t inode_type = coda_inode_type(attr); 112 111 inode->i_mode |= inode_type; 113 112 114 113 if (attr->va_mode != (u_short) -1)
+5 -1
fs/coda/coda_linux.h
··· 53 53 u32, unsigned int); 54 54 int coda_setattr(struct user_namespace *, struct dentry *, struct iattr *); 55 55 56 - /* this file: heloers */ 56 + /* this file: helpers */ 57 57 char *coda_f2s(struct CodaFid *f); 58 58 int coda_iscontrol(const char *name, size_t length); 59 59 60 + umode_t coda_inode_type(struct coda_vattr *attr); 60 61 void coda_vattr_to_iattr(struct inode *, struct coda_vattr *); 61 62 void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *); 62 63 unsigned short coda_flags_to_cflags(unsigned short); ··· 83 82 static __inline__ void coda_flag_inode(struct inode *inode, int flag) 84 83 { 85 84 struct coda_inode_info *cii = ITOC(inode); 85 + 86 + if (!inode) 87 + return; 86 88 87 89 spin_lock(&cii->c_lock); 88 90 cii->c_flags |= flag;
+11 -9
fs/coda/dir.c
··· 317 317 coda_dir_drop_nlink(old_dir); 318 318 coda_dir_inc_nlink(new_dir); 319 319 } 320 - coda_dir_update_mtime(old_dir); 321 - coda_dir_update_mtime(new_dir); 322 320 coda_flag_inode(d_inode(new_dentry), C_VATTR); 323 - } else { 324 - coda_flag_inode(old_dir, C_VATTR); 325 - coda_flag_inode(new_dir, C_VATTR); 326 321 } 322 + coda_dir_update_mtime(old_dir); 323 + coda_dir_update_mtime(new_dir); 327 324 } 328 325 return error; 329 326 } ··· 496 499 */ 497 500 static int coda_dentry_delete(const struct dentry * dentry) 498 501 { 499 - int flags; 502 + struct inode *inode; 503 + struct coda_inode_info *cii; 500 504 501 505 if (d_really_is_negative(dentry)) 502 506 return 0; 503 507 504 - flags = (ITOC(d_inode(dentry))->c_flags) & C_PURGE; 505 - if (is_bad_inode(d_inode(dentry)) || flags) { 508 + inode = d_inode(dentry); 509 + if (!inode || is_bad_inode(inode)) 506 510 return 1; 507 - } 511 + 512 + cii = ITOC(inode); 513 + if (cii->c_flags & C_PURGE) 514 + return 1; 515 + 508 516 return 0; 509 517 } 510 518
+6 -6
fs/coda/file.c
··· 8 8 * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>. 9 9 */ 10 10 11 + #include <linux/refcount.h> 11 12 #include <linux/types.h> 12 13 #include <linux/kernel.h> 13 14 #include <linux/time.h> ··· 29 28 #include "coda_int.h" 30 29 31 30 struct coda_vm_ops { 32 - atomic_t refcnt; 31 + refcount_t refcnt; 33 32 struct file *coda_file; 34 33 const struct vm_operations_struct *host_vm_ops; 35 34 struct vm_operations_struct vm_ops; ··· 99 98 struct coda_vm_ops *cvm_ops = 100 99 container_of(vma->vm_ops, struct coda_vm_ops, vm_ops); 101 100 102 - atomic_inc(&cvm_ops->refcnt); 101 + refcount_inc(&cvm_ops->refcnt); 103 102 104 103 if (cvm_ops->host_vm_ops && cvm_ops->host_vm_ops->open) 105 104 cvm_ops->host_vm_ops->open(vma); ··· 114 113 if (cvm_ops->host_vm_ops && cvm_ops->host_vm_ops->close) 115 114 cvm_ops->host_vm_ops->close(vma); 116 115 117 - if (atomic_dec_and_test(&cvm_ops->refcnt)) { 116 + if (refcount_dec_and_test(&cvm_ops->refcnt)) { 118 117 vma->vm_ops = cvm_ops->host_vm_ops; 119 118 fput(cvm_ops->coda_file); 120 119 kfree(cvm_ops); ··· 190 189 cvm_ops->vm_ops.open = coda_vm_open; 191 190 cvm_ops->vm_ops.close = coda_vm_close; 192 191 cvm_ops->coda_file = coda_file; 193 - atomic_set(&cvm_ops->refcnt, 1); 192 + refcount_set(&cvm_ops->refcnt, 1); 194 193 195 194 vma->vm_ops = &cvm_ops->vm_ops; 196 195 } ··· 239 238 struct coda_file_info *cfi; 240 239 struct coda_inode_info *cii; 241 240 struct inode *host_inode; 242 - int err; 243 241 244 242 cfi = coda_ftoc(coda_file); 245 243 246 - err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode), 244 + venus_close(coda_inode->i_sb, coda_i2f(coda_inode), 247 245 coda_flags, coda_file->f_cred->fsuid); 248 246 249 247 host_inode = file_inode(cfi->cfi_container);
+5 -9
fs/coda/psdev.c
··· 122 122 hdr.opcode, hdr.unique); 123 123 nbytes = size; 124 124 } 125 - dcbuf = kvmalloc(nbytes, GFP_KERNEL); 126 - if (!dcbuf) { 127 - retval = -ENOMEM; 128 - goto out; 129 - } 130 - if (copy_from_user(dcbuf, buf, nbytes)) { 131 - kvfree(dcbuf); 132 - retval = -EFAULT; 125 + 126 + dcbuf = vmemdup_user(buf, nbytes); 127 + if (IS_ERR(dcbuf)) { 128 + retval = PTR_ERR(dcbuf); 133 129 goto out; 134 130 } 135 131 ··· 384 388 MODULE_DESCRIPTION("Coda Distributed File System VFS interface"); 385 389 MODULE_ALIAS_CHARDEV_MAJOR(CODA_PSDEV_MAJOR); 386 390 MODULE_LICENSE("GPL"); 387 - MODULE_VERSION("7.0"); 391 + MODULE_VERSION("7.2"); 388 392 389 393 static int __init init_coda(void) 390 394 {
+2 -1
fs/coda/upcall.c
··· 744 744 list_add_tail(&req->uc_chain, &vcp->vc_pending); 745 745 wake_up_interruptible(&vcp->vc_waitq); 746 746 747 - if (req->uc_flags & CODA_REQ_ASYNC) { 747 + /* We can return early on asynchronous requests */ 748 + if (outSize == NULL) { 748 749 mutex_unlock(&vcp->vc_mutex); 749 750 return 0; 750 751 }
+2 -4
fs/hfs/inode.c
··· 462 462 goto out; 463 463 464 464 if (S_ISDIR(main_inode->i_mode)) { 465 - if (fd.entrylength < sizeof(struct hfs_cat_dir)) 466 - /* panic? */; 465 + WARN_ON(fd.entrylength < sizeof(struct hfs_cat_dir)); 467 466 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, 468 467 sizeof(struct hfs_cat_dir)); 469 468 if (rec.type != HFS_CDR_DIR || ··· 482 483 hfs_bnode_write(fd.bnode, &rec, fd.entryoffset, 483 484 sizeof(struct hfs_cat_file)); 484 485 } else { 485 - if (fd.entrylength < sizeof(struct hfs_cat_file)) 486 - /* panic? */; 486 + WARN_ON(fd.entrylength < sizeof(struct hfs_cat_file)); 487 487 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, 488 488 sizeof(struct hfs_cat_file)); 489 489 if (rec.type != HFS_CDR_FIL ||
+4 -8
fs/hfsplus/inode.c
··· 509 509 if (type == HFSPLUS_FOLDER) { 510 510 struct hfsplus_cat_folder *folder = &entry.folder; 511 511 512 - if (fd->entrylength < sizeof(struct hfsplus_cat_folder)) 513 - /* panic? */; 512 + WARN_ON(fd->entrylength < sizeof(struct hfsplus_cat_folder)); 514 513 hfs_bnode_read(fd->bnode, &entry, fd->entryoffset, 515 514 sizeof(struct hfsplus_cat_folder)); 516 515 hfsplus_get_perms(inode, &folder->permissions, 1); ··· 529 530 } else if (type == HFSPLUS_FILE) { 530 531 struct hfsplus_cat_file *file = &entry.file; 531 532 532 - if (fd->entrylength < sizeof(struct hfsplus_cat_file)) 533 - /* panic? */; 533 + WARN_ON(fd->entrylength < sizeof(struct hfsplus_cat_file)); 534 534 hfs_bnode_read(fd->bnode, &entry, fd->entryoffset, 535 535 sizeof(struct hfsplus_cat_file)); 536 536 ··· 586 588 if (S_ISDIR(main_inode->i_mode)) { 587 589 struct hfsplus_cat_folder *folder = &entry.folder; 588 590 589 - if (fd.entrylength < sizeof(struct hfsplus_cat_folder)) 590 - /* panic? */; 591 + WARN_ON(fd.entrylength < sizeof(struct hfsplus_cat_folder)); 591 592 hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, 592 593 sizeof(struct hfsplus_cat_folder)); 593 594 /* simple node checks? */ ··· 611 614 } else { 612 615 struct hfsplus_cat_file *file = &entry.file; 613 616 614 - if (fd.entrylength < sizeof(struct hfsplus_cat_file)) 615 - /* panic? */; 617 + WARN_ON(fd.entrylength < sizeof(struct hfsplus_cat_file)); 616 618 hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, 617 619 sizeof(struct hfsplus_cat_file)); 618 620 hfsplus_inode_write_fork(inode, &file->data_fork);
+8 -15
fs/hugetlbfs/inode.c
··· 1446 1446 * otherwise hugetlb_reserve_pages reserves one less hugepages than intended. 1447 1447 */ 1448 1448 struct file *hugetlb_file_setup(const char *name, size_t size, 1449 - vm_flags_t acctflag, struct ucounts **ucounts, 1450 - int creat_flags, int page_size_log) 1449 + vm_flags_t acctflag, int creat_flags, 1450 + int page_size_log) 1451 1451 { 1452 1452 struct inode *inode; 1453 1453 struct vfsmount *mnt; ··· 1458 1458 if (hstate_idx < 0) 1459 1459 return ERR_PTR(-ENODEV); 1460 1460 1461 - *ucounts = NULL; 1462 1461 mnt = hugetlbfs_vfsmount[hstate_idx]; 1463 1462 if (!mnt) 1464 1463 return ERR_PTR(-ENOENT); 1465 1464 1466 1465 if (creat_flags == HUGETLB_SHMFS_INODE && !can_do_hugetlb_shm()) { 1467 - *ucounts = current_ucounts(); 1468 - if (user_shm_lock(size, *ucounts)) { 1469 - task_lock(current); 1470 - pr_warn_once("%s (%d): Using mlock ulimits for SHM_HUGETLB is deprecated\n", 1466 + struct ucounts *ucounts = current_ucounts(); 1467 + 1468 + if (user_shm_lock(size, ucounts)) { 1469 + pr_warn_once("%s (%d): Using mlock ulimits for SHM_HUGETLB is obsolete\n", 1471 1470 current->comm, current->pid); 1472 - task_unlock(current); 1473 - } else { 1474 - *ucounts = NULL; 1475 - return ERR_PTR(-EPERM); 1471 + user_shm_unlock(size, ucounts); 1476 1472 } 1473 + return ERR_PTR(-EPERM); 1477 1474 } 1478 1475 1479 1476 file = ERR_PTR(-ENOSPC); ··· 1495 1498 1496 1499 iput(inode); 1497 1500 out: 1498 - if (*ucounts) { 1499 - user_shm_unlock(size, *ucounts); 1500 - *ucounts = NULL; 1501 - } 1502 1501 return file; 1503 1502 } 1504 1503
+27 -19
fs/inode.c
··· 428 428 } 429 429 EXPORT_SYMBOL(ihold); 430 430 431 - static void inode_lru_list_add(struct inode *inode) 431 + static void __inode_add_lru(struct inode *inode, bool rotate) 432 432 { 433 + if (inode->i_state & (I_DIRTY_ALL | I_SYNC | I_FREEING | I_WILL_FREE)) 434 + return; 435 + if (atomic_read(&inode->i_count)) 436 + return; 437 + if (!(inode->i_sb->s_flags & SB_ACTIVE)) 438 + return; 439 + if (!mapping_shrinkable(&inode->i_data)) 440 + return; 441 + 433 442 if (list_lru_add(&inode->i_sb->s_inode_lru, &inode->i_lru)) 434 443 this_cpu_inc(nr_unused); 435 - else 444 + else if (rotate) 436 445 inode->i_state |= I_REFERENCED; 437 446 } 438 447 ··· 452 443 */ 453 444 void inode_add_lru(struct inode *inode) 454 445 { 455 - if (!(inode->i_state & (I_DIRTY_ALL | I_SYNC | 456 - I_FREEING | I_WILL_FREE)) && 457 - !atomic_read(&inode->i_count) && inode->i_sb->s_flags & SB_ACTIVE) 458 - inode_lru_list_add(inode); 446 + __inode_add_lru(inode, false); 459 447 } 460 - 461 448 462 449 static void inode_lru_list_del(struct inode *inode) 463 450 { 464 - 465 451 if (list_lru_del(&inode->i_sb->s_inode_lru, &inode->i_lru)) 466 452 this_cpu_dec(nr_unused); 467 453 } ··· 732 728 /* 733 729 * Isolate the inode from the LRU in preparation for freeing it. 734 730 * 735 - * Any inodes which are pinned purely because of attached pagecache have their 736 - * pagecache removed. If the inode has metadata buffers attached to 737 - * mapping->private_list then try to remove them. 738 - * 739 731 * If the inode has the I_REFERENCED flag set, then it means that it has been 740 732 * used recently - the flag is set in iput_final(). When we encounter such an 741 733 * inode, clear the flag and move it to the back of the LRU so it gets another ··· 747 747 struct inode *inode = container_of(item, struct inode, i_lru); 748 748 749 749 /* 750 - * we are inverting the lru lock/inode->i_lock here, so use a trylock. 751 - * If we fail to get the lock, just skip it. 750 + * We are inverting the lru lock/inode->i_lock here, so use a 751 + * trylock. If we fail to get the lock, just skip it. 752 752 */ 753 753 if (!spin_trylock(&inode->i_lock)) 754 754 return LRU_SKIP; 755 755 756 756 /* 757 - * Referenced or dirty inodes are still in use. Give them another pass 758 - * through the LRU as we canot reclaim them now. 757 + * Inodes can get referenced, redirtied, or repopulated while 758 + * they're already on the LRU, and this can make them 759 + * unreclaimable for a while. Remove them lazily here; iput, 760 + * sync, or the last page cache deletion will requeue them. 759 761 */ 760 762 if (atomic_read(&inode->i_count) || 761 - (inode->i_state & ~I_REFERENCED)) { 763 + (inode->i_state & ~I_REFERENCED) || 764 + !mapping_shrinkable(&inode->i_data)) { 762 765 list_lru_isolate(lru, &inode->i_lru); 763 766 spin_unlock(&inode->i_lock); 764 767 this_cpu_dec(nr_unused); 765 768 return LRU_REMOVED; 766 769 } 767 770 768 - /* recently referenced inodes get one more pass */ 771 + /* Recently referenced inodes get one more pass */ 769 772 if (inode->i_state & I_REFERENCED) { 770 773 inode->i_state &= ~I_REFERENCED; 771 774 spin_unlock(&inode->i_lock); 772 775 return LRU_ROTATE; 773 776 } 774 777 778 + /* 779 + * On highmem systems, mapping_shrinkable() permits dropping 780 + * page cache in order to free up struct inodes: lowmem might 781 + * be under pressure before the cache inside the highmem zone. 782 + */ 775 783 if (inode_has_buffers(inode) || !mapping_empty(&inode->i_data)) { 776 784 __iget(inode); 777 785 spin_unlock(&inode->i_lock); ··· 1646 1638 if (!drop && 1647 1639 !(inode->i_state & I_DONTCACHE) && 1648 1640 (sb->s_flags & SB_ACTIVE)) { 1649 - inode_add_lru(inode); 1641 + __inode_add_lru(inode, true); 1650 1642 spin_unlock(&inode->i_lock); 1651 1643 return; 1652 1644 }
-1
fs/internal.h
··· 138 138 * inode.c 139 139 */ 140 140 extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc); 141 - extern void inode_add_lru(struct inode *inode); 142 141 extern int dentry_needs_remove_privs(struct dentry *dentry); 143 142 144 143 /*
+1 -1
fs/nilfs2/alloc.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * alloc.c - NILFS dat/inode allocator 3 + * NILFS dat/inode allocator 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/alloc.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * alloc.h - persistent object (dat entry/disk inode) allocator/deallocator 3 + * Persistent object (dat entry/disk inode) allocator/deallocator 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/bmap.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * bmap.c - NILFS block mapping. 3 + * NILFS block mapping. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/bmap.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * bmap.h - NILFS block mapping. 3 + * NILFS block mapping. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/btnode.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * btnode.c - NILFS B-tree node cache 3 + * NILFS B-tree node cache 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/btnode.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * btnode.h - NILFS B-tree node cache 3 + * NILFS B-tree node cache 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/btree.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * btree.c - NILFS B-tree. 3 + * NILFS B-tree. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/btree.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * btree.h - NILFS B-tree. 3 + * NILFS B-tree. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/cpfile.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * cpfile.c - NILFS checkpoint file. 3 + * NILFS checkpoint file. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/cpfile.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * cpfile.h - NILFS checkpoint file. 3 + * NILFS checkpoint file. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/dat.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * dat.c - NILFS disk address translation. 3 + * NILFS disk address translation. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/dat.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * dat.h - NILFS disk address translation. 3 + * NILFS disk address translation. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/dir.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * dir.c - NILFS directory entry operations 3 + * NILFS directory entry operations 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/direct.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * direct.c - NILFS direct block pointer. 3 + * NILFS direct block pointer. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/direct.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * direct.h - NILFS direct block pointer. 3 + * NILFS direct block pointer. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/file.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * file.c - NILFS regular file handling primitives including fsync(). 3 + * NILFS regular file handling primitives including fsync(). 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/gcinode.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * gcinode.c - dummy inodes to buffer blocks for garbage collection 3 + * Dummy inodes to buffer blocks for garbage collection 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/ifile.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * ifile.c - NILFS inode file 3 + * NILFS inode file 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/ifile.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * ifile.h - NILFS inode file 3 + * NILFS inode file 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/inode.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * inode.c - NILFS inode operations. 3 + * NILFS inode operations. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/ioctl.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * ioctl.c - NILFS ioctl operations. 3 + * NILFS ioctl operations. 4 4 * 5 5 * Copyright (C) 2007, 2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/mdt.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * mdt.c - meta data file for NILFS 3 + * Meta data file for NILFS 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/mdt.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * mdt.h - NILFS meta data file prototype and definitions 3 + * NILFS meta data file prototype and definitions 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/namei.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * namei.c - NILFS pathname lookup operations. 3 + * NILFS pathname lookup operations. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/nilfs.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * nilfs.h - NILFS local header file. 3 + * NILFS local header file. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/page.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * page.c - buffer/page management specific to NILFS 3 + * Buffer/page management specific to NILFS 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/page.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * page.h - buffer/page management specific to NILFS 3 + * Buffer/page management specific to NILFS 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/recovery.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * recovery.c - NILFS recovery logic 3 + * NILFS recovery logic 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/segbuf.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * segbuf.c - NILFS segment buffer 3 + * NILFS segment buffer 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/segbuf.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * segbuf.h - NILFS Segment buffer prototypes and definitions 3 + * NILFS Segment buffer prototypes and definitions 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/segment.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * segment.c - NILFS segment constructor. 3 + * NILFS segment constructor. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/segment.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * segment.h - NILFS Segment constructor prototypes and definitions 3 + * NILFS Segment constructor prototypes and definitions 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/sufile.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * sufile.c - NILFS segment usage file. 3 + * NILFS segment usage file. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/sufile.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * sufile.h - NILFS segment usage file. 3 + * NILFS segment usage file. 4 4 * 5 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/super.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * super.c - NILFS module and super block management. 3 + * NILFS module and super block management. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+39 -39
fs/nilfs2/sysfs.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * sysfs.c - sysfs support implementation. 3 + * Sysfs support implementation. 4 4 * 5 5 * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation. 6 6 * Copyright (C) 2014 HGST, Inc., a Western Digital Company. ··· 95 95 nilfs_snapshot_inodes_count_show(struct nilfs_snapshot_attr *attr, 96 96 struct nilfs_root *root, char *buf) 97 97 { 98 - return snprintf(buf, PAGE_SIZE, "%llu\n", 98 + return sysfs_emit(buf, "%llu\n", 99 99 (unsigned long long)atomic64_read(&root->inodes_count)); 100 100 } 101 101 ··· 103 103 nilfs_snapshot_blocks_count_show(struct nilfs_snapshot_attr *attr, 104 104 struct nilfs_root *root, char *buf) 105 105 { 106 - return snprintf(buf, PAGE_SIZE, "%llu\n", 106 + return sysfs_emit(buf, "%llu\n", 107 107 (unsigned long long)atomic64_read(&root->blocks_count)); 108 108 } 109 109 ··· 116 116 nilfs_snapshot_README_show(struct nilfs_snapshot_attr *attr, 117 117 struct nilfs_root *root, char *buf) 118 118 { 119 - return snprintf(buf, PAGE_SIZE, snapshot_readme_str); 119 + return sysfs_emit(buf, snapshot_readme_str); 120 120 } 121 121 122 122 NILFS_SNAPSHOT_RO_ATTR(inodes_count); ··· 217 217 nilfs_mounted_snapshots_README_show(struct nilfs_mounted_snapshots_attr *attr, 218 218 struct the_nilfs *nilfs, char *buf) 219 219 { 220 - return snprintf(buf, PAGE_SIZE, mounted_snapshots_readme_str); 220 + return sysfs_emit(buf, mounted_snapshots_readme_str); 221 221 } 222 222 223 223 NILFS_MOUNTED_SNAPSHOTS_RO_ATTR(README); ··· 255 255 256 256 ncheckpoints = cpstat.cs_ncps; 257 257 258 - return snprintf(buf, PAGE_SIZE, "%llu\n", ncheckpoints); 258 + return sysfs_emit(buf, "%llu\n", ncheckpoints); 259 259 } 260 260 261 261 static ssize_t ··· 278 278 279 279 nsnapshots = cpstat.cs_nsss; 280 280 281 - return snprintf(buf, PAGE_SIZE, "%llu\n", nsnapshots); 281 + return sysfs_emit(buf, "%llu\n", nsnapshots); 282 282 } 283 283 284 284 static ssize_t ··· 292 292 last_cno = nilfs->ns_last_cno; 293 293 spin_unlock(&nilfs->ns_last_segment_lock); 294 294 295 - return snprintf(buf, PAGE_SIZE, "%llu\n", last_cno); 295 + return sysfs_emit(buf, "%llu\n", last_cno); 296 296 } 297 297 298 298 static ssize_t ··· 306 306 cno = nilfs->ns_cno; 307 307 up_read(&nilfs->ns_segctor_sem); 308 308 309 - return snprintf(buf, PAGE_SIZE, "%llu\n", cno); 309 + return sysfs_emit(buf, "%llu\n", cno); 310 310 } 311 311 312 312 static const char checkpoints_readme_str[] = ··· 322 322 nilfs_checkpoints_README_show(struct nilfs_checkpoints_attr *attr, 323 323 struct the_nilfs *nilfs, char *buf) 324 324 { 325 - return snprintf(buf, PAGE_SIZE, checkpoints_readme_str); 325 + return sysfs_emit(buf, checkpoints_readme_str); 326 326 } 327 327 328 328 NILFS_CHECKPOINTS_RO_ATTR(checkpoints_number); ··· 353 353 struct the_nilfs *nilfs, 354 354 char *buf) 355 355 { 356 - return snprintf(buf, PAGE_SIZE, "%lu\n", nilfs->ns_nsegments); 356 + return sysfs_emit(buf, "%lu\n", nilfs->ns_nsegments); 357 357 } 358 358 359 359 static ssize_t ··· 361 361 struct the_nilfs *nilfs, 362 362 char *buf) 363 363 { 364 - return snprintf(buf, PAGE_SIZE, "%lu\n", nilfs->ns_blocks_per_segment); 364 + return sysfs_emit(buf, "%lu\n", nilfs->ns_blocks_per_segment); 365 365 } 366 366 367 367 static ssize_t ··· 375 375 ncleansegs = nilfs_sufile_get_ncleansegs(nilfs->ns_sufile); 376 376 up_read(&NILFS_MDT(nilfs->ns_dat)->mi_sem); 377 377 378 - return snprintf(buf, PAGE_SIZE, "%lu\n", ncleansegs); 378 + return sysfs_emit(buf, "%lu\n", ncleansegs); 379 379 } 380 380 381 381 static ssize_t ··· 395 395 return err; 396 396 } 397 397 398 - return snprintf(buf, PAGE_SIZE, "%llu\n", sustat.ss_ndirtysegs); 398 + return sysfs_emit(buf, "%llu\n", sustat.ss_ndirtysegs); 399 399 } 400 400 401 401 static const char segments_readme_str[] = ··· 411 411 struct the_nilfs *nilfs, 412 412 char *buf) 413 413 { 414 - return snprintf(buf, PAGE_SIZE, segments_readme_str); 414 + return sysfs_emit(buf, segments_readme_str); 415 415 } 416 416 417 417 NILFS_SEGMENTS_RO_ATTR(segments_number); ··· 448 448 last_pseg = nilfs->ns_last_pseg; 449 449 spin_unlock(&nilfs->ns_last_segment_lock); 450 450 451 - return snprintf(buf, PAGE_SIZE, "%llu\n", 451 + return sysfs_emit(buf, "%llu\n", 452 452 (unsigned long long)last_pseg); 453 453 } 454 454 ··· 463 463 last_seq = nilfs->ns_last_seq; 464 464 spin_unlock(&nilfs->ns_last_segment_lock); 465 465 466 - return snprintf(buf, PAGE_SIZE, "%llu\n", last_seq); 466 + return sysfs_emit(buf, "%llu\n", last_seq); 467 467 } 468 468 469 469 static ssize_t ··· 477 477 last_cno = nilfs->ns_last_cno; 478 478 spin_unlock(&nilfs->ns_last_segment_lock); 479 479 480 - return snprintf(buf, PAGE_SIZE, "%llu\n", last_cno); 480 + return sysfs_emit(buf, "%llu\n", last_cno); 481 481 } 482 482 483 483 static ssize_t ··· 491 491 seg_seq = nilfs->ns_seg_seq; 492 492 up_read(&nilfs->ns_segctor_sem); 493 493 494 - return snprintf(buf, PAGE_SIZE, "%llu\n", seg_seq); 494 + return sysfs_emit(buf, "%llu\n", seg_seq); 495 495 } 496 496 497 497 static ssize_t ··· 505 505 segnum = nilfs->ns_segnum; 506 506 up_read(&nilfs->ns_segctor_sem); 507 507 508 - return snprintf(buf, PAGE_SIZE, "%llu\n", segnum); 508 + return sysfs_emit(buf, "%llu\n", segnum); 509 509 } 510 510 511 511 static ssize_t ··· 519 519 nextnum = nilfs->ns_nextnum; 520 520 up_read(&nilfs->ns_segctor_sem); 521 521 522 - return snprintf(buf, PAGE_SIZE, "%llu\n", nextnum); 522 + return sysfs_emit(buf, "%llu\n", nextnum); 523 523 } 524 524 525 525 static ssize_t ··· 533 533 pseg_offset = nilfs->ns_pseg_offset; 534 534 up_read(&nilfs->ns_segctor_sem); 535 535 536 - return snprintf(buf, PAGE_SIZE, "%lu\n", pseg_offset); 536 + return sysfs_emit(buf, "%lu\n", pseg_offset); 537 537 } 538 538 539 539 static ssize_t ··· 547 547 cno = nilfs->ns_cno; 548 548 up_read(&nilfs->ns_segctor_sem); 549 549 550 - return snprintf(buf, PAGE_SIZE, "%llu\n", cno); 550 + return sysfs_emit(buf, "%llu\n", cno); 551 551 } 552 552 553 553 static ssize_t ··· 575 575 ctime = nilfs->ns_ctime; 576 576 up_read(&nilfs->ns_segctor_sem); 577 577 578 - return snprintf(buf, PAGE_SIZE, "%llu\n", ctime); 578 + return sysfs_emit(buf, "%llu\n", ctime); 579 579 } 580 580 581 581 static ssize_t ··· 603 603 nongc_ctime = nilfs->ns_nongc_ctime; 604 604 up_read(&nilfs->ns_segctor_sem); 605 605 606 - return snprintf(buf, PAGE_SIZE, "%llu\n", nongc_ctime); 606 + return sysfs_emit(buf, "%llu\n", nongc_ctime); 607 607 } 608 608 609 609 static ssize_t ··· 617 617 ndirtyblks = atomic_read(&nilfs->ns_ndirtyblks); 618 618 up_read(&nilfs->ns_segctor_sem); 619 619 620 - return snprintf(buf, PAGE_SIZE, "%u\n", ndirtyblks); 620 + return sysfs_emit(buf, "%u\n", ndirtyblks); 621 621 } 622 622 623 623 static const char segctor_readme_str[] = ··· 654 654 nilfs_segctor_README_show(struct nilfs_segctor_attr *attr, 655 655 struct the_nilfs *nilfs, char *buf) 656 656 { 657 - return snprintf(buf, PAGE_SIZE, segctor_readme_str); 657 + return sysfs_emit(buf, segctor_readme_str); 658 658 } 659 659 660 660 NILFS_SEGCTOR_RO_ATTR(last_pseg_block); ··· 723 723 sbwtime = nilfs->ns_sbwtime; 724 724 up_read(&nilfs->ns_sem); 725 725 726 - return snprintf(buf, PAGE_SIZE, "%llu\n", sbwtime); 726 + return sysfs_emit(buf, "%llu\n", sbwtime); 727 727 } 728 728 729 729 static ssize_t ··· 737 737 sbwcount = nilfs->ns_sbwcount; 738 738 up_read(&nilfs->ns_sem); 739 739 740 - return snprintf(buf, PAGE_SIZE, "%u\n", sbwcount); 740 + return sysfs_emit(buf, "%u\n", sbwcount); 741 741 } 742 742 743 743 static ssize_t ··· 751 751 sb_update_freq = nilfs->ns_sb_update_freq; 752 752 up_read(&nilfs->ns_sem); 753 753 754 - return snprintf(buf, PAGE_SIZE, "%u\n", sb_update_freq); 754 + return sysfs_emit(buf, "%u\n", sb_update_freq); 755 755 } 756 756 757 757 static ssize_t ··· 799 799 nilfs_superblock_README_show(struct nilfs_superblock_attr *attr, 800 800 struct the_nilfs *nilfs, char *buf) 801 801 { 802 - return snprintf(buf, PAGE_SIZE, sb_readme_str); 802 + return sysfs_emit(buf, sb_readme_str); 803 803 } 804 804 805 805 NILFS_SUPERBLOCK_RO_ATTR(sb_write_time); ··· 834 834 u32 major = le32_to_cpu(sbp[0]->s_rev_level); 835 835 u16 minor = le16_to_cpu(sbp[0]->s_minor_rev_level); 836 836 837 - return snprintf(buf, PAGE_SIZE, "%d.%d\n", major, minor); 837 + return sysfs_emit(buf, "%d.%d\n", major, minor); 838 838 } 839 839 840 840 static ··· 842 842 struct the_nilfs *nilfs, 843 843 char *buf) 844 844 { 845 - return snprintf(buf, PAGE_SIZE, "%u\n", nilfs->ns_blocksize); 845 + return sysfs_emit(buf, "%u\n", nilfs->ns_blocksize); 846 846 } 847 847 848 848 static ··· 853 853 struct nilfs_super_block **sbp = nilfs->ns_sbp; 854 854 u64 dev_size = le64_to_cpu(sbp[0]->s_dev_size); 855 855 856 - return snprintf(buf, PAGE_SIZE, "%llu\n", dev_size); 856 + return sysfs_emit(buf, "%llu\n", dev_size); 857 857 } 858 858 859 859 static ··· 864 864 sector_t free_blocks = 0; 865 865 866 866 nilfs_count_free_blocks(nilfs, &free_blocks); 867 - return snprintf(buf, PAGE_SIZE, "%llu\n", 867 + return sysfs_emit(buf, "%llu\n", 868 868 (unsigned long long)free_blocks); 869 869 } 870 870 ··· 875 875 { 876 876 struct nilfs_super_block **sbp = nilfs->ns_sbp; 877 877 878 - return snprintf(buf, PAGE_SIZE, "%pUb\n", sbp[0]->s_uuid); 878 + return sysfs_emit(buf, "%pUb\n", sbp[0]->s_uuid); 879 879 } 880 880 881 881 static ··· 903 903 struct the_nilfs *nilfs, 904 904 char *buf) 905 905 { 906 - return snprintf(buf, PAGE_SIZE, dev_readme_str); 906 + return sysfs_emit(buf, dev_readme_str); 907 907 } 908 908 909 909 NILFS_DEV_RO_ATTR(revision); ··· 1047 1047 static ssize_t nilfs_feature_revision_show(struct kobject *kobj, 1048 1048 struct attribute *attr, char *buf) 1049 1049 { 1050 - return snprintf(buf, PAGE_SIZE, "%d.%d\n", 1050 + return sysfs_emit(buf, "%d.%d\n", 1051 1051 NILFS_CURRENT_REV, NILFS_MINOR_REV); 1052 1052 } 1053 1053 ··· 1060 1060 struct attribute *attr, 1061 1061 char *buf) 1062 1062 { 1063 - return snprintf(buf, PAGE_SIZE, features_readme_str); 1063 + return sysfs_emit(buf, features_readme_str); 1064 1064 } 1065 1065 1066 1066 NILFS_FEATURE_RO_ATTR(revision);
+1 -1
fs/nilfs2/sysfs.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * sysfs.h - sysfs support declarations. 3 + * Sysfs support declarations. 4 4 * 5 5 * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation. 6 6 * Copyright (C) 2014 HGST, Inc., a Western Digital Company.
+1 -1
fs/nilfs2/the_nilfs.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 - * the_nilfs.c - the_nilfs shared structure. 3 + * the_nilfs shared structure. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+1 -1
fs/nilfs2/the_nilfs.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 - * the_nilfs.h - the_nilfs shared structure. 3 + * the_nilfs shared structure. 4 4 * 5 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 6 6 *
+13 -8
fs/proc/base.c
··· 1982 1982 { 1983 1983 struct inode *inode; 1984 1984 struct task_struct *task; 1985 + int ret = 0; 1985 1986 1986 - if (flags & LOOKUP_RCU) 1987 - return -ECHILD; 1988 - 1989 - inode = d_inode(dentry); 1990 - task = get_proc_task(inode); 1987 + rcu_read_lock(); 1988 + inode = d_inode_rcu(dentry); 1989 + if (!inode) 1990 + goto out; 1991 + task = pid_task(proc_pid(inode), PIDTYPE_PID); 1991 1992 1992 1993 if (task) { 1993 1994 pid_update_inode(task, inode); 1994 - put_task_struct(task); 1995 - return 1; 1995 + ret = 1; 1996 1996 } 1997 - return 0; 1997 + out: 1998 + rcu_read_unlock(); 1999 + return ret; 1998 2000 } 1999 2001 2000 2002 static inline bool proc_inode_is_dead(struct inode *inode) ··· 3804 3802 task = next_tid(task), ctx->pos++) { 3805 3803 char name[10 + 1]; 3806 3804 unsigned int len; 3805 + 3807 3806 tid = task_pid_nr_ns(task, ns); 3807 + if (!tid) 3808 + continue; /* The task has just exited. */ 3808 3809 len = snprintf(name, sizeof(name), "%u", tid); 3809 3810 if (!proc_fill_cache(file, ctx, name, len, 3810 3811 proc_task_instantiate, task, NULL)) {
+76 -37
fs/proc/vmcore.c
··· 62 62 /* Device Dump Size */ 63 63 static size_t vmcoredd_orig_sz; 64 64 65 - /* 66 - * Returns > 0 for RAM pages, 0 for non-RAM pages, < 0 on error 67 - * The called function has to take care of module refcounting. 68 - */ 69 - static int (*oldmem_pfn_is_ram)(unsigned long pfn); 65 + static DECLARE_RWSEM(vmcore_cb_rwsem); 66 + /* List of registered vmcore callbacks. */ 67 + static LIST_HEAD(vmcore_cb_list); 68 + /* Whether we had a surprise unregistration of a callback. */ 69 + static bool vmcore_cb_unstable; 70 + /* Whether the vmcore has been opened once. */ 71 + static bool vmcore_opened; 70 72 71 - int register_oldmem_pfn_is_ram(int (*fn)(unsigned long pfn)) 73 + void register_vmcore_cb(struct vmcore_cb *cb) 72 74 { 73 - if (oldmem_pfn_is_ram) 74 - return -EBUSY; 75 - oldmem_pfn_is_ram = fn; 76 - return 0; 77 - } 78 - EXPORT_SYMBOL_GPL(register_oldmem_pfn_is_ram); 79 - 80 - void unregister_oldmem_pfn_is_ram(void) 81 - { 82 - oldmem_pfn_is_ram = NULL; 83 - wmb(); 84 - } 85 - EXPORT_SYMBOL_GPL(unregister_oldmem_pfn_is_ram); 86 - 87 - static int pfn_is_ram(unsigned long pfn) 88 - { 89 - int (*fn)(unsigned long pfn); 90 - /* pfn is ram unless fn() checks pagetype */ 91 - int ret = 1; 92 - 75 + down_write(&vmcore_cb_rwsem); 76 + INIT_LIST_HEAD(&cb->next); 77 + list_add_tail(&cb->next, &vmcore_cb_list); 93 78 /* 94 - * Ask hypervisor if the pfn is really ram. 95 - * A ballooned page contains no data and reading from such a page 96 - * will cause high load in the hypervisor. 79 + * Registering a vmcore callback after the vmcore was opened is 80 + * very unusual (e.g., manual driver loading). 97 81 */ 98 - fn = oldmem_pfn_is_ram; 99 - if (fn) 100 - ret = fn(pfn); 82 + if (vmcore_opened) 83 + pr_warn_once("Unexpected vmcore callback registration\n"); 84 + up_write(&vmcore_cb_rwsem); 85 + } 86 + EXPORT_SYMBOL_GPL(register_vmcore_cb); 87 + 88 + void unregister_vmcore_cb(struct vmcore_cb *cb) 89 + { 90 + down_write(&vmcore_cb_rwsem); 91 + list_del(&cb->next); 92 + /* 93 + * Unregistering a vmcore callback after the vmcore was opened is 94 + * very unusual (e.g., forced driver removal), but we cannot stop 95 + * unregistering. 96 + */ 97 + if (vmcore_opened) { 98 + pr_warn_once("Unexpected vmcore callback unregistration\n"); 99 + vmcore_cb_unstable = true; 100 + } 101 + up_write(&vmcore_cb_rwsem); 102 + } 103 + EXPORT_SYMBOL_GPL(unregister_vmcore_cb); 104 + 105 + static bool pfn_is_ram(unsigned long pfn) 106 + { 107 + struct vmcore_cb *cb; 108 + bool ret = true; 109 + 110 + lockdep_assert_held_read(&vmcore_cb_rwsem); 111 + if (unlikely(vmcore_cb_unstable)) 112 + return false; 113 + 114 + list_for_each_entry(cb, &vmcore_cb_list, next) { 115 + if (unlikely(!cb->pfn_is_ram)) 116 + continue; 117 + ret = cb->pfn_is_ram(cb, pfn); 118 + if (!ret) 119 + break; 120 + } 101 121 102 122 return ret; 123 + } 124 + 125 + static int open_vmcore(struct inode *inode, struct file *file) 126 + { 127 + down_read(&vmcore_cb_rwsem); 128 + vmcore_opened = true; 129 + up_read(&vmcore_cb_rwsem); 130 + 131 + return 0; 103 132 } 104 133 105 134 /* Reads a page from the oldmem device from given offset. */ ··· 146 117 offset = (unsigned long)(*ppos % PAGE_SIZE); 147 118 pfn = (unsigned long)(*ppos / PAGE_SIZE); 148 119 120 + down_read(&vmcore_cb_rwsem); 149 121 do { 150 122 if (count > (PAGE_SIZE - offset)) 151 123 nr_bytes = PAGE_SIZE - offset; ··· 154 124 nr_bytes = count; 155 125 156 126 /* If pfn is not ram, return zeros for sparse dump files */ 157 - if (pfn_is_ram(pfn) == 0) 127 + if (!pfn_is_ram(pfn)) 158 128 memset(buf, 0, nr_bytes); 159 129 else { 160 130 if (encrypted) ··· 166 136 tmp = copy_oldmem_page(pfn, buf, nr_bytes, 167 137 offset, userbuf); 168 138 169 - if (tmp < 0) 139 + if (tmp < 0) { 140 + up_read(&vmcore_cb_rwsem); 170 141 return tmp; 142 + } 171 143 } 172 144 *ppos += nr_bytes; 173 145 count -= nr_bytes; ··· 179 147 offset = 0; 180 148 } while (count); 181 149 150 + up_read(&vmcore_cb_rwsem); 182 151 return read; 183 152 } 184 153 ··· 570 537 unsigned long from, unsigned long pfn, 571 538 unsigned long size, pgprot_t prot) 572 539 { 540 + int ret; 541 + 573 542 /* 574 543 * Check if oldmem_pfn_is_ram was registered to avoid 575 544 * looping over all pages without a reason. 576 545 */ 577 - if (oldmem_pfn_is_ram) 578 - return remap_oldmem_pfn_checked(vma, from, pfn, size, prot); 546 + down_read(&vmcore_cb_rwsem); 547 + if (!list_empty(&vmcore_cb_list) || vmcore_cb_unstable) 548 + ret = remap_oldmem_pfn_checked(vma, from, pfn, size, prot); 579 549 else 580 - return remap_oldmem_pfn_range(vma, from, pfn, size, prot); 550 + ret = remap_oldmem_pfn_range(vma, from, pfn, size, prot); 551 + up_read(&vmcore_cb_rwsem); 552 + return ret; 581 553 } 582 554 583 555 static int mmap_vmcore(struct file *file, struct vm_area_struct *vma) ··· 706 668 #endif 707 669 708 670 static const struct proc_ops vmcore_proc_ops = { 671 + .proc_open = open_vmcore, 709 672 .proc_read = read_vmcore, 710 673 .proc_lseek = default_llseek, 711 674 .proc_mmap = mmap_vmcore,
+7 -4
fs/ramfs/inode.c
··· 204 204 int opt; 205 205 206 206 opt = fs_parse(fc, ramfs_fs_parameters, param, &result); 207 - if (opt < 0) { 207 + if (opt == -ENOPARAM) { 208 + opt = vfs_parse_fs_param_source(fc, param); 209 + if (opt != -ENOPARAM) 210 + return opt; 208 211 /* 209 212 * We might like to report bad mount options here; 210 213 * but traditionally ramfs has ignored all mount options, 211 214 * and as it is used as a !CONFIG_SHMEM simple substitute 212 215 * for tmpfs, better continue to ignore other mount options. 213 216 */ 214 - if (opt == -ENOPARAM) 215 - opt = 0; 216 - return opt; 217 + return 0; 217 218 } 219 + if (opt < 0) 220 + return opt; 218 221 219 222 switch (opt) { 220 223 case Opt_mode:
-16
fs/seq_file.c
··· 383 383 } 384 384 EXPORT_SYMBOL(seq_escape_mem); 385 385 386 - /** 387 - * seq_escape - print string into buffer, escaping some characters 388 - * @m: target buffer 389 - * @s: string 390 - * @esc: set of characters that need escaping 391 - * 392 - * Puts string into buffer, replacing each occurrence of character from 393 - * @esc with usual octal escape. 394 - * Use seq_has_overflowed() to check for errors. 395 - */ 396 - void seq_escape(struct seq_file *m, const char *s, const char *esc) 397 - { 398 - seq_escape_str(m, s, ESCAPE_OCTAL, esc); 399 - } 400 - EXPORT_SYMBOL(seq_escape); 401 - 402 386 void seq_vprintf(struct seq_file *m, const char *f, va_list args) 403 387 { 404 388 int len;
+2 -4
fs/sysv/super.c
··· 474 474 struct sysv_sb_info *sbi; 475 475 struct buffer_head *bh; 476 476 477 - if (440 != sizeof (struct v7_super_block)) 478 - panic("V7 FS: bad super-block size"); 479 - if (64 != sizeof (struct sysv_inode)) 480 - panic("sysv fs: bad i-node size"); 477 + BUILD_BUG_ON(sizeof(struct v7_super_block) != 440); 478 + BUILD_BUG_ON(sizeof(struct sysv_inode) != 64); 481 479 482 480 sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL); 483 481 if (!sbi)
+59 -16
include/asm-generic/sections.h
··· 64 64 #define dereference_kernel_function_descriptor(p) ((void *)(p)) 65 65 #endif 66 66 67 - /* random extra sections (if any). Override 68 - * in asm/sections.h */ 69 - #ifndef arch_is_kernel_text 70 - static inline int arch_is_kernel_text(unsigned long addr) 71 - { 72 - return 0; 73 - } 74 - #endif 75 - 76 - #ifndef arch_is_kernel_data 77 - static inline int arch_is_kernel_data(unsigned long addr) 78 - { 79 - return 0; 80 - } 81 - #endif 82 - 83 67 /** 84 68 * memory_contains - checks if an object is contained within a memory region 85 69 * @begin: virtual address of the beginning of the memory region ··· 129 145 } 130 146 131 147 /** 148 + * is_kernel_core_data - checks if the pointer address is located in the 149 + * .data section 150 + * 151 + * @addr: address to check 152 + * 153 + * Returns: true if the address is located in .data, false otherwise. 154 + * Note: On some archs it may return true for core RODATA, and false 155 + * for others. But will always be true for core RW data. 156 + */ 157 + static inline bool is_kernel_core_data(unsigned long addr) 158 + { 159 + return addr >= (unsigned long)_sdata && 160 + addr < (unsigned long)_edata; 161 + } 162 + 163 + /** 132 164 * is_kernel_rodata - checks if the pointer address is located in the 133 165 * .rodata section 134 166 * ··· 156 156 { 157 157 return addr >= (unsigned long)__start_rodata && 158 158 addr < (unsigned long)__end_rodata; 159 + } 160 + 161 + /** 162 + * is_kernel_inittext - checks if the pointer address is located in the 163 + * .init.text section 164 + * 165 + * @addr: address to check 166 + * 167 + * Returns: true if the address is located in .init.text, false otherwise. 168 + */ 169 + static inline bool is_kernel_inittext(unsigned long addr) 170 + { 171 + return addr >= (unsigned long)_sinittext && 172 + addr < (unsigned long)_einittext; 173 + } 174 + 175 + /** 176 + * __is_kernel_text - checks if the pointer address is located in the 177 + * .text section 178 + * 179 + * @addr: address to check 180 + * 181 + * Returns: true if the address is located in .text, false otherwise. 182 + * Note: an internal helper, only check the range of _stext to _etext. 183 + */ 184 + static inline bool __is_kernel_text(unsigned long addr) 185 + { 186 + return addr >= (unsigned long)_stext && 187 + addr < (unsigned long)_etext; 188 + } 189 + 190 + /** 191 + * __is_kernel - checks if the pointer address is located in the kernel range 192 + * 193 + * @addr: address to check 194 + * 195 + * Returns: true if the address is located in the kernel range, false otherwise. 196 + * Note: an internal helper, only check the range of _stext to _end. 197 + */ 198 + static inline bool __is_kernel(unsigned long addr) 199 + { 200 + return addr >= (unsigned long)_stext && 201 + addr < (unsigned long)_end; 159 202 } 160 203 161 204 #endif /* _ASM_GENERIC_SECTIONS_H_ */
+11 -2
include/kunit/test.h
··· 11 11 12 12 #include <kunit/assert.h> 13 13 #include <kunit/try-catch.h> 14 - #include <linux/kernel.h> 14 + 15 + #include <linux/container_of.h> 16 + #include <linux/err.h> 17 + #include <linux/init.h> 18 + #include <linux/kconfig.h> 19 + #include <linux/kref.h> 20 + #include <linux/list.h> 15 21 #include <linux/module.h> 16 22 #include <linux/slab.h> 23 + #include <linux/spinlock.h> 24 + #include <linux/string.h> 17 25 #include <linux/types.h> 18 - #include <linux/kref.h> 26 + 27 + #include <asm/rwonce.h> 19 28 20 29 struct kunit_resource; 21 30
+1
include/linux/bottom_half.h
··· 2 2 #ifndef _LINUX_BH_H 3 3 #define _LINUX_BH_H 4 4 5 + #include <linux/instruction_pointer.h> 5 6 #include <linux/preempt.h> 6 7 7 8 #if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_TRACE_IRQFLAGS)
+40
include/linux/container_of.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_CONTAINER_OF_H 3 + #define _LINUX_CONTAINER_OF_H 4 + 5 + #include <linux/build_bug.h> 6 + #include <linux/err.h> 7 + 8 + #define typeof_member(T, m) typeof(((T*)0)->m) 9 + 10 + /** 11 + * container_of - cast a member of a structure out to the containing structure 12 + * @ptr: the pointer to the member. 13 + * @type: the type of the container struct this is embedded in. 14 + * @member: the name of the member within the struct. 15 + * 16 + */ 17 + #define container_of(ptr, type, member) ({ \ 18 + void *__mptr = (void *)(ptr); \ 19 + static_assert(__same_type(*(ptr), ((type *)0)->member) || \ 20 + __same_type(*(ptr), void), \ 21 + "pointer type mismatch in container_of()"); \ 22 + ((type *)(__mptr - offsetof(type, member))); }) 23 + 24 + /** 25 + * container_of_safe - cast a member of a structure out to the containing structure 26 + * @ptr: the pointer to the member. 27 + * @type: the type of the container struct this is embedded in. 28 + * @member: the name of the member within the struct. 29 + * 30 + * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged. 31 + */ 32 + #define container_of_safe(ptr, type, member) ({ \ 33 + void *__mptr = (void *)(ptr); \ 34 + static_assert(__same_type(*(ptr), ((type *)0)->member) || \ 35 + __same_type(*(ptr), void), \ 36 + "pointer type mismatch in container_of_safe()"); \ 37 + IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \ 38 + ((type *)(__mptr - offsetof(type, member))); }) 39 + 40 + #endif /* _LINUX_CONTAINER_OF_H */
+24 -6
include/linux/crash_dump.h
··· 8 8 #include <linux/pgtable.h> 9 9 #include <uapi/linux/vmcore.h> 10 10 11 - #include <linux/pgtable.h> /* for pgprot_t */ 12 - 13 11 /* For IS_ENABLED(CONFIG_CRASH_DUMP) */ 14 12 #define ELFCORE_ADDR_MAX (-1ULL) 15 13 #define ELFCORE_ADDR_ERR (-2ULL) ··· 89 91 elfcorehdr_addr = ELFCORE_ADDR_ERR; 90 92 } 91 93 92 - #define HAVE_OLDMEM_PFN_IS_RAM 1 93 - extern int register_oldmem_pfn_is_ram(int (*fn)(unsigned long pfn)); 94 - extern void unregister_oldmem_pfn_is_ram(void); 94 + /** 95 + * struct vmcore_cb - driver callbacks for /proc/vmcore handling 96 + * @pfn_is_ram: check whether a PFN really is RAM and should be accessed when 97 + * reading the vmcore. Will return "true" if it is RAM or if the 98 + * callback cannot tell. If any callback returns "false", it's not 99 + * RAM and the page must not be accessed; zeroes should be 100 + * indicated in the vmcore instead. For example, a ballooned page 101 + * contains no data and reading from such a page will cause high 102 + * load in the hypervisor. 103 + * @next: List head to manage registered callbacks internally; initialized by 104 + * register_vmcore_cb(). 105 + * 106 + * vmcore callbacks allow drivers managing physical memory ranges to 107 + * coordinate with vmcore handling code, for example, to prevent accessing 108 + * physical memory ranges that should not be accessed when reading the vmcore, 109 + * although included in the vmcore header as memory ranges to dump. 110 + */ 111 + struct vmcore_cb { 112 + bool (*pfn_is_ram)(struct vmcore_cb *cb, unsigned long pfn); 113 + struct list_head next; 114 + }; 115 + extern void register_vmcore_cb(struct vmcore_cb *cb); 116 + extern void unregister_vmcore_cb(struct vmcore_cb *cb); 95 117 96 118 #else /* !CONFIG_CRASH_DUMP */ 97 - static inline bool is_kdump_kernel(void) { return 0; } 119 + static inline bool is_kdump_kernel(void) { return false; } 98 120 #endif /* CONFIG_CRASH_DUMP */ 99 121 100 122 /* Device Dump information to be filled by drivers */
+1 -1
include/linux/delay.h
··· 19 19 * https://lists.openwall.net/linux-kernel/2011/01/09/56 20 20 */ 21 21 22 - #include <linux/kernel.h> 22 + #include <linux/math.h> 23 23 24 24 extern unsigned long loops_per_jiffy; 25 25
+1
include/linux/fs.h
··· 3193 3193 } 3194 3194 3195 3195 extern void inode_sb_list_add(struct inode *inode); 3196 + extern void inode_add_lru(struct inode *inode); 3196 3197 3197 3198 extern int sb_set_blocksize(struct super_block *, int); 3198 3199 extern int sb_min_blocksize(struct super_block *, int);
+2 -1
include/linux/generic-radix-tree.h
··· 38 38 39 39 #include <asm/page.h> 40 40 #include <linux/bug.h> 41 - #include <linux/kernel.h> 42 41 #include <linux/log2.h> 42 + #include <linux/math.h> 43 + #include <linux/types.h> 43 44 44 45 struct genradix_root; 45 46
+2 -4
include/linux/hugetlb.h
··· 477 477 extern const struct file_operations hugetlbfs_file_operations; 478 478 extern const struct vm_operations_struct hugetlb_vm_ops; 479 479 struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct, 480 - struct ucounts **ucounts, int creat_flags, 481 - int page_size_log); 480 + int creat_flags, int page_size_log); 482 481 483 482 static inline bool is_file_hugepages(struct file *file) 484 483 { ··· 496 497 #define is_file_hugepages(file) false 497 498 static inline struct file * 498 499 hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag, 499 - struct ucounts **ucounts, int creat_flags, 500 - int page_size_log) 500 + int creat_flags, int page_size_log) 501 501 { 502 502 return ERR_PTR(-ENOSYS); 503 503 }
+8
include/linux/instruction_pointer.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_INSTRUCTION_POINTER_H 3 + #define _LINUX_INSTRUCTION_POINTER_H 4 + 5 + #define _RET_IP_ (unsigned long)__builtin_return_address(0) 6 + #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) 7 + 8 + #endif /* _LINUX_INSTRUCTION_POINTER_H */
+2 -11
include/linux/kallsyms.h
··· 24 24 struct cred; 25 25 struct module; 26 26 27 - static inline int is_kernel_inittext(unsigned long addr) 28 - { 29 - if (addr >= (unsigned long)_sinittext 30 - && addr <= (unsigned long)_einittext) 31 - return 1; 32 - return 0; 33 - } 34 - 35 27 static inline int is_kernel_text(unsigned long addr) 36 28 { 37 - if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) || 38 - arch_is_kernel_text(addr)) 29 + if (__is_kernel_text(addr)) 39 30 return 1; 40 31 return in_gate_area_no_mm(addr); 41 32 } 42 33 43 34 static inline int is_kernel(unsigned long addr) 44 35 { 45 - if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end) 36 + if (__is_kernel(addr)) 46 37 return 1; 47 38 return in_gate_area_no_mm(addr); 48 39 }
+2 -37
include/linux/kernel.h
··· 9 9 #include <linux/stddef.h> 10 10 #include <linux/types.h> 11 11 #include <linux/compiler.h> 12 + #include <linux/container_of.h> 12 13 #include <linux/bitops.h> 13 14 #include <linux/kstrtox.h> 14 15 #include <linux/log2.h> ··· 20 19 #include <linux/printk.h> 21 20 #include <linux/build_bug.h> 22 21 #include <linux/static_call_types.h> 22 + #include <linux/instruction_pointer.h> 23 23 #include <asm/byteorder.h> 24 24 25 25 #include <uapi/linux/kernel.h> ··· 53 51 (void __user *)(uintptr_t)(x); \ 54 52 } \ 55 53 ) 56 - 57 - #define typeof_member(T, m) typeof(((T*)0)->m) 58 - 59 - #define _RET_IP_ (unsigned long)__builtin_return_address(0) 60 - #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) 61 54 62 55 /** 63 56 * upper_32_bits - return bits 32-63 of a number ··· 225 228 extern char *next_arg(char *args, char **param, char **val); 226 229 227 230 extern int core_kernel_text(unsigned long addr); 228 - extern int init_kernel_text(unsigned long addr); 229 - extern int core_kernel_data(unsigned long addr); 230 231 extern int __kernel_text_address(unsigned long addr); 231 232 extern int kernel_text_address(unsigned long addr); 232 233 extern int func_ptr_is_kernel_text(void *ptr); ··· 477 482 478 483 #define __CONCAT(a, b) a ## b 479 484 #define CONCATENATE(a, b) __CONCAT(a, b) 480 - 481 - /** 482 - * container_of - cast a member of a structure out to the containing structure 483 - * @ptr: the pointer to the member. 484 - * @type: the type of the container struct this is embedded in. 485 - * @member: the name of the member within the struct. 486 - * 487 - */ 488 - #define container_of(ptr, type, member) ({ \ 489 - void *__mptr = (void *)(ptr); \ 490 - BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ 491 - !__same_type(*(ptr), void), \ 492 - "pointer type mismatch in container_of()"); \ 493 - ((type *)(__mptr - offsetof(type, member))); }) 494 - 495 - /** 496 - * container_of_safe - cast a member of a structure out to the containing structure 497 - * @ptr: the pointer to the member. 498 - * @type: the type of the container struct this is embedded in. 499 - * @member: the name of the member within the struct. 500 - * 501 - * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged. 502 - */ 503 - #define container_of_safe(ptr, type, member) ({ \ 504 - void *__mptr = (void *)(ptr); \ 505 - BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ 506 - !__same_type(*(ptr), void), \ 507 - "pointer type mismatch in container_of()"); \ 508 - IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \ 509 - ((type *)(__mptr - offsetof(type, member))); }) 510 485 511 486 /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ 512 487 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
+3 -1
include/linux/list.h
··· 2 2 #ifndef _LINUX_LIST_H 3 3 #define _LINUX_LIST_H 4 4 5 + #include <linux/container_of.h> 5 6 #include <linux/types.h> 6 7 #include <linux/stddef.h> 7 8 #include <linux/poison.h> 8 9 #include <linux/const.h> 9 - #include <linux/kernel.h> 10 + 11 + #include <asm/barrier.h> 10 12 11 13 /* 12 14 * Circular doubly linked list implementation.
+3 -1
include/linux/llist.h
··· 49 49 */ 50 50 51 51 #include <linux/atomic.h> 52 - #include <linux/kernel.h> 52 + #include <linux/container_of.h> 53 + #include <linux/stddef.h> 54 + #include <linux/types.h> 53 55 54 56 struct llist_head { 55 57 struct llist_node *first;
+50
include/linux/pagemap.h
··· 24 24 } 25 25 26 26 /* 27 + * mapping_shrinkable - test if page cache state allows inode reclaim 28 + * @mapping: the page cache mapping 29 + * 30 + * This checks the mapping's cache state for the pupose of inode 31 + * reclaim and LRU management. 32 + * 33 + * The caller is expected to hold the i_lock, but is not required to 34 + * hold the i_pages lock, which usually protects cache state. That's 35 + * because the i_lock and the list_lru lock that protect the inode and 36 + * its LRU state don't nest inside the irq-safe i_pages lock. 37 + * 38 + * Cache deletions are performed under the i_lock, which ensures that 39 + * when an inode goes empty, it will reliably get queued on the LRU. 40 + * 41 + * Cache additions do not acquire the i_lock and may race with this 42 + * check, in which case we'll report the inode as shrinkable when it 43 + * has cache pages. This is okay: the shrinker also checks the 44 + * refcount and the referenced bit, which will be elevated or set in 45 + * the process of adding new cache pages to an inode. 46 + */ 47 + static inline bool mapping_shrinkable(struct address_space *mapping) 48 + { 49 + void *head; 50 + 51 + /* 52 + * On highmem systems, there could be lowmem pressure from the 53 + * inodes before there is highmem pressure from the page 54 + * cache. Make inodes shrinkable regardless of cache state. 55 + */ 56 + if (IS_ENABLED(CONFIG_HIGHMEM)) 57 + return true; 58 + 59 + /* Cache completely empty? Shrink away. */ 60 + head = rcu_access_pointer(mapping->i_pages.xa_head); 61 + if (!head) 62 + return true; 63 + 64 + /* 65 + * The xarray stores single offset-0 entries directly in the 66 + * head pointer, which allows non-resident page cache entries 67 + * to escape the shadow shrinker's list of xarray nodes. The 68 + * inode shrinker needs to pick them up under memory pressure. 69 + */ 70 + if (!xa_is_node(head) && xa_is_value(head)) 71 + return true; 72 + 73 + return false; 74 + } 75 + 76 + /* 27 77 * Bits in mapping->flags. 28 78 */ 29 79 enum mapping_flags {
+4 -1
include/linux/plist.h
··· 73 73 #ifndef _LINUX_PLIST_H_ 74 74 #define _LINUX_PLIST_H_ 75 75 76 - #include <linux/kernel.h> 76 + #include <linux/container_of.h> 77 77 #include <linux/list.h> 78 + #include <linux/types.h> 79 + 80 + #include <asm/bug.h> 78 81 79 82 struct plist_head { 80 83 struct list_head node_list;
+3 -1
include/linux/radix-tree.h
··· 9 9 #define _LINUX_RADIX_TREE_H 10 10 11 11 #include <linux/bitops.h> 12 - #include <linux/kernel.h> 12 + #include <linux/gfp.h> 13 13 #include <linux/list.h> 14 + #include <linux/lockdep.h> 15 + #include <linux/math.h> 14 16 #include <linux/percpu.h> 15 17 #include <linux/preempt.h> 16 18 #include <linux/rcupdate.h>
-1
include/linux/rwsem.h
··· 11 11 #include <linux/linkage.h> 12 12 13 13 #include <linux/types.h> 14 - #include <linux/kernel.h> 15 14 #include <linux/list.h> 16 15 #include <linux/spinlock.h> 17 16 #include <linux/atomic.h>
+10 -1
include/linux/sbitmap.h
··· 9 9 #ifndef __LINUX_SCALE_BITMAP_H 10 10 #define __LINUX_SCALE_BITMAP_H 11 11 12 - #include <linux/kernel.h> 12 + #include <linux/atomic.h> 13 + #include <linux/bitops.h> 14 + #include <linux/cache.h> 15 + #include <linux/list.h> 16 + #include <linux/log2.h> 17 + #include <linux/minmax.h> 18 + #include <linux/percpu.h> 13 19 #include <linux/slab.h> 20 + #include <linux/smp.h> 21 + #include <linux/types.h> 22 + #include <linux/wait.h> 14 23 15 24 struct seq_file; 16 25
+17 -2
include/linux/seq_file.h
··· 4 4 5 5 #include <linux/types.h> 6 6 #include <linux/string.h> 7 + #include <linux/string_helpers.h> 7 8 #include <linux/bug.h> 8 9 #include <linux/mutex.h> 9 10 #include <linux/cpumask.h> ··· 136 135 seq_escape_mem(m, src, strlen(src), flags, esc); 137 136 } 138 137 139 - void seq_escape(struct seq_file *m, const char *s, const char *esc); 138 + /** 139 + * seq_escape - print string into buffer, escaping some characters 140 + * @m: target buffer 141 + * @s: NULL-terminated string 142 + * @esc: set of characters that need escaping 143 + * 144 + * Puts string into buffer, replacing each occurrence of character from 145 + * @esc with usual octal escape. 146 + * 147 + * Use seq_has_overflowed() to check for errors. 148 + */ 149 + static inline void seq_escape(struct seq_file *m, const char *s, const char *esc) 150 + { 151 + seq_escape_str(m, s, ESCAPE_OCTAL, esc); 152 + } 140 153 141 154 void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type, 142 155 int rowsize, int groupsize, const void *buf, size_t len, ··· 209 194 #define DEFINE_PROC_SHOW_ATTRIBUTE(__name) \ 210 195 static int __name ## _open(struct inode *inode, struct file *file) \ 211 196 { \ 212 - return single_open(file, __name ## _show, inode->i_private); \ 197 + return single_open(file, __name ## _show, PDE_DATA(inode)); \ 213 198 } \ 214 199 \ 215 200 static const struct proc_ops __name ## _proc_ops = { \
-1
include/linux/signal.h
··· 126 126 #define sigmask(sig) (1UL << ((sig) - 1)) 127 127 128 128 #ifndef __HAVE_ARCH_SIG_SETOPS 129 - #include <linux/string.h> 130 129 131 130 #define _SIG_SET_BINOP(name, op) \ 132 131 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
-1
include/linux/smp.h
··· 108 108 #ifdef CONFIG_SMP 109 109 110 110 #include <linux/preempt.h> 111 - #include <linux/kernel.h> 112 111 #include <linux/compiler.h> 113 112 #include <linux/thread_info.h> 114 113 #include <asm/smp.h>
-1
include/linux/spinlock.h
··· 57 57 #include <linux/compiler.h> 58 58 #include <linux/irqflags.h> 59 59 #include <linux/thread_info.h> 60 - #include <linux/kernel.h> 61 60 #include <linux/stringify.h> 62 61 #include <linux/bottom_half.h> 63 62 #include <linux/lockdep.h>
+5
include/linux/stackdepot.h
··· 25 25 unsigned int stack_depot_fetch(depot_stack_handle_t handle, 26 26 unsigned long **entries); 27 27 28 + int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size, 29 + int spaces); 30 + 31 + void stack_depot_print(depot_stack_handle_t stack); 32 + 28 33 #ifdef CONFIG_STACKDEPOT 29 34 int stack_depot_init(void); 30 35 #else
+1
include/linux/string_helpers.h
··· 4 4 5 5 #include <linux/bits.h> 6 6 #include <linux/ctype.h> 7 + #include <linux/string.h> 7 8 #include <linux/types.h> 8 9 9 10 struct file;
+2 -1
include/media/media-entity.h
··· 13 13 14 14 #include <linux/bitmap.h> 15 15 #include <linux/bug.h> 16 + #include <linux/container_of.h> 16 17 #include <linux/fwnode.h> 17 - #include <linux/kernel.h> 18 18 #include <linux/list.h> 19 19 #include <linux/media.h> 20 + #include <linux/types.h> 20 21 21 22 /* Enums used internally at the media controller to represent graphs */ 22 23
+3 -1
init/main.c
··· 915 915 for (p = &envp_init[2]; *p; p++) 916 916 end += sprintf(end, " %s", *p); 917 917 918 - pr_notice("Unknown command line parameters:%s\n", unknown_options); 918 + /* Start at unknown_options[1] to skip the initial space */ 919 + pr_notice("Unknown kernel command line parameters \"%s\", will be passed to user space.\n", 920 + &unknown_options[1]); 919 921 memblock_free(unknown_options, len); 920 922 } 921 923
+18 -14
ipc/ipc_sysctl.c
··· 10 10 #include <linux/nsproxy.h> 11 11 #include <linux/sysctl.h> 12 12 #include <linux/uaccess.h> 13 + #include <linux/capability.h> 13 14 #include <linux/ipc_namespace.h> 14 15 #include <linux/msg.h> 15 16 #include "util.h" ··· 23 22 return which; 24 23 } 25 24 26 - #ifdef CONFIG_PROC_SYSCTL 27 25 static int proc_ipc_dointvec(struct ctl_table *table, int write, 28 26 void *buffer, size_t *lenp, loff_t *ppos) 29 27 { ··· 104 104 return ret; 105 105 } 106 106 107 - #else 108 - #define proc_ipc_doulongvec_minmax NULL 109 - #define proc_ipc_dointvec NULL 110 - #define proc_ipc_dointvec_minmax NULL 111 - #define proc_ipc_dointvec_minmax_orphans NULL 112 - #define proc_ipc_auto_msgmni NULL 113 - #define proc_ipc_sem_dointvec NULL 107 + #ifdef CONFIG_CHECKPOINT_RESTORE 108 + static int proc_ipc_dointvec_minmax_checkpoint_restore(struct ctl_table *table, 109 + int write, void *buffer, size_t *lenp, loff_t *ppos) 110 + { 111 + struct user_namespace *user_ns = current->nsproxy->ipc_ns->user_ns; 112 + 113 + if (write && !checkpoint_restore_ns_capable(user_ns)) 114 + return -EPERM; 115 + 116 + return proc_ipc_dointvec_minmax(table, write, buffer, lenp, ppos); 117 + } 114 118 #endif 115 119 116 120 int ipc_mni = IPCMNI; ··· 202 198 .procname = "sem_next_id", 203 199 .data = &init_ipc_ns.ids[IPC_SEM_IDS].next_id, 204 200 .maxlen = sizeof(init_ipc_ns.ids[IPC_SEM_IDS].next_id), 205 - .mode = 0644, 206 - .proc_handler = proc_ipc_dointvec_minmax, 201 + .mode = 0666, 202 + .proc_handler = proc_ipc_dointvec_minmax_checkpoint_restore, 207 203 .extra1 = SYSCTL_ZERO, 208 204 .extra2 = SYSCTL_INT_MAX, 209 205 }, ··· 211 207 .procname = "msg_next_id", 212 208 .data = &init_ipc_ns.ids[IPC_MSG_IDS].next_id, 213 209 .maxlen = sizeof(init_ipc_ns.ids[IPC_MSG_IDS].next_id), 214 - .mode = 0644, 215 - .proc_handler = proc_ipc_dointvec_minmax, 210 + .mode = 0666, 211 + .proc_handler = proc_ipc_dointvec_minmax_checkpoint_restore, 216 212 .extra1 = SYSCTL_ZERO, 217 213 .extra2 = SYSCTL_INT_MAX, 218 214 }, ··· 220 216 .procname = "shm_next_id", 221 217 .data = &init_ipc_ns.ids[IPC_SHM_IDS].next_id, 222 218 .maxlen = sizeof(init_ipc_ns.ids[IPC_SHM_IDS].next_id), 223 - .mode = 0644, 224 - .proc_handler = proc_ipc_dointvec_minmax, 219 + .mode = 0666, 220 + .proc_handler = proc_ipc_dointvec_minmax_checkpoint_restore, 225 221 .extra1 = SYSCTL_ZERO, 226 222 .extra2 = SYSCTL_INT_MAX, 227 223 },
+1 -7
ipc/shm.c
··· 287 287 shm_unlock(shp); 288 288 if (!is_file_hugepages(shm_file)) 289 289 shmem_lock(shm_file, 0, shp->mlock_ucounts); 290 - else if (shp->mlock_ucounts) 291 - user_shm_unlock(i_size_read(file_inode(shm_file)), 292 - shp->mlock_ucounts); 293 290 fput(shm_file); 294 291 ipc_update_pid(&shp->shm_cprid, NULL); 295 292 ipc_update_pid(&shp->shm_lprid, NULL); ··· 647 650 if (shmflg & SHM_NORESERVE) 648 651 acctflag = VM_NORESERVE; 649 652 file = hugetlb_file_setup(name, hugesize, acctflag, 650 - &shp->mlock_ucounts, HUGETLB_SHMFS_INODE, 651 - (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK); 653 + HUGETLB_SHMFS_INODE, (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK); 652 654 } else { 653 655 /* 654 656 * Do not allow no accounting for OVERCOMMIT_NEVER, even ··· 694 698 no_id: 695 699 ipc_update_pid(&shp->shm_cprid, NULL); 696 700 ipc_update_pid(&shp->shm_lprid, NULL); 697 - if (is_file_hugepages(file) && shp->mlock_ucounts) 698 - user_shm_unlock(size, shp->mlock_ucounts); 699 701 fput(file); 700 702 ipc_rcu_putref(&shp->shm_perm, shm_rcu_free); 701 703 return error;
+3 -30
kernel/extable.c
··· 62 62 return e; 63 63 } 64 64 65 - int init_kernel_text(unsigned long addr) 66 - { 67 - if (addr >= (unsigned long)_sinittext && 68 - addr < (unsigned long)_einittext) 69 - return 1; 70 - return 0; 71 - } 72 - 73 65 int notrace core_kernel_text(unsigned long addr) 74 66 { 75 - if (addr >= (unsigned long)_stext && 76 - addr < (unsigned long)_etext) 67 + if (is_kernel_text(addr)) 77 68 return 1; 78 69 79 70 if (system_state < SYSTEM_FREEING_INITMEM && 80 - init_kernel_text(addr)) 81 - return 1; 82 - return 0; 83 - } 84 - 85 - /** 86 - * core_kernel_data - tell if addr points to kernel data 87 - * @addr: address to test 88 - * 89 - * Returns true if @addr passed in is from the core kernel data 90 - * section. 91 - * 92 - * Note: On some archs it may return true for core RODATA, and false 93 - * for others. But will always be true for core RW data. 94 - */ 95 - int core_kernel_data(unsigned long addr) 96 - { 97 - if (addr >= (unsigned long)_sdata && 98 - addr < (unsigned long)_edata) 71 + is_kernel_inittext(addr)) 99 72 return 1; 100 73 return 0; 101 74 } ··· 85 112 * Since we are after the module-symbols check, there's 86 113 * no danger of address overlap: 87 114 */ 88 - if (init_kernel_text(addr)) 115 + if (is_kernel_inittext(addr)) 89 116 return 1; 90 117 return 0; 91 118 }
+3 -6
kernel/fork.c
··· 3024 3024 int ksys_unshare(unsigned long unshare_flags) 3025 3025 { 3026 3026 struct fs_struct *fs, *new_fs = NULL; 3027 - struct files_struct *fd, *new_fd = NULL; 3027 + struct files_struct *new_fd = NULL; 3028 3028 struct cred *new_cred = NULL; 3029 3029 struct nsproxy *new_nsproxy = NULL; 3030 3030 int do_sysvsem = 0; ··· 3111 3111 spin_unlock(&fs->lock); 3112 3112 } 3113 3113 3114 - if (new_fd) { 3115 - fd = current->files; 3116 - current->files = new_fd; 3117 - new_fd = fd; 3118 - } 3114 + if (new_fd) 3115 + swap(current->files, new_fd); 3119 3116 3120 3117 task_unlock(current); 3121 3118
+20 -16
kernel/kcov.c
··· 88 88 89 89 struct kcov_percpu_data { 90 90 void *irq_area; 91 + local_lock_t lock; 91 92 92 93 unsigned int saved_mode; 93 94 unsigned int saved_size; ··· 97 96 int saved_sequence; 98 97 }; 99 98 100 - static DEFINE_PER_CPU(struct kcov_percpu_data, kcov_percpu_data); 99 + static DEFINE_PER_CPU(struct kcov_percpu_data, kcov_percpu_data) = { 100 + .lock = INIT_LOCAL_LOCK(lock), 101 + }; 101 102 102 103 /* Must be called with kcov_remote_lock locked. */ 103 104 static struct kcov_remote *kcov_remote_find(u64 handle) ··· 827 824 if (!in_task() && !in_serving_softirq()) 828 825 return; 829 826 830 - local_irq_save(flags); 827 + local_lock_irqsave(&kcov_percpu_data.lock, flags); 831 828 832 829 /* 833 830 * Check that kcov_remote_start() is not called twice in background ··· 835 832 */ 836 833 mode = READ_ONCE(t->kcov_mode); 837 834 if (WARN_ON(in_task() && kcov_mode_enabled(mode))) { 838 - local_irq_restore(flags); 835 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 839 836 return; 840 837 } 841 838 /* ··· 844 841 * happened while collecting coverage from a background thread. 845 842 */ 846 843 if (WARN_ON(in_serving_softirq() && t->kcov_softirq)) { 847 - local_irq_restore(flags); 844 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 848 845 return; 849 846 } 850 847 851 848 spin_lock(&kcov_remote_lock); 852 849 remote = kcov_remote_find(handle); 853 850 if (!remote) { 854 - spin_unlock_irqrestore(&kcov_remote_lock, flags); 851 + spin_unlock(&kcov_remote_lock); 852 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 855 853 return; 856 854 } 857 855 kcov_debug("handle = %llx, context: %s\n", handle, ··· 873 869 size = CONFIG_KCOV_IRQ_AREA_SIZE; 874 870 area = this_cpu_ptr(&kcov_percpu_data)->irq_area; 875 871 } 876 - spin_unlock_irqrestore(&kcov_remote_lock, flags); 872 + spin_unlock(&kcov_remote_lock); 877 873 878 874 /* Can only happen when in_task(). */ 879 875 if (!area) { 876 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 880 877 area = vmalloc(size * sizeof(unsigned long)); 881 878 if (!area) { 882 879 kcov_put(kcov); 883 880 return; 884 881 } 882 + local_lock_irqsave(&kcov_percpu_data.lock, flags); 885 883 } 886 - 887 - local_irq_save(flags); 888 884 889 885 /* Reset coverage size. */ 890 886 *(u64 *)area = 0; ··· 895 891 } 896 892 kcov_start(t, kcov, size, area, mode, sequence); 897 893 898 - local_irq_restore(flags); 894 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 899 895 900 896 } 901 897 EXPORT_SYMBOL(kcov_remote_start); ··· 969 965 if (!in_task() && !in_serving_softirq()) 970 966 return; 971 967 972 - local_irq_save(flags); 968 + local_lock_irqsave(&kcov_percpu_data.lock, flags); 973 969 974 970 mode = READ_ONCE(t->kcov_mode); 975 971 barrier(); 976 972 if (!kcov_mode_enabled(mode)) { 977 - local_irq_restore(flags); 973 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 978 974 return; 979 975 } 980 976 /* ··· 982 978 * actually found the remote handle and started collecting coverage. 983 979 */ 984 980 if (in_serving_softirq() && !t->kcov_softirq) { 985 - local_irq_restore(flags); 981 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 986 982 return; 987 983 } 988 984 /* Make sure that kcov_softirq is only set when in softirq. */ 989 985 if (WARN_ON(!in_serving_softirq() && t->kcov_softirq)) { 990 - local_irq_restore(flags); 986 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 991 987 return; 992 988 } 993 989 ··· 1017 1013 spin_unlock(&kcov_remote_lock); 1018 1014 } 1019 1015 1020 - local_irq_restore(flags); 1016 + local_unlock_irqrestore(&kcov_percpu_data.lock, flags); 1021 1017 1022 1018 /* Get in kcov_remote_start(). */ 1023 1019 kcov_put(kcov); ··· 1038 1034 int cpu; 1039 1035 1040 1036 for_each_possible_cpu(cpu) { 1041 - void *area = vmalloc(CONFIG_KCOV_IRQ_AREA_SIZE * 1042 - sizeof(unsigned long)); 1037 + void *area = vmalloc_node(CONFIG_KCOV_IRQ_AREA_SIZE * 1038 + sizeof(unsigned long), cpu_to_node(cpu)); 1043 1039 if (!area) 1044 1040 return -ENOMEM; 1045 1041 per_cpu_ptr(&kcov_percpu_data, cpu)->irq_area = area;
-3
kernel/locking/lockdep.c
··· 818 818 if ((addr >= start) && (addr < end)) 819 819 return 1; 820 820 821 - if (arch_is_kernel_data(addr)) 822 - return 1; 823 - 824 821 /* 825 822 * in-kernel percpu var? 826 823 */
+39 -15
kernel/resource.c
··· 73 73 return p->sibling; 74 74 } 75 75 76 + static struct resource *next_resource_skip_children(struct resource *p) 77 + { 78 + while (!p->sibling && p->parent) 79 + p = p->parent; 80 + return p->sibling; 81 + } 82 + 83 + #define for_each_resource(_root, _p, _skip_children) \ 84 + for ((_p) = (_root)->child; (_p); \ 85 + (_p) = (_skip_children) ? next_resource_skip_children(_p) : \ 86 + next_resource(_p)) 87 + 76 88 static void *r_next(struct seq_file *m, void *v, loff_t *pos) 77 89 { 78 90 struct resource *p = v; ··· 1719 1707 #endif 1720 1708 1721 1709 /* 1722 - * check if an address is reserved in the iomem resource tree 1723 - * returns true if reserved, false if not reserved. 1710 + * Check if an address is exclusive to the kernel and must not be mapped to 1711 + * user space, for example, via /dev/mem. 1712 + * 1713 + * Returns true if exclusive to the kernel, otherwise returns false. 1724 1714 */ 1725 1715 bool iomem_is_exclusive(u64 addr) 1726 1716 { 1727 - struct resource *p = &iomem_resource; 1728 - bool err = false; 1729 - loff_t l; 1717 + const unsigned int exclusive_system_ram = IORESOURCE_SYSTEM_RAM | 1718 + IORESOURCE_EXCLUSIVE; 1719 + bool skip_children = false, err = false; 1730 1720 int size = PAGE_SIZE; 1731 - 1732 - if (!strict_iomem_checks) 1733 - return false; 1721 + struct resource *p; 1734 1722 1735 1723 addr = addr & PAGE_MASK; 1736 1724 1737 1725 read_lock(&resource_lock); 1738 - for (p = p->child; p ; p = r_next(NULL, p, &l)) { 1739 - /* 1740 - * We can probably skip the resources without 1741 - * IORESOURCE_IO attribute? 1742 - */ 1726 + for_each_resource(&iomem_resource, p, skip_children) { 1743 1727 if (p->start >= addr + size) 1744 1728 break; 1745 - if (p->end < addr) 1729 + if (p->end < addr) { 1730 + skip_children = true; 1746 1731 continue; 1732 + } 1733 + skip_children = false; 1734 + 1735 + /* 1736 + * IORESOURCE_SYSTEM_RAM resources are exclusive if 1737 + * IORESOURCE_EXCLUSIVE is set, even if they 1738 + * are not busy and even if "iomem=relaxed" is set. The 1739 + * responsible driver dynamically adds/removes system RAM within 1740 + * such an area and uncontrolled access is dangerous. 1741 + */ 1742 + if ((p->flags & exclusive_system_ram) == exclusive_system_ram) { 1743 + err = true; 1744 + break; 1745 + } 1746 + 1747 1747 /* 1748 1748 * A resource is exclusive if IORESOURCE_EXCLUSIVE is set 1749 1749 * or CONFIG_IO_STRICT_DEVMEM is enabled and the 1750 1750 * resource is busy. 1751 1751 */ 1752 - if ((p->flags & IORESOURCE_BUSY) == 0) 1752 + if (!strict_iomem_checks || !(p->flags & IORESOURCE_BUSY)) 1753 1753 continue; 1754 1754 if (IS_ENABLED(CONFIG_IO_STRICT_DEVMEM) 1755 1755 || p->flags & IORESOURCE_EXCLUSIVE) {
+1 -1
kernel/trace/ftrace.c
··· 318 318 if (!ftrace_enabled && (ops->flags & FTRACE_OPS_FL_PERMANENT)) 319 319 return -EBUSY; 320 320 321 - if (!core_kernel_data((unsigned long)ops)) 321 + if (!is_kernel_core_data((unsigned long)ops)) 322 322 ops->flags |= FTRACE_OPS_FL_DYNAMIC; 323 323 324 324 add_ftrace_ops(&ftrace_ops_list, ops);
+4 -7
lib/scatterlist.c
··· 828 828 * stops @miter. 829 829 * 830 830 * Context: 831 - * Don't care if @miter is stopped, or not proceeded yet. 832 - * Otherwise, preemption disabled if the SG_MITER_ATOMIC is set. 831 + * Don't care. 833 832 * 834 833 * Returns: 835 834 * true if @miter contains the valid mapping. false if end of sg ··· 864 865 * @miter->addr and @miter->length point to the current mapping. 865 866 * 866 867 * Context: 867 - * Preemption disabled if SG_MITER_ATOMIC. Preemption must stay disabled 868 - * till @miter is stopped. May sleep if !SG_MITER_ATOMIC. 868 + * May sleep if !SG_MITER_ATOMIC. 869 869 * 870 870 * Returns: 871 871 * true if @miter contains the next mapping. false if end of sg ··· 904 906 * need to be released during iteration. 905 907 * 906 908 * Context: 907 - * Preemption disabled if the SG_MITER_ATOMIC is set. Don't care 908 - * otherwise. 909 + * Don't care otherwise. 909 910 */ 910 911 void sg_miter_stop(struct sg_mapping_iter *miter) 911 912 { ··· 919 922 flush_dcache_page(miter->page); 920 923 921 924 if (miter->__flags & SG_MITER_ATOMIC) { 922 - WARN_ON_ONCE(preemptible()); 925 + WARN_ON_ONCE(!pagefault_disabled()); 923 926 kunmap_atomic(miter->addr); 924 927 } else 925 928 kunmap(miter->page);
+46
lib/stackdepot.c
··· 214 214 } 215 215 216 216 /** 217 + * stack_depot_snprint - print stack entries from a depot into a buffer 218 + * 219 + * @handle: Stack depot handle which was returned from 220 + * stack_depot_save(). 221 + * @buf: Pointer to the print buffer 222 + * 223 + * @size: Size of the print buffer 224 + * 225 + * @spaces: Number of leading spaces to print 226 + * 227 + * Return: Number of bytes printed. 228 + */ 229 + int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size, 230 + int spaces) 231 + { 232 + unsigned long *entries; 233 + unsigned int nr_entries; 234 + 235 + nr_entries = stack_depot_fetch(handle, &entries); 236 + return nr_entries ? stack_trace_snprint(buf, size, entries, nr_entries, 237 + spaces) : 0; 238 + } 239 + EXPORT_SYMBOL_GPL(stack_depot_snprint); 240 + 241 + /** 242 + * stack_depot_print - print stack entries from a depot 243 + * 244 + * @stack: Stack depot handle which was returned from 245 + * stack_depot_save(). 246 + * 247 + */ 248 + void stack_depot_print(depot_stack_handle_t stack) 249 + { 250 + unsigned long *entries; 251 + unsigned int nr_entries; 252 + 253 + nr_entries = stack_depot_fetch(stack, &entries); 254 + if (nr_entries > 0) 255 + stack_trace_print(entries, nr_entries, 0); 256 + } 257 + EXPORT_SYMBOL_GPL(stack_depot_print); 258 + 259 + /** 217 260 * stack_depot_fetch - Fetch stack entries from a depot 218 261 * 219 262 * @handle: Stack depot handle which was returned from ··· 274 231 struct stack_record *stack; 275 232 276 233 *entries = NULL; 234 + if (!handle) 235 + return 0; 236 + 277 237 if (parts.slabindex > depot_index) { 278 238 WARN(1, "slab index %d out of bounds (%d) for stack id %08x\n", 279 239 parts.slabindex, depot_index, handle);
+1 -2
lib/vsprintf.c
··· 53 53 #include <linux/string_helpers.h> 54 54 #include "kstrtox.h" 55 55 56 - static unsigned long long simple_strntoull(const char *startp, size_t max_chars, 57 - char **endp, unsigned int base) 56 + static noinline unsigned long long simple_strntoull(const char *startp, size_t max_chars, char **endp, unsigned int base) 58 57 { 59 58 const char *cp; 60 59 unsigned long long result = 0ULL;
+7
mm/Kconfig
··· 109 109 config MEMORY_ISOLATION 110 110 bool 111 111 112 + # IORESOURCE_SYSTEM_RAM regions in the kernel resource tree that are marked 113 + # IORESOURCE_EXCLUSIVE cannot be mapped to user space, for example, via 114 + # /dev/mem. 115 + config EXCLUSIVE_SYSTEM_RAM 116 + def_bool y 117 + depends on !DEVMEM || STRICT_DEVMEM 118 + 112 119 # 113 120 # Only be set on architectures that have completely implemented memory hotplug 114 121 # feature. If you are not sure, don't touch it.
+8
mm/filemap.c
··· 261 261 struct address_space *mapping = page_mapping(page); 262 262 263 263 BUG_ON(!PageLocked(page)); 264 + spin_lock(&mapping->host->i_lock); 264 265 xa_lock_irq(&mapping->i_pages); 265 266 __delete_from_page_cache(page, NULL); 266 267 xa_unlock_irq(&mapping->i_pages); 268 + if (mapping_shrinkable(mapping)) 269 + inode_add_lru(mapping->host); 270 + spin_unlock(&mapping->host->i_lock); 267 271 268 272 page_cache_free_page(mapping, page); 269 273 } ··· 343 339 if (!pagevec_count(pvec)) 344 340 return; 345 341 342 + spin_lock(&mapping->host->i_lock); 346 343 xa_lock_irq(&mapping->i_pages); 347 344 for (i = 0; i < pagevec_count(pvec); i++) { 348 345 trace_mm_filemap_delete_from_page_cache(pvec->pages[i]); ··· 352 347 } 353 348 page_cache_delete_batch(mapping, pvec); 354 349 xa_unlock_irq(&mapping->i_pages); 350 + if (mapping_shrinkable(mapping)) 351 + inode_add_lru(mapping->host); 352 + spin_unlock(&mapping->host->i_lock); 355 353 356 354 for (i = 0; i < pagevec_count(pvec); i++) 357 355 page_cache_free_page(mapping, pvec->pages[i]);
+4 -13
mm/kasan/report.c
··· 132 132 kasan_enable_current(); 133 133 } 134 134 135 - static void print_stack(depot_stack_handle_t stack) 136 - { 137 - unsigned long *entries; 138 - unsigned int nr_entries; 139 - 140 - nr_entries = stack_depot_fetch(stack, &entries); 141 - stack_trace_print(entries, nr_entries, 0); 142 - } 143 - 144 135 static void print_track(struct kasan_track *track, const char *prefix) 145 136 { 146 137 pr_err("%s by task %u:\n", prefix, track->pid); 147 138 if (track->stack) { 148 - print_stack(track->stack); 139 + stack_depot_print(track->stack); 149 140 } else { 150 141 pr_err("(stack is not available)\n"); 151 142 } ··· 205 214 return; 206 215 if (alloc_meta->aux_stack[0]) { 207 216 pr_err("Last potentially related work creation:\n"); 208 - print_stack(alloc_meta->aux_stack[0]); 217 + stack_depot_print(alloc_meta->aux_stack[0]); 209 218 pr_err("\n"); 210 219 } 211 220 if (alloc_meta->aux_stack[1]) { 212 221 pr_err("Second to last potentially related work creation:\n"); 213 - print_stack(alloc_meta->aux_stack[1]); 222 + stack_depot_print(alloc_meta->aux_stack[1]); 214 223 pr_err("\n"); 215 224 } 216 225 #endif ··· 226 235 227 236 static inline bool kernel_or_module_addr(const void *addr) 228 237 { 229 - if (addr >= (void *)_stext && addr < (void *)_end) 238 + if (is_kernel((unsigned long)addr)) 230 239 return true; 231 240 if (is_module_address((unsigned long)addr)) 232 241 return true;
+1 -3
mm/memfd.c
··· 297 297 } 298 298 299 299 if (flags & MFD_HUGETLB) { 300 - struct ucounts *ucounts = NULL; 301 - 302 - file = hugetlb_file_setup(name, 0, VM_NORESERVE, &ucounts, 300 + file = hugetlb_file_setup(name, 0, VM_NORESERVE, 303 301 HUGETLB_ANONHUGE_INODE, 304 302 (flags >> MFD_HUGE_SHIFT) & 305 303 MFD_HUGE_MASK);
+1 -2
mm/mmap.c
··· 1599 1599 goto out_fput; 1600 1600 } 1601 1601 } else if (flags & MAP_HUGETLB) { 1602 - struct ucounts *ucounts = NULL; 1603 1602 struct hstate *hs; 1604 1603 1605 1604 hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK); ··· 1614 1615 */ 1615 1616 file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, 1616 1617 VM_NORESERVE, 1617 - &ucounts, HUGETLB_ANONHUGE_INODE, 1618 + HUGETLB_ANONHUGE_INODE, 1618 1619 (flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK); 1619 1620 if (IS_ERR(file)) 1620 1621 return PTR_ERR(file);
+5 -13
mm/page_owner.c
··· 329 329 depot_stack_handle_t handle) 330 330 { 331 331 int ret, pageblock_mt, page_mt; 332 - unsigned long *entries; 333 - unsigned int nr_entries; 334 332 char *kbuf; 335 333 336 334 count = min_t(size_t, count, PAGE_SIZE); ··· 359 361 if (ret >= count) 360 362 goto err; 361 363 362 - nr_entries = stack_depot_fetch(handle, &entries); 363 - ret += stack_trace_snprint(kbuf + ret, count - ret, entries, nr_entries, 0); 364 + ret += stack_depot_snprint(handle, kbuf + ret, count - ret, 0); 364 365 if (ret >= count) 365 366 goto err; 366 367 ··· 391 394 struct page_ext *page_ext = lookup_page_ext(page); 392 395 struct page_owner *page_owner; 393 396 depot_stack_handle_t handle; 394 - unsigned long *entries; 395 - unsigned int nr_entries; 396 397 gfp_t gfp_mask; 397 398 int mt; 398 399 ··· 418 423 page_owner->pid, page_owner->ts_nsec, page_owner->free_ts_nsec); 419 424 420 425 handle = READ_ONCE(page_owner->handle); 421 - if (!handle) { 426 + if (!handle) 422 427 pr_alert("page_owner allocation stack trace missing\n"); 423 - } else { 424 - nr_entries = stack_depot_fetch(handle, &entries); 425 - stack_trace_print(entries, nr_entries, 0); 426 - } 428 + else 429 + stack_depot_print(handle); 427 430 428 431 handle = READ_ONCE(page_owner->free_handle); 429 432 if (!handle) { 430 433 pr_alert("page_owner free stack trace missing\n"); 431 434 } else { 432 - nr_entries = stack_depot_fetch(handle, &entries); 433 435 pr_alert("page last free stack trace:\n"); 434 - stack_trace_print(entries, nr_entries, 0); 436 + stack_depot_print(handle); 435 437 } 436 438 437 439 if (page_owner->last_migrate_reason != -1)
+17 -2
mm/truncate.c
··· 45 45 static void clear_shadow_entry(struct address_space *mapping, pgoff_t index, 46 46 void *entry) 47 47 { 48 + spin_lock(&mapping->host->i_lock); 48 49 xa_lock_irq(&mapping->i_pages); 49 50 __clear_shadow_entry(mapping, index, entry); 50 51 xa_unlock_irq(&mapping->i_pages); 52 + if (mapping_shrinkable(mapping)) 53 + inode_add_lru(mapping->host); 54 + spin_unlock(&mapping->host->i_lock); 51 55 } 52 56 53 57 /* ··· 77 73 return; 78 74 79 75 dax = dax_mapping(mapping); 80 - if (!dax) 76 + if (!dax) { 77 + spin_lock(&mapping->host->i_lock); 81 78 xa_lock_irq(&mapping->i_pages); 79 + } 82 80 83 81 for (i = j; i < pagevec_count(pvec); i++) { 84 82 struct page *page = pvec->pages[i]; ··· 99 93 __clear_shadow_entry(mapping, index, page); 100 94 } 101 95 102 - if (!dax) 96 + if (!dax) { 103 97 xa_unlock_irq(&mapping->i_pages); 98 + if (mapping_shrinkable(mapping)) 99 + inode_add_lru(mapping->host); 100 + spin_unlock(&mapping->host->i_lock); 101 + } 104 102 pvec->nr = j; 105 103 } 106 104 ··· 577 567 if (page_has_private(page) && !try_to_release_page(page, GFP_KERNEL)) 578 568 return 0; 579 569 570 + spin_lock(&mapping->host->i_lock); 580 571 xa_lock_irq(&mapping->i_pages); 581 572 if (PageDirty(page)) 582 573 goto failed; ··· 585 574 BUG_ON(page_has_private(page)); 586 575 __delete_from_page_cache(page, NULL); 587 576 xa_unlock_irq(&mapping->i_pages); 577 + if (mapping_shrinkable(mapping)) 578 + inode_add_lru(mapping->host); 579 + spin_unlock(&mapping->host->i_lock); 588 580 589 581 if (mapping->a_ops->freepage) 590 582 mapping->a_ops->freepage(page); ··· 596 582 return 1; 597 583 failed: 598 584 xa_unlock_irq(&mapping->i_pages); 585 + spin_unlock(&mapping->host->i_lock); 599 586 return 0; 600 587 } 601 588
+7
mm/vmscan.c
··· 1205 1205 BUG_ON(!PageLocked(page)); 1206 1206 BUG_ON(mapping != page_mapping(page)); 1207 1207 1208 + if (!PageSwapCache(page)) 1209 + spin_lock(&mapping->host->i_lock); 1208 1210 xa_lock_irq(&mapping->i_pages); 1209 1211 /* 1210 1212 * The non racy check for a busy page. ··· 1275 1273 shadow = workingset_eviction(page, target_memcg); 1276 1274 __delete_from_page_cache(page, shadow); 1277 1275 xa_unlock_irq(&mapping->i_pages); 1276 + if (mapping_shrinkable(mapping)) 1277 + inode_add_lru(mapping->host); 1278 + spin_unlock(&mapping->host->i_lock); 1278 1279 1279 1280 if (freepage != NULL) 1280 1281 freepage(page); ··· 1287 1282 1288 1283 cannot_free: 1289 1284 xa_unlock_irq(&mapping->i_pages); 1285 + if (!PageSwapCache(page)) 1286 + spin_unlock(&mapping->host->i_lock); 1290 1287 return 0; 1291 1288 } 1292 1289
+10
mm/workingset.c
··· 543 543 goto out; 544 544 } 545 545 546 + if (!spin_trylock(&mapping->host->i_lock)) { 547 + xa_unlock(&mapping->i_pages); 548 + spin_unlock_irq(lru_lock); 549 + ret = LRU_RETRY; 550 + goto out; 551 + } 552 + 546 553 list_lru_isolate(lru, item); 547 554 __dec_lruvec_kmem_state(node, WORKINGSET_NODES); 548 555 ··· 569 562 570 563 out_invalid: 571 564 xa_unlock_irq(&mapping->i_pages); 565 + if (mapping_shrinkable(mapping)) 566 + inode_add_lru(mapping->host); 567 + spin_unlock(&mapping->host->i_lock); 572 568 ret = LRU_REMOVED_RETRY; 573 569 out: 574 570 cond_resched();
+1 -1
net/sysctl_net.c
··· 144 144 addr = (unsigned long)ent->data; 145 145 if (is_module_address(addr)) 146 146 where = "module"; 147 - else if (core_kernel_data(addr)) 147 + else if (is_kernel_core_data(addr)) 148 148 where = "kernel"; 149 149 else 150 150 continue;
+29 -4
scripts/checkpatch.pl
··· 63 63 my $spelling_file = "$D/spelling.txt"; 64 64 my $codespell = 0; 65 65 my $codespellfile = "/usr/share/codespell/dictionary.txt"; 66 + my $user_codespellfile = ""; 66 67 my $conststructsfile = "$D/const_structs.checkpatch"; 67 68 my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst"; 68 69 my $typedefsfile; ··· 131 130 --ignore-perl-version override checking of perl version. expect 132 131 runtime errors. 133 132 --codespell Use the codespell dictionary for spelling/typos 134 - (default:/usr/share/codespell/dictionary.txt) 133 + (default:$codespellfile) 135 134 --codespellfile Use this codespell dictionary 136 135 --typedefsfile Read additional types from this file 137 136 --color[=WHEN] Use colors 'always', 'never', or only when output ··· 318 317 'debug=s' => \%debug, 319 318 'test-only=s' => \$tst_only, 320 319 'codespell!' => \$codespell, 321 - 'codespellfile=s' => \$codespellfile, 320 + 'codespellfile=s' => \$user_codespellfile, 322 321 'typedefsfile=s' => \$typedefsfile, 323 322 'color=s' => \$color, 324 323 'no-color' => \$color, #keep old behaviors of -nocolor ··· 326 325 'kconfig-prefix=s' => \${CONFIG_}, 327 326 'h|help' => \$help, 328 327 'version' => \$help 329 - ) or help(1); 328 + ) or $help = 2; 330 329 331 - help(0) if ($help); 330 + if ($user_codespellfile) { 331 + # Use the user provided codespell file unconditionally 332 + $codespellfile = $user_codespellfile; 333 + } elsif (!(-f $codespellfile)) { 334 + # If /usr/share/codespell/dictionary.txt is not present, try to find it 335 + # under codespell's install directory: <codespell_root>/data/dictionary.txt 336 + if (($codespell || $help) && which("codespell") ne "" && which("python") ne "") { 337 + my $python_codespell_dict = << "EOF"; 338 + 339 + import os.path as op 340 + import codespell_lib 341 + codespell_dir = op.dirname(codespell_lib.__file__) 342 + codespell_file = op.join(codespell_dir, 'data', 'dictionary.txt') 343 + print(codespell_file, end='') 344 + EOF 345 + 346 + my $codespell_dict = `python -c "$python_codespell_dict" 2> /dev/null`; 347 + $codespellfile = $codespell_dict if (-f $codespell_dict); 348 + } 349 + } 350 + 351 + # $help is 1 if either -h, --help or --version is passed as option - exitcode: 0 352 + # $help is 2 if invalid option is passed - exitcode: 1 353 + help($help - 1) if ($help); 332 354 333 355 die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix)); 334 356 die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse); ··· 4473 4449 # XXX(foo); 4474 4450 # EXPORT_SYMBOL(something_foo); 4475 4451 my $name = $1; 4452 + $name =~ s/^\s*($Ident).*/$1/; 4476 4453 if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ && 4477 4454 $name =~ /^${Ident}_$2/) { 4478 4455 #print "FOO C name<$name>\n";
+4
scripts/const_structs.checkpatch
··· 54 54 seq_operations 55 55 sirfsoc_padmux 56 56 snd_ac97_build_ops 57 + snd_pcm_ops 58 + snd_rawmidi_ops 57 59 snd_soc_component_driver 60 + snd_soc_dai_ops 61 + snd_soc_ops 58 62 soc_pcmcia_socket_ops 59 63 stacktrace_ops 60 64 sysfs_ops
+2 -1
scripts/gdb/linux/symbols.py
··· 148 148 # drop all current symbols and reload vmlinux 149 149 orig_vmlinux = 'vmlinux' 150 150 for obj in gdb.objfiles(): 151 - if obj.filename.endswith('vmlinux'): 151 + if (obj.filename.endswith('vmlinux') or 152 + obj.filename.endswith('vmlinux.debug')): 152 153 orig_vmlinux = obj.filename 153 154 gdb.execute("symbol-file", to_string=True) 154 155 gdb.execute("symbol-file {0}".format(orig_vmlinux))
+18 -10
tools/testing/selftests/kselftest/runner.sh
··· 33 33 { 34 34 # Make sure tests will time out if utility is available. 35 35 if [ -x /usr/bin/timeout ] ; then 36 - /usr/bin/timeout --foreground "$kselftest_timeout" "$1" 36 + /usr/bin/timeout --foreground "$kselftest_timeout" $1 37 37 else 38 - "$1" 38 + $1 39 39 fi 40 40 } 41 41 ··· 65 65 66 66 TEST_HDR_MSG="selftests: $DIR: $BASENAME_TEST" 67 67 echo "# $TEST_HDR_MSG" 68 - if [ ! -x "$TEST" ]; then 69 - echo -n "# Warning: file $TEST is " 70 - if [ ! -e "$TEST" ]; then 71 - echo "missing!" 72 - else 73 - echo "not executable, correct this." 74 - fi 68 + if [ ! -e "$TEST" ]; then 69 + echo "# Warning: file $TEST is missing!" 75 70 echo "not ok $test_num $TEST_HDR_MSG" 76 71 else 72 + cmd="./$BASENAME_TEST" 73 + if [ ! -x "$TEST" ]; then 74 + echo "# Warning: file $TEST is not executable" 75 + 76 + if [ $(head -n 1 "$TEST" | cut -c -2) = "#!" ] 77 + then 78 + interpreter=$(head -n 1 "$TEST" | cut -c 3-) 79 + cmd="$interpreter ./$BASENAME_TEST" 80 + else 81 + echo "not ok $test_num $TEST_HDR_MSG" 82 + return 83 + fi 84 + fi 77 85 cd `dirname $TEST` > /dev/null 78 - ((((( tap_timeout ./$BASENAME_TEST 2>&1; echo $? >&3) | 86 + ((((( tap_timeout "$cmd" 2>&1; echo $? >&3) | 79 87 tap_prefix >&4) 3>&1) | 80 88 (read xs; exit $xs)) 4>>"$logfile" && 81 89 echo "ok $test_num $TEST_HDR_MSG") ||
+1
tools/testing/selftests/proc/.gitignore
··· 11 11 /proc-self-syscall 12 12 /proc-self-wchan 13 13 /proc-subset-pid 14 + /proc-tid0 14 15 /proc-uptime-001 15 16 /proc-uptime-002 16 17 /read
+2
tools/testing/selftests/proc/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 CFLAGS += -Wall -O2 -Wno-unused-function 3 3 CFLAGS += -D_GNU_SOURCE 4 + LDFLAGS += -pthread 4 5 5 6 TEST_GEN_PROGS := 6 7 TEST_GEN_PROGS += fd-001-lookup ··· 14 13 TEST_GEN_PROGS += proc-self-syscall 15 14 TEST_GEN_PROGS += proc-self-wchan 16 15 TEST_GEN_PROGS += proc-subset-pid 16 + TEST_GEN_PROGS += proc-tid0 17 17 TEST_GEN_PROGS += proc-uptime-001 18 18 TEST_GEN_PROGS += proc-uptime-002 19 19 TEST_GEN_PROGS += read
+81
tools/testing/selftests/proc/proc-tid0.c
··· 1 + /* 2 + * Copyright (c) 2021 Alexey Dobriyan <adobriyan@gmail.com> 3 + * 4 + * Permission to use, copy, modify, and distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + // Test that /proc/*/task never contains "0". 17 + #include <sys/types.h> 18 + #include <dirent.h> 19 + #include <signal.h> 20 + #include <stdio.h> 21 + #include <stdlib.h> 22 + #include <string.h> 23 + #include <unistd.h> 24 + #include <pthread.h> 25 + 26 + static pid_t pid = -1; 27 + 28 + static void atexit_hook(void) 29 + { 30 + if (pid > 0) { 31 + kill(pid, SIGKILL); 32 + } 33 + } 34 + 35 + static void *f(void *_) 36 + { 37 + return NULL; 38 + } 39 + 40 + static void sigalrm(int _) 41 + { 42 + exit(0); 43 + } 44 + 45 + int main(void) 46 + { 47 + pid = fork(); 48 + if (pid == 0) { 49 + /* child */ 50 + while (1) { 51 + pthread_t pth; 52 + pthread_create(&pth, NULL, f, NULL); 53 + pthread_join(pth, NULL); 54 + } 55 + } else if (pid > 0) { 56 + /* parent */ 57 + atexit(atexit_hook); 58 + 59 + char buf[64]; 60 + snprintf(buf, sizeof(buf), "/proc/%u/task", pid); 61 + 62 + signal(SIGALRM, sigalrm); 63 + alarm(1); 64 + 65 + while (1) { 66 + DIR *d = opendir(buf); 67 + struct dirent *de; 68 + while ((de = readdir(d))) { 69 + if (strcmp(de->d_name, "0") == 0) { 70 + exit(1); 71 + } 72 + } 73 + closedir(d); 74 + } 75 + 76 + return 0; 77 + } else { 78 + perror("fork"); 79 + return 1; 80 + } 81 + }