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:
"VM:
- z3fold fixes and enhancements by Henry Burns and Vitaly Wool

- more accurate reclaimed slab caches calculations by Yafang Shao

- fix MAP_UNINITIALIZED UAPI symbol to not depend on config, by
Christoph Hellwig

- !CONFIG_MMU fixes by Christoph Hellwig

- new novmcoredd parameter to omit device dumps from vmcore, by
Kairui Song

- new test_meminit module for testing heap and pagealloc
initialization, by Alexander Potapenko

- ioremap improvements for huge mappings, by Anshuman Khandual

- generalize kprobe page fault handling, by Anshuman Khandual

- device-dax hotplug fixes and improvements, by Pavel Tatashin

- enable synchronous DAX fault on powerpc, by Aneesh Kumar K.V

- add pte_devmap() support for arm64, by Robin Murphy

- unify locked_vm accounting with a helper, by Daniel Jordan

- several misc fixes

core/lib:
- new typeof_member() macro including some users, by Alexey Dobriyan

- make BIT() and GENMASK() available in asm, by Masahiro Yamada

- changed LIST_POISON2 on x86_64 to 0xdead000000000122 for better
code generation, by Alexey Dobriyan

- rbtree code size optimizations, by Michel Lespinasse

- convert struct pid count to refcount_t, by Joel Fernandes

get_maintainer.pl:
- add --no-moderated switch to skip moderated ML's, by Joe Perches

misc:
- ptrace PTRACE_GET_SYSCALL_INFO interface

- coda updates

- gdb scripts, various"

[ Using merge message suggestion from Vlastimil Babka, with some editing - Linus ]

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (100 commits)
fs/select.c: use struct_size() in kmalloc()
mm: add account_locked_vm utility function
arm64: mm: implement pte_devmap support
mm: introduce ARCH_HAS_PTE_DEVMAP
mm: clean up is_device_*_page() definitions
mm/mmap: move common defines to mman-common.h
mm: move MAP_SYNC to asm-generic/mman-common.h
device-dax: "Hotremove" persistent memory that is used like normal RAM
mm/hotplug: make remove_memory() interface usable
device-dax: fix memory and resource leak if hotplug fails
include/linux/lz4.h: fix spelling and copy-paste errors in documentation
ipc/mqueue.c: only perform resource calculation if user valid
include/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT architectures
scripts/gdb: add helpers to find and list devices
scripts/gdb: add lx-genpd-summary command
drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl
kernel/pid.c: convert struct pid count to refcount_t
drivers/rapidio/devices/rio_mport_cdev.c: NUL terminate some strings
select: shift restore_saved_sigmask_unless() into poll_select_copy_remaining()
select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR
...

+2672 -1223
+11
Documentation/admin-guide/kernel-parameters.txt
··· 2877 2877 /sys/module/printk/parameters/console_suspend) to 2878 2878 turn on/off it dynamically. 2879 2879 2880 + novmcoredd [KNL,KDUMP] 2881 + Disable device dump. Device dump allows drivers to 2882 + append dump data to vmcore so you can collect driver 2883 + specified debug info. Drivers can append the data 2884 + without any limit and this data is stored in memory, 2885 + so this may cause significant memory stress. Disabling 2886 + device dump can help save memory but the driver debug 2887 + data will be no longer available. This parameter 2888 + is only available when CONFIG_PROC_VMCORE_DEVICE_DUMP 2889 + is set. 2890 + 2880 2891 noaliencache [MM, NUMA, SLAB] Disables the allocation of alien 2881 2892 caches in the slab allocator. Saves per-node memory, 2882 2893 but will impact performance.
+1 -1
Documentation/devicetree/bindings/usb/s3c2410-usb.txt
··· 4 4 5 5 Required properties: 6 6 - compatible: should be "samsung,s3c2410-ohci" for USB host controller 7 - - reg: address and lenght of the controller memory mapped region 7 + - reg: address and length of the controller memory mapped region 8 8 - interrupts: interrupt number for the USB OHCI controller 9 9 - clocks: Should reference the bus and host clocks 10 10 - clock-names: Should contain two strings
+7 -4
Documentation/filesystems/coda.txt
··· 481 481 482 482 483 483 484 - 484 + struct coda_timespec { 485 + int64_t tv_sec; /* seconds */ 486 + long tv_nsec; /* nanoseconds */ 487 + }; 485 488 486 489 struct coda_vattr { 487 490 enum coda_vtype va_type; /* vnode type (for create) */ ··· 496 493 long va_fileid; /* file id */ 497 494 u_quad_t va_size; /* file size in bytes */ 498 495 long va_blocksize; /* blocksize preferred for i/o */ 499 - struct timespec va_atime; /* time of last access */ 500 - struct timespec va_mtime; /* time of last modification */ 501 - struct timespec va_ctime; /* time file changed */ 496 + struct coda_timespec va_atime; /* time of last access */ 497 + struct coda_timespec va_mtime; /* time of last modification */ 498 + struct coda_timespec va_ctime; /* time file changed */ 502 499 u_long va_gen; /* generation number of file */ 503 500 u_long va_flags; /* flags defined for file */ 504 501 dev_t va_rdev; /* device special file represents */
-5
arch/alpha/include/asm/io.h
··· 93 93 94 94 #define page_to_phys(page) page_to_pa(page) 95 95 96 - static inline dma_addr_t __deprecated isa_page_to_bus(struct page *page) 97 - { 98 - return page_to_phys(page); 99 - } 100 - 101 96 /* Maximum PIO space address supported? */ 102 97 #define IO_SPACE_LIMIT 0xffff 103 98
+4 -4
arch/arc/include/asm/pgtable.h
··· 32 32 #ifndef _ASM_ARC_PGTABLE_H 33 33 #define _ASM_ARC_PGTABLE_H 34 34 35 - #include <linux/const.h> 35 + #include <linux/bits.h> 36 36 #define __ARCH_USE_5LEVEL_HACK 37 37 #include <asm-generic/pgtable-nopmd.h> 38 38 #include <asm/page.h> ··· 215 215 #define BITS_FOR_PTE (PGDIR_SHIFT - PAGE_SHIFT) 216 216 #define BITS_FOR_PGD (32 - PGDIR_SHIFT) 217 217 218 - #define PGDIR_SIZE _BITUL(PGDIR_SHIFT) /* vaddr span, not PDG sz */ 218 + #define PGDIR_SIZE BIT(PGDIR_SHIFT) /* vaddr span, not PDG sz */ 219 219 #define PGDIR_MASK (~(PGDIR_SIZE-1)) 220 220 221 - #define PTRS_PER_PTE _BITUL(BITS_FOR_PTE) 222 - #define PTRS_PER_PGD _BITUL(BITS_FOR_PGD) 221 + #define PTRS_PER_PTE BIT(BITS_FOR_PTE) 222 + #define PTRS_PER_PGD BIT(BITS_FOR_PGD) 223 223 224 224 /* 225 225 * Number of entries a user land program use.
+8 -7
arch/arc/plat-eznps/include/plat/ctop.h
··· 10 10 #error "Incorrect ctop.h include" 11 11 #endif 12 12 13 + #include <linux/bits.h> 13 14 #include <linux/types.h> 14 15 #include <soc/nps/common.h> 15 16 ··· 52 51 #define CTOP_INST_AXOR_DI_R2_R2_R3 0x4A664C06 53 52 54 53 /* Do not use D$ for address in 2G-3G */ 55 - #define HW_COMPLY_KRN_NOT_D_CACHED _BITUL(28) 54 + #define HW_COMPLY_KRN_NOT_D_CACHED BIT(28) 56 55 57 56 #define NPS_MSU_EN_CFG 0x80 58 57 #define NPS_CRG_BLKID 0x480 59 - #define NPS_CRG_SYNC_BIT _BITUL(0) 58 + #define NPS_CRG_SYNC_BIT BIT(0) 60 59 #define NPS_GIM_BLKID 0x5C0 61 60 62 61 /* GIM registers and fields*/ 63 - #define NPS_GIM_UART_LINE _BITUL(7) 64 - #define NPS_GIM_DBG_LAN_EAST_TX_DONE_LINE _BITUL(10) 65 - #define NPS_GIM_DBG_LAN_EAST_RX_RDY_LINE _BITUL(11) 66 - #define NPS_GIM_DBG_LAN_WEST_TX_DONE_LINE _BITUL(25) 67 - #define NPS_GIM_DBG_LAN_WEST_RX_RDY_LINE _BITUL(26) 62 + #define NPS_GIM_UART_LINE BIT(7) 63 + #define NPS_GIM_DBG_LAN_EAST_TX_DONE_LINE BIT(10) 64 + #define NPS_GIM_DBG_LAN_EAST_RX_RDY_LINE BIT(11) 65 + #define NPS_GIM_DBG_LAN_WEST_TX_DONE_LINE BIT(25) 66 + #define NPS_GIM_DBG_LAN_WEST_RX_RDY_LINE BIT(26) 68 67 69 68 #ifndef __ASSEMBLY__ 70 69 /* Functional registers definition */
-1
arch/arm/include/asm/io.h
··· 30 30 * ISA I/O bus memory addresses are 1:1 with the physical address. 31 31 */ 32 32 #define isa_virt_to_bus virt_to_phys 33 - #define isa_page_to_bus page_to_phys 34 33 #define isa_bus_to_virt phys_to_virt 35 34 36 35 /*
+1 -23
arch/arm/mm/fault.c
··· 27 27 28 28 #ifdef CONFIG_MMU 29 29 30 - #ifdef CONFIG_KPROBES 31 - static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr) 32 - { 33 - int ret = 0; 34 - 35 - if (!user_mode(regs)) { 36 - /* kprobe_running() needs smp_processor_id() */ 37 - preempt_disable(); 38 - if (kprobe_running() && kprobe_fault_handler(regs, fsr)) 39 - ret = 1; 40 - preempt_enable(); 41 - } 42 - 43 - return ret; 44 - } 45 - #else 46 - static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr) 47 - { 48 - return 0; 49 - } 50 - #endif 51 - 52 30 /* 53 31 * This is useful to dump out the page tables associated with 54 32 * 'addr' in mm 'mm'. ··· 243 265 vm_fault_t fault; 244 266 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; 245 267 246 - if (notify_page_fault(regs, fsr)) 268 + if (kprobe_page_fault(regs, fsr)) 247 269 return 0; 248 270 249 271 tsk = current;
+1
arch/arm64/Kconfig
··· 24 24 select ARCH_HAS_KCOV 25 25 select ARCH_HAS_KEEPINITRD 26 26 select ARCH_HAS_MEMBARRIER_SYNC_CORE 27 + select ARCH_HAS_PTE_DEVMAP 27 28 select ARCH_HAS_PTE_SPECIAL 28 29 select ARCH_HAS_SETUP_DMA_OPS 29 30 select ARCH_HAS_SET_DIRECT_MAP
+1
arch/arm64/include/asm/pgtable-prot.h
··· 16 16 #define PTE_WRITE (PTE_DBM) /* same as DBM (51) */ 17 17 #define PTE_DIRTY (_AT(pteval_t, 1) << 55) 18 18 #define PTE_SPECIAL (_AT(pteval_t, 1) << 56) 19 + #define PTE_DEVMAP (_AT(pteval_t, 1) << 57) 19 20 #define PTE_PROT_NONE (_AT(pteval_t, 1) << 58) /* only when !PTE_VALID */ 20 21 21 22 #ifndef __ASSEMBLY__
+21
arch/arm64/include/asm/pgtable.h
··· 79 79 #define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE)) 80 80 #define pte_user_exec(pte) (!(pte_val(pte) & PTE_UXN)) 81 81 #define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT)) 82 + #define pte_devmap(pte) (!!(pte_val(pte) & PTE_DEVMAP)) 82 83 83 84 #define pte_cont_addr_end(addr, end) \ 84 85 ({ unsigned long __boundary = ((addr) + CONT_PTE_SIZE) & CONT_PTE_MASK; \ ··· 205 204 static inline pmd_t pmd_mkcont(pmd_t pmd) 206 205 { 207 206 return __pmd(pmd_val(pmd) | PMD_SECT_CONT); 207 + } 208 + 209 + static inline pte_t pte_mkdevmap(pte_t pte) 210 + { 211 + return set_pte_bit(pte, __pgprot(PTE_DEVMAP)); 208 212 } 209 213 210 214 static inline void set_pte(pte_t *ptep, pte_t pte) ··· 393 387 #define pmd_write(pmd) pte_write(pmd_pte(pmd)) 394 388 395 389 #define pmd_mkhuge(pmd) (__pmd(pmd_val(pmd) & ~PMD_TABLE_BIT)) 390 + 391 + #ifdef CONFIG_TRANSPARENT_HUGEPAGE 392 + #define pmd_devmap(pmd) pte_devmap(pmd_pte(pmd)) 393 + #endif 394 + #define pmd_mkdevmap(pmd) pte_pmd(pte_mkdevmap(pmd_pte(pmd))) 396 395 397 396 #define __pmd_to_phys(pmd) __pte_to_phys(pmd_pte(pmd)) 398 397 #define __phys_to_pmd_val(phys) __phys_to_pte_val(phys) ··· 683 672 pmd_t entry, int dirty) 684 673 { 685 674 return ptep_set_access_flags(vma, address, (pte_t *)pmdp, pmd_pte(entry), dirty); 675 + } 676 + 677 + static inline int pud_devmap(pud_t pud) 678 + { 679 + return 0; 680 + } 681 + 682 + static inline int pgd_devmap(pgd_t pgd) 683 + { 684 + return 0; 686 685 } 687 686 #endif 688 687
+40 -40
arch/arm64/include/asm/sysreg.h
··· 9 9 #ifndef __ASM_SYSREG_H 10 10 #define __ASM_SYSREG_H 11 11 12 - #include <linux/const.h> 12 + #include <linux/bits.h> 13 13 #include <linux/stringify.h> 14 14 15 15 /* ··· 478 478 #define SYS_CNTV_CVAL_EL02 sys_reg(3, 5, 14, 3, 2) 479 479 480 480 /* Common SCTLR_ELx flags. */ 481 - #define SCTLR_ELx_DSSBS (_BITUL(44)) 482 - #define SCTLR_ELx_ENIA (_BITUL(31)) 483 - #define SCTLR_ELx_ENIB (_BITUL(30)) 484 - #define SCTLR_ELx_ENDA (_BITUL(27)) 485 - #define SCTLR_ELx_EE (_BITUL(25)) 486 - #define SCTLR_ELx_IESB (_BITUL(21)) 487 - #define SCTLR_ELx_WXN (_BITUL(19)) 488 - #define SCTLR_ELx_ENDB (_BITUL(13)) 489 - #define SCTLR_ELx_I (_BITUL(12)) 490 - #define SCTLR_ELx_SA (_BITUL(3)) 491 - #define SCTLR_ELx_C (_BITUL(2)) 492 - #define SCTLR_ELx_A (_BITUL(1)) 493 - #define SCTLR_ELx_M (_BITUL(0)) 481 + #define SCTLR_ELx_DSSBS (BIT(44)) 482 + #define SCTLR_ELx_ENIA (BIT(31)) 483 + #define SCTLR_ELx_ENIB (BIT(30)) 484 + #define SCTLR_ELx_ENDA (BIT(27)) 485 + #define SCTLR_ELx_EE (BIT(25)) 486 + #define SCTLR_ELx_IESB (BIT(21)) 487 + #define SCTLR_ELx_WXN (BIT(19)) 488 + #define SCTLR_ELx_ENDB (BIT(13)) 489 + #define SCTLR_ELx_I (BIT(12)) 490 + #define SCTLR_ELx_SA (BIT(3)) 491 + #define SCTLR_ELx_C (BIT(2)) 492 + #define SCTLR_ELx_A (BIT(1)) 493 + #define SCTLR_ELx_M (BIT(0)) 494 494 495 495 #define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ 496 496 SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_IESB) 497 497 498 498 /* SCTLR_EL2 specific flags. */ 499 - #define SCTLR_EL2_RES1 ((_BITUL(4)) | (_BITUL(5)) | (_BITUL(11)) | (_BITUL(16)) | \ 500 - (_BITUL(18)) | (_BITUL(22)) | (_BITUL(23)) | (_BITUL(28)) | \ 501 - (_BITUL(29))) 502 - #define SCTLR_EL2_RES0 ((_BITUL(6)) | (_BITUL(7)) | (_BITUL(8)) | (_BITUL(9)) | \ 503 - (_BITUL(10)) | (_BITUL(13)) | (_BITUL(14)) | (_BITUL(15)) | \ 504 - (_BITUL(17)) | (_BITUL(20)) | (_BITUL(24)) | (_BITUL(26)) | \ 505 - (_BITUL(27)) | (_BITUL(30)) | (_BITUL(31)) | \ 499 + #define SCTLR_EL2_RES1 ((BIT(4)) | (BIT(5)) | (BIT(11)) | (BIT(16)) | \ 500 + (BIT(18)) | (BIT(22)) | (BIT(23)) | (BIT(28)) | \ 501 + (BIT(29))) 502 + #define SCTLR_EL2_RES0 ((BIT(6)) | (BIT(7)) | (BIT(8)) | (BIT(9)) | \ 503 + (BIT(10)) | (BIT(13)) | (BIT(14)) | (BIT(15)) | \ 504 + (BIT(17)) | (BIT(20)) | (BIT(24)) | (BIT(26)) | \ 505 + (BIT(27)) | (BIT(30)) | (BIT(31)) | \ 506 506 (0xffffefffUL << 32)) 507 507 508 508 #ifdef CONFIG_CPU_BIG_ENDIAN ··· 524 524 #endif 525 525 526 526 /* SCTLR_EL1 specific flags. */ 527 - #define SCTLR_EL1_UCI (_BITUL(26)) 528 - #define SCTLR_EL1_E0E (_BITUL(24)) 529 - #define SCTLR_EL1_SPAN (_BITUL(23)) 530 - #define SCTLR_EL1_NTWE (_BITUL(18)) 531 - #define SCTLR_EL1_NTWI (_BITUL(16)) 532 - #define SCTLR_EL1_UCT (_BITUL(15)) 533 - #define SCTLR_EL1_DZE (_BITUL(14)) 534 - #define SCTLR_EL1_UMA (_BITUL(9)) 535 - #define SCTLR_EL1_SED (_BITUL(8)) 536 - #define SCTLR_EL1_ITD (_BITUL(7)) 537 - #define SCTLR_EL1_CP15BEN (_BITUL(5)) 538 - #define SCTLR_EL1_SA0 (_BITUL(4)) 527 + #define SCTLR_EL1_UCI (BIT(26)) 528 + #define SCTLR_EL1_E0E (BIT(24)) 529 + #define SCTLR_EL1_SPAN (BIT(23)) 530 + #define SCTLR_EL1_NTWE (BIT(18)) 531 + #define SCTLR_EL1_NTWI (BIT(16)) 532 + #define SCTLR_EL1_UCT (BIT(15)) 533 + #define SCTLR_EL1_DZE (BIT(14)) 534 + #define SCTLR_EL1_UMA (BIT(9)) 535 + #define SCTLR_EL1_SED (BIT(8)) 536 + #define SCTLR_EL1_ITD (BIT(7)) 537 + #define SCTLR_EL1_CP15BEN (BIT(5)) 538 + #define SCTLR_EL1_SA0 (BIT(4)) 539 539 540 - #define SCTLR_EL1_RES1 ((_BITUL(11)) | (_BITUL(20)) | (_BITUL(22)) | (_BITUL(28)) | \ 541 - (_BITUL(29))) 542 - #define SCTLR_EL1_RES0 ((_BITUL(6)) | (_BITUL(10)) | (_BITUL(13)) | (_BITUL(17)) | \ 543 - (_BITUL(27)) | (_BITUL(30)) | (_BITUL(31)) | \ 540 + #define SCTLR_EL1_RES1 ((BIT(11)) | (BIT(20)) | (BIT(22)) | (BIT(28)) | \ 541 + (BIT(29))) 542 + #define SCTLR_EL1_RES0 ((BIT(6)) | (BIT(10)) | (BIT(13)) | (BIT(17)) | \ 543 + (BIT(27)) | (BIT(30)) | (BIT(31)) | \ 544 544 (0xffffefffUL << 32)) 545 545 546 546 #ifdef CONFIG_CPU_BIG_ENDIAN ··· 756 756 #define ZCR_ELx_LEN_SIZE 9 757 757 #define ZCR_ELx_LEN_MASK 0x1ff 758 758 759 - #define CPACR_EL1_ZEN_EL1EN (_BITUL(16)) /* enable EL1 access */ 760 - #define CPACR_EL1_ZEN_EL0EN (_BITUL(17)) /* enable EL0 access, if EL1EN set */ 759 + #define CPACR_EL1_ZEN_EL1EN (BIT(16)) /* enable EL1 access */ 760 + #define CPACR_EL1_ZEN_EL0EN (BIT(17)) /* enable EL0 access, if EL1EN set */ 761 761 #define CPACR_EL1_ZEN (CPACR_EL1_ZEN_EL1EN | CPACR_EL1_ZEN_EL0EN) 762 762 763 763 764 764 /* Safe value for MPIDR_EL1: Bit31:RES1, Bit30:U:0, Bit24:MT:0 */ 765 - #define SYS_MPIDR_SAFE_VAL (_BITUL(31)) 765 + #define SYS_MPIDR_SAFE_VAL (BIT(31)) 766 766 767 767 #ifdef __ASSEMBLY__ 768 768
+1 -23
arch/arm64/mm/fault.c
··· 59 59 return debug_fault_info + DBG_ESR_EVT(esr); 60 60 } 61 61 62 - #ifdef CONFIG_KPROBES 63 - static inline int notify_page_fault(struct pt_regs *regs, unsigned int esr) 64 - { 65 - int ret = 0; 66 - 67 - /* kprobe_running() needs smp_processor_id() */ 68 - if (!user_mode(regs)) { 69 - preempt_disable(); 70 - if (kprobe_running() && kprobe_fault_handler(regs, esr)) 71 - ret = 1; 72 - preempt_enable(); 73 - } 74 - 75 - return ret; 76 - } 77 - #else 78 - static inline int notify_page_fault(struct pt_regs *regs, unsigned int esr) 79 - { 80 - return 0; 81 - } 82 - #endif 83 - 84 62 static void data_abort_decode(unsigned int esr) 85 63 { 86 64 pr_alert("Data abort info:\n"); ··· 412 434 unsigned long vm_flags = VM_READ | VM_WRITE; 413 435 unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; 414 436 415 - if (notify_page_fault(regs, esr)) 437 + if (kprobe_page_fault(regs, esr)) 416 438 return 0; 417 439 418 440 /*
+5
arch/arm64/mm/mmu.c
··· 942 942 return dt_virt; 943 943 } 944 944 945 + int __init arch_ioremap_p4d_supported(void) 946 + { 947 + return 0; 948 + } 949 + 945 950 int __init arch_ioremap_pud_supported(void) 946 951 { 947 952 /*
+14
arch/hexagon/include/asm/syscall.h
··· 9 9 #define _ASM_HEXAGON_SYSCALL_H 10 10 11 11 #include <uapi/linux/audit.h> 12 + #include <linux/err.h> 13 + #include <asm/ptrace.h> 12 14 13 15 typedef long (*syscall_fn)(unsigned long, unsigned long, 14 16 unsigned long, unsigned long, ··· 31 29 unsigned long *args) 32 30 { 33 31 memcpy(args, &(&regs->r00)[0], 6 * sizeof(args[0])); 32 + } 33 + 34 + static inline long syscall_get_error(struct task_struct *task, 35 + struct pt_regs *regs) 36 + { 37 + return IS_ERR_VALUE(regs->r00) ? regs->r00 : 0; 38 + } 39 + 40 + static inline long syscall_get_return_value(struct task_struct *task, 41 + struct pt_regs *regs) 42 + { 43 + return regs->r00; 34 44 } 35 45 36 46 static inline int syscall_get_arch(struct task_struct *task)
+1 -23
arch/ia64/mm/fault.c
··· 21 21 22 22 extern int die(char *, struct pt_regs *, long); 23 23 24 - #ifdef CONFIG_KPROBES 25 - static inline int notify_page_fault(struct pt_regs *regs, int trap) 26 - { 27 - int ret = 0; 28 - 29 - if (!user_mode(regs)) { 30 - /* kprobe_running() needs smp_processor_id() */ 31 - preempt_disable(); 32 - if (kprobe_running() && kprobe_fault_handler(regs, trap)) 33 - ret = 1; 34 - preempt_enable(); 35 - } 36 - 37 - return ret; 38 - } 39 - #else 40 - static inline int notify_page_fault(struct pt_regs *regs, int trap) 41 - { 42 - return 0; 43 - } 44 - #endif 45 - 46 24 /* 47 25 * Return TRUE if ADDRESS points at a page in the kernel's mapped segment 48 26 * (inside region 5, on ia64) and that page is present. ··· 94 116 /* 95 117 * This is to handle the kprobes on user space access instructions 96 118 */ 97 - if (notify_page_fault(regs, TRAP_BRKPT)) 119 + if (kprobe_page_fault(regs, TRAP_BRKPT)) 98 120 return; 99 121 100 122 if (user_mode(regs))
-2
arch/mips/include/asm/io.h
··· 149 149 return phys_to_virt(address); 150 150 } 151 151 152 - #define isa_page_to_bus page_to_phys 153 - 154 152 /* 155 153 * However PCI ones are not necessarily 1:1 and therefore these interfaces 156 154 * are forbidden in portable PCI drivers.
+1
arch/mips/include/asm/kprobes.h
··· 41 41 #define kretprobe_blacklist_size 0 42 42 43 43 void arch_remove_kprobe(struct kprobe *p); 44 + int kprobe_fault_handler(struct pt_regs *regs, int trapnr); 44 45 45 46 /* Architecture specific copy of original instruction*/ 46 47 struct arch_specific_insn {
+6
arch/mips/include/asm/syscall.h
··· 89 89 unreachable(); 90 90 } 91 91 92 + static inline long syscall_get_error(struct task_struct *task, 93 + struct pt_regs *regs) 94 + { 95 + return regs->regs[7] ? -regs->regs[2] : 0; 96 + } 97 + 92 98 static inline long syscall_get_return_value(struct task_struct *task, 93 99 struct pt_regs *regs) 94 100 {
+1 -1
arch/mips/kernel/kprobes.c
··· 398 398 return 1; 399 399 } 400 400 401 - static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr) 401 + int kprobe_fault_handler(struct pt_regs *regs, int trapnr) 402 402 { 403 403 struct kprobe *cur = kprobe_running(); 404 404 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
+17 -10
arch/nds32/include/asm/syscall.h
··· 26 26 * 27 27 * It's only valid to call this when @task is known to be blocked. 28 28 */ 29 - int syscall_get_nr(struct task_struct *task, struct pt_regs *regs) 29 + static inline int 30 + syscall_get_nr(struct task_struct *task, struct pt_regs *regs) 30 31 { 31 32 return regs->syscallno; 32 33 } ··· 48 47 * system call instruction. This may not be the same as what the 49 48 * register state looked like at system call entry tracing. 50 49 */ 51 - void syscall_rollback(struct task_struct *task, struct pt_regs *regs) 50 + static inline void 51 + syscall_rollback(struct task_struct *task, struct pt_regs *regs) 52 52 { 53 53 regs->uregs[0] = regs->orig_r0; 54 54 } ··· 64 62 * It's only valid to call this when @task is stopped for tracing on exit 65 63 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. 66 64 */ 67 - long syscall_get_error(struct task_struct *task, struct pt_regs *regs) 65 + static inline long 66 + syscall_get_error(struct task_struct *task, struct pt_regs *regs) 68 67 { 69 68 unsigned long error = regs->uregs[0]; 70 69 return IS_ERR_VALUE(error) ? error : 0; ··· 82 79 * It's only valid to call this when @task is stopped for tracing on exit 83 80 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. 84 81 */ 85 - long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) 82 + static inline long 83 + syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) 86 84 { 87 85 return regs->uregs[0]; 88 86 } ··· 103 99 * It's only valid to call this when @task is stopped for tracing on exit 104 100 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. 105 101 */ 106 - void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, 107 - int error, long val) 102 + static inline void 103 + syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, 104 + int error, long val) 108 105 { 109 106 regs->uregs[0] = (long)error ? error : val; 110 107 } ··· 123 118 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. 124 119 */ 125 120 #define SYSCALL_MAX_ARGS 6 126 - void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, 127 - unsigned long *args) 121 + static inline void 122 + syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, 123 + unsigned long *args) 128 124 { 129 125 args[0] = regs->orig_r0; 130 126 args++; ··· 144 138 * It's only valid to call this when @task is stopped for tracing on 145 139 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. 146 140 */ 147 - void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, 148 - const unsigned long *args) 141 + static inline void 142 + syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, 143 + const unsigned long *args) 149 144 { 150 145 regs->orig_r0 = args[0]; 151 146 args++;
+7
arch/parisc/include/asm/syscall.h
··· 29 29 args[0] = regs->gr[26]; 30 30 } 31 31 32 + static inline long syscall_get_error(struct task_struct *task, 33 + struct pt_regs *regs) 34 + { 35 + unsigned long error = regs->gr[28]; 36 + return IS_ERR_VALUE(error) ? error : 0; 37 + } 38 + 32 39 static inline long syscall_get_return_value(struct task_struct *task, 33 40 struct pt_regs *regs) 34 41 {
+1 -1
arch/powerpc/Kconfig
··· 129 129 select ARCH_HAS_MMIOWB if PPC64 130 130 select ARCH_HAS_PHYS_TO_DMA 131 131 select ARCH_HAS_PMEM_API if PPC64 132 + select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 132 133 select ARCH_HAS_PTE_SPECIAL 133 134 select ARCH_HAS_MEMBARRIER_CALLBACKS 134 135 select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64 ··· 137 136 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 138 137 select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 139 138 select ARCH_HAS_UBSAN_SANITIZE_ALL 140 - select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 141 139 select ARCH_HAVE_NMI_SAFE_CMPXCHG 142 140 select ARCH_KEEP_MEMBLOCK 143 141 select ARCH_MIGHT_HAVE_PC_PARPORT
-1
arch/powerpc/include/asm/book3s/64/pgtable.h
··· 90 90 #define _PAGE_SOFT_DIRTY _RPAGE_SW3 /* software: software dirty tracking */ 91 91 #define _PAGE_SPECIAL _RPAGE_SW2 /* software: special page */ 92 92 #define _PAGE_DEVMAP _RPAGE_SW1 /* software: ZONE_DEVICE page */ 93 - #define __HAVE_ARCH_PTE_DEVMAP 94 93 95 94 /* 96 95 * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE
+10
arch/powerpc/include/asm/syscall.h
··· 35 35 regs->gpr[3] = regs->orig_gpr3; 36 36 } 37 37 38 + static inline long syscall_get_error(struct task_struct *task, 39 + struct pt_regs *regs) 40 + { 41 + /* 42 + * If the system call failed, 43 + * regs->gpr[3] contains a positive ERRORCODE. 44 + */ 45 + return (regs->ccr & 0x10000000UL) ? -regs->gpr[3] : 0; 46 + } 47 + 38 48 static inline long syscall_get_return_value(struct task_struct *task, 39 49 struct pt_regs *regs) 40 50 {
+1 -5
arch/powerpc/include/uapi/asm/mman.h
··· 21 21 #define MAP_DENYWRITE 0x0800 /* ETXTBSY */ 22 22 #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ 23 23 24 + 24 25 #define MCL_CURRENT 0x2000 /* lock all currently mapped pages */ 25 26 #define MCL_FUTURE 0x4000 /* lock all additions to address space */ 26 27 #define MCL_ONFAULT 0x8000 /* lock all pages that are faulted in */ 27 - 28 - #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 29 - #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 30 - #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 31 - #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 32 28 33 29 /* Override any generic PKEY permission defines */ 34 30 #define PKEY_DISABLE_EXECUTE 0x4
+4 -40
arch/powerpc/kvm/book3s_64_vio.c
··· 19 19 #include <linux/anon_inodes.h> 20 20 #include <linux/iommu.h> 21 21 #include <linux/file.h> 22 + #include <linux/mm.h> 22 23 23 24 #include <asm/kvm_ppc.h> 24 25 #include <asm/kvm_book3s.h> ··· 44 43 (tce_pages * sizeof(struct page *)); 45 44 46 45 return tce_pages + ALIGN(stt_bytes, PAGE_SIZE) / PAGE_SIZE; 47 - } 48 - 49 - static long kvmppc_account_memlimit(unsigned long stt_pages, bool inc) 50 - { 51 - long ret = 0; 52 - 53 - if (!current || !current->mm) 54 - return ret; /* process exited */ 55 - 56 - down_write(&current->mm->mmap_sem); 57 - 58 - if (inc) { 59 - unsigned long locked, lock_limit; 60 - 61 - locked = current->mm->locked_vm + stt_pages; 62 - lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; 63 - if (locked > lock_limit && !capable(CAP_IPC_LOCK)) 64 - ret = -ENOMEM; 65 - else 66 - current->mm->locked_vm += stt_pages; 67 - } else { 68 - if (WARN_ON_ONCE(stt_pages > current->mm->locked_vm)) 69 - stt_pages = current->mm->locked_vm; 70 - 71 - current->mm->locked_vm -= stt_pages; 72 - } 73 - 74 - pr_debug("[%d] RLIMIT_MEMLOCK KVM %c%ld %ld/%ld%s\n", current->pid, 75 - inc ? '+' : '-', 76 - stt_pages << PAGE_SHIFT, 77 - current->mm->locked_vm << PAGE_SHIFT, 78 - rlimit(RLIMIT_MEMLOCK), 79 - ret ? " - exceeded" : ""); 80 - 81 - up_write(&current->mm->mmap_sem); 82 - 83 - return ret; 84 46 } 85 47 86 48 static void kvm_spapr_tce_iommu_table_free(struct rcu_head *head) ··· 255 291 256 292 kvm_put_kvm(stt->kvm); 257 293 258 - kvmppc_account_memlimit( 294 + account_locked_vm(current->mm, 259 295 kvmppc_stt_pages(kvmppc_tce_pages(stt->size)), false); 260 296 call_rcu(&stt->rcu, release_spapr_tce_table); 261 297 ··· 280 316 return -EINVAL; 281 317 282 318 npages = kvmppc_tce_pages(size); 283 - ret = kvmppc_account_memlimit(kvmppc_stt_pages(npages), true); 319 + ret = account_locked_vm(current->mm, kvmppc_stt_pages(npages), true); 284 320 if (ret) 285 321 return ret; 286 322 ··· 326 362 327 363 kfree(stt); 328 364 fail_acct: 329 - kvmppc_account_memlimit(kvmppc_stt_pages(npages), false); 365 + account_locked_vm(current->mm, kvmppc_stt_pages(npages), false); 330 366 return ret; 331 367 } 332 368
+4 -37
arch/powerpc/mm/book3s64/iommu_api.c
··· 14 14 #include <linux/hugetlb.h> 15 15 #include <linux/swap.h> 16 16 #include <linux/sizes.h> 17 + #include <linux/mm.h> 17 18 #include <asm/mmu_context.h> 18 19 #include <asm/pte-walk.h> 19 20 #include <linux/mm_inline.h> ··· 47 46 u64 dev_hpa; /* Device memory base address */ 48 47 }; 49 48 50 - static long mm_iommu_adjust_locked_vm(struct mm_struct *mm, 51 - unsigned long npages, bool incr) 52 - { 53 - long ret = 0, locked, lock_limit; 54 - 55 - if (!npages) 56 - return 0; 57 - 58 - down_write(&mm->mmap_sem); 59 - 60 - if (incr) { 61 - locked = mm->locked_vm + npages; 62 - lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; 63 - if (locked > lock_limit && !capable(CAP_IPC_LOCK)) 64 - ret = -ENOMEM; 65 - else 66 - mm->locked_vm += npages; 67 - } else { 68 - if (WARN_ON_ONCE(npages > mm->locked_vm)) 69 - npages = mm->locked_vm; 70 - mm->locked_vm -= npages; 71 - } 72 - 73 - pr_debug("[%d] RLIMIT_MEMLOCK HASH64 %c%ld %ld/%ld\n", 74 - current ? current->pid : 0, 75 - incr ? '+' : '-', 76 - npages << PAGE_SHIFT, 77 - mm->locked_vm << PAGE_SHIFT, 78 - rlimit(RLIMIT_MEMLOCK)); 79 - up_write(&mm->mmap_sem); 80 - 81 - return ret; 82 - } 83 - 84 49 bool mm_iommu_preregistered(struct mm_struct *mm) 85 50 { 86 51 return !list_empty(&mm->context.iommu_group_mem_list); ··· 63 96 unsigned long entry, chunk; 64 97 65 98 if (dev_hpa == MM_IOMMU_TABLE_INVALID_HPA) { 66 - ret = mm_iommu_adjust_locked_vm(mm, entries, true); 99 + ret = account_locked_vm(mm, entries, true); 67 100 if (ret) 68 101 return ret; 69 102 ··· 178 211 kfree(mem); 179 212 180 213 unlock_exit: 181 - mm_iommu_adjust_locked_vm(mm, locked_entries, false); 214 + account_locked_vm(mm, locked_entries, false); 182 215 183 216 return ret; 184 217 } ··· 278 311 unlock_exit: 279 312 mutex_unlock(&mem_list_mutex); 280 313 281 - mm_iommu_adjust_locked_vm(mm, unlock_entries, false); 314 + account_locked_vm(mm, unlock_entries, false); 282 315 283 316 return ret; 284 317 }
+5
arch/powerpc/mm/book3s64/radix_pgtable.c
··· 1237 1237 return 0; 1238 1238 } 1239 1239 } 1240 + 1241 + int __init arch_ioremap_p4d_supported(void) 1242 + { 1243 + return 0; 1244 + }
+2 -21
arch/powerpc/mm/fault.c
··· 42 42 #include <asm/debug.h> 43 43 #include <asm/kup.h> 44 44 45 - static inline bool notify_page_fault(struct pt_regs *regs) 46 - { 47 - bool ret = false; 48 - 49 - #ifdef CONFIG_KPROBES 50 - /* kprobe_running() needs smp_processor_id() */ 51 - if (!user_mode(regs)) { 52 - preempt_disable(); 53 - if (kprobe_running() && kprobe_fault_handler(regs, 11)) 54 - ret = true; 55 - preempt_enable(); 56 - } 57 - #endif /* CONFIG_KPROBES */ 58 - 59 - if (unlikely(debugger_fault_handler(regs))) 60 - ret = true; 61 - 62 - return ret; 63 - } 64 - 65 45 /* 66 46 * Check whether the instruction inst is a store using 67 47 * an update addressing form which will update r1. ··· 441 461 int is_write = page_fault_is_write(error_code); 442 462 vm_fault_t fault, major = 0; 443 463 bool must_retry = false; 464 + bool kprobe_fault = kprobe_page_fault(regs, 11); 444 465 445 - if (notify_page_fault(regs)) 466 + if (unlikely(debugger_fault_handler(regs) || kprobe_fault)) 446 467 return 0; 447 468 448 469 if (unlikely(page_fault_is_bad(error_code))) {
+18 -18
arch/s390/include/asm/ctl_reg.h
··· 8 8 #ifndef __ASM_CTL_REG_H 9 9 #define __ASM_CTL_REG_H 10 10 11 - #include <linux/const.h> 11 + #include <linux/bits.h> 12 12 13 - #define CR0_CLOCK_COMPARATOR_SIGN _BITUL(63 - 10) 14 - #define CR0_EMERGENCY_SIGNAL_SUBMASK _BITUL(63 - 49) 15 - #define CR0_EXTERNAL_CALL_SUBMASK _BITUL(63 - 50) 16 - #define CR0_CLOCK_COMPARATOR_SUBMASK _BITUL(63 - 52) 17 - #define CR0_CPU_TIMER_SUBMASK _BITUL(63 - 53) 18 - #define CR0_SERVICE_SIGNAL_SUBMASK _BITUL(63 - 54) 19 - #define CR0_UNUSED_56 _BITUL(63 - 56) 20 - #define CR0_INTERRUPT_KEY_SUBMASK _BITUL(63 - 57) 21 - #define CR0_MEASUREMENT_ALERT_SUBMASK _BITUL(63 - 58) 13 + #define CR0_CLOCK_COMPARATOR_SIGN BIT(63 - 10) 14 + #define CR0_EMERGENCY_SIGNAL_SUBMASK BIT(63 - 49) 15 + #define CR0_EXTERNAL_CALL_SUBMASK BIT(63 - 50) 16 + #define CR0_CLOCK_COMPARATOR_SUBMASK BIT(63 - 52) 17 + #define CR0_CPU_TIMER_SUBMASK BIT(63 - 53) 18 + #define CR0_SERVICE_SIGNAL_SUBMASK BIT(63 - 54) 19 + #define CR0_UNUSED_56 BIT(63 - 56) 20 + #define CR0_INTERRUPT_KEY_SUBMASK BIT(63 - 57) 21 + #define CR0_MEASUREMENT_ALERT_SUBMASK BIT(63 - 58) 22 22 23 - #define CR2_GUARDED_STORAGE _BITUL(63 - 59) 23 + #define CR2_GUARDED_STORAGE BIT(63 - 59) 24 24 25 - #define CR14_UNUSED_32 _BITUL(63 - 32) 26 - #define CR14_UNUSED_33 _BITUL(63 - 33) 27 - #define CR14_CHANNEL_REPORT_SUBMASK _BITUL(63 - 35) 28 - #define CR14_RECOVERY_SUBMASK _BITUL(63 - 36) 29 - #define CR14_DEGRADATION_SUBMASK _BITUL(63 - 37) 30 - #define CR14_EXTERNAL_DAMAGE_SUBMASK _BITUL(63 - 38) 31 - #define CR14_WARNING_SUBMASK _BITUL(63 - 39) 25 + #define CR14_UNUSED_32 BIT(63 - 32) 26 + #define CR14_UNUSED_33 BIT(63 - 33) 27 + #define CR14_CHANNEL_REPORT_SUBMASK BIT(63 - 35) 28 + #define CR14_RECOVERY_SUBMASK BIT(63 - 36) 29 + #define CR14_DEGRADATION_SUBMASK BIT(63 - 37) 30 + #define CR14_EXTERNAL_DAMAGE_SUBMASK BIT(63 - 38) 31 + #define CR14_WARNING_SUBMASK BIT(63 - 39) 32 32 33 33 #ifndef __ASSEMBLY__ 34 34
+10 -10
arch/s390/include/asm/nmi.h
··· 12 12 #ifndef _ASM_S390_NMI_H 13 13 #define _ASM_S390_NMI_H 14 14 15 - #include <linux/const.h> 15 + #include <linux/bits.h> 16 16 #include <linux/types.h> 17 17 18 18 #define MCIC_SUBCLASS_MASK (1ULL<<63 | 1ULL<<62 | 1ULL<<61 | \ ··· 20 20 1ULL<<55 | 1ULL<<54 | 1ULL<<53 | \ 21 21 1ULL<<52 | 1ULL<<47 | 1ULL<<46 | \ 22 22 1ULL<<45 | 1ULL<<44) 23 - #define MCCK_CODE_SYSTEM_DAMAGE _BITUL(63) 24 - #define MCCK_CODE_EXT_DAMAGE _BITUL(63 - 5) 25 - #define MCCK_CODE_CP _BITUL(63 - 9) 26 - #define MCCK_CODE_CPU_TIMER_VALID _BITUL(63 - 46) 27 - #define MCCK_CODE_PSW_MWP_VALID _BITUL(63 - 20) 28 - #define MCCK_CODE_PSW_IA_VALID _BITUL(63 - 23) 29 - #define MCCK_CODE_CR_VALID _BITUL(63 - 29) 30 - #define MCCK_CODE_GS_VALID _BITUL(63 - 36) 31 - #define MCCK_CODE_FC_VALID _BITUL(63 - 43) 23 + #define MCCK_CODE_SYSTEM_DAMAGE BIT(63) 24 + #define MCCK_CODE_EXT_DAMAGE BIT(63 - 5) 25 + #define MCCK_CODE_CP BIT(63 - 9) 26 + #define MCCK_CODE_CPU_TIMER_VALID BIT(63 - 46) 27 + #define MCCK_CODE_PSW_MWP_VALID BIT(63 - 20) 28 + #define MCCK_CODE_PSW_IA_VALID BIT(63 - 23) 29 + #define MCCK_CODE_CR_VALID BIT(63 - 29) 30 + #define MCCK_CODE_GS_VALID BIT(63 - 36) 31 + #define MCCK_CODE_FC_VALID BIT(63 - 43) 32 32 33 33 #ifndef __ASSEMBLY__ 34 34
+10 -10
arch/s390/include/asm/processor.h
··· 12 12 #ifndef __ASM_S390_PROCESSOR_H 13 13 #define __ASM_S390_PROCESSOR_H 14 14 15 - #include <linux/const.h> 15 + #include <linux/bits.h> 16 16 17 17 #define CIF_MCCK_PENDING 0 /* machine check handling is pending */ 18 18 #define CIF_ASCE_PRIMARY 1 /* primary asce needs fixup / uaccess */ ··· 24 24 #define CIF_MCCK_GUEST 7 /* machine check happening in guest */ 25 25 #define CIF_DEDICATED_CPU 8 /* this CPU is dedicated */ 26 26 27 - #define _CIF_MCCK_PENDING _BITUL(CIF_MCCK_PENDING) 28 - #define _CIF_ASCE_PRIMARY _BITUL(CIF_ASCE_PRIMARY) 29 - #define _CIF_ASCE_SECONDARY _BITUL(CIF_ASCE_SECONDARY) 30 - #define _CIF_NOHZ_DELAY _BITUL(CIF_NOHZ_DELAY) 31 - #define _CIF_FPU _BITUL(CIF_FPU) 32 - #define _CIF_IGNORE_IRQ _BITUL(CIF_IGNORE_IRQ) 33 - #define _CIF_ENABLED_WAIT _BITUL(CIF_ENABLED_WAIT) 34 - #define _CIF_MCCK_GUEST _BITUL(CIF_MCCK_GUEST) 35 - #define _CIF_DEDICATED_CPU _BITUL(CIF_DEDICATED_CPU) 27 + #define _CIF_MCCK_PENDING BIT(CIF_MCCK_PENDING) 28 + #define _CIF_ASCE_PRIMARY BIT(CIF_ASCE_PRIMARY) 29 + #define _CIF_ASCE_SECONDARY BIT(CIF_ASCE_SECONDARY) 30 + #define _CIF_NOHZ_DELAY BIT(CIF_NOHZ_DELAY) 31 + #define _CIF_FPU BIT(CIF_FPU) 32 + #define _CIF_IGNORE_IRQ BIT(CIF_IGNORE_IRQ) 33 + #define _CIF_ENABLED_WAIT BIT(CIF_ENABLED_WAIT) 34 + #define _CIF_MCCK_GUEST BIT(CIF_MCCK_GUEST) 35 + #define _CIF_DEDICATED_CPU BIT(CIF_DEDICATED_CPU) 36 36 37 37 #ifndef __ASSEMBLY__ 38 38
+5 -5
arch/s390/include/asm/ptrace.h
··· 7 7 #ifndef _S390_PTRACE_H 8 8 #define _S390_PTRACE_H 9 9 10 - #include <linux/const.h> 10 + #include <linux/bits.h> 11 11 #include <uapi/asm/ptrace.h> 12 12 13 13 #define PIF_SYSCALL 0 /* inside a system call */ ··· 15 15 #define PIF_SYSCALL_RESTART 2 /* restart the current system call */ 16 16 #define PIF_GUEST_FAULT 3 /* indicates program check in sie64a */ 17 17 18 - #define _PIF_SYSCALL _BITUL(PIF_SYSCALL) 19 - #define _PIF_PER_TRAP _BITUL(PIF_PER_TRAP) 20 - #define _PIF_SYSCALL_RESTART _BITUL(PIF_SYSCALL_RESTART) 21 - #define _PIF_GUEST_FAULT _BITUL(PIF_GUEST_FAULT) 18 + #define _PIF_SYSCALL BIT(PIF_SYSCALL) 19 + #define _PIF_PER_TRAP BIT(PIF_PER_TRAP) 20 + #define _PIF_SYSCALL_RESTART BIT(PIF_SYSCALL_RESTART) 21 + #define _PIF_GUEST_FAULT BIT(PIF_GUEST_FAULT) 22 22 23 23 #ifndef __ASSEMBLY__ 24 24
+19 -19
arch/s390/include/asm/setup.h
··· 6 6 #ifndef _ASM_S390_SETUP_H 7 7 #define _ASM_S390_SETUP_H 8 8 9 - #include <linux/const.h> 9 + #include <linux/bits.h> 10 10 #include <uapi/asm/setup.h> 11 11 12 12 #define EP_OFFSET 0x10008 ··· 21 21 * Machine features detected in early.c 22 22 */ 23 23 24 - #define MACHINE_FLAG_VM _BITUL(0) 25 - #define MACHINE_FLAG_KVM _BITUL(1) 26 - #define MACHINE_FLAG_LPAR _BITUL(2) 27 - #define MACHINE_FLAG_DIAG9C _BITUL(3) 28 - #define MACHINE_FLAG_ESOP _BITUL(4) 29 - #define MACHINE_FLAG_IDTE _BITUL(5) 30 - #define MACHINE_FLAG_DIAG44 _BITUL(6) 31 - #define MACHINE_FLAG_EDAT1 _BITUL(7) 32 - #define MACHINE_FLAG_EDAT2 _BITUL(8) 33 - #define MACHINE_FLAG_TOPOLOGY _BITUL(10) 34 - #define MACHINE_FLAG_TE _BITUL(11) 35 - #define MACHINE_FLAG_TLB_LC _BITUL(12) 36 - #define MACHINE_FLAG_VX _BITUL(13) 37 - #define MACHINE_FLAG_TLB_GUEST _BITUL(14) 38 - #define MACHINE_FLAG_NX _BITUL(15) 39 - #define MACHINE_FLAG_GS _BITUL(16) 40 - #define MACHINE_FLAG_SCC _BITUL(17) 24 + #define MACHINE_FLAG_VM BIT(0) 25 + #define MACHINE_FLAG_KVM BIT(1) 26 + #define MACHINE_FLAG_LPAR BIT(2) 27 + #define MACHINE_FLAG_DIAG9C BIT(3) 28 + #define MACHINE_FLAG_ESOP BIT(4) 29 + #define MACHINE_FLAG_IDTE BIT(5) 30 + #define MACHINE_FLAG_DIAG44 BIT(6) 31 + #define MACHINE_FLAG_EDAT1 BIT(7) 32 + #define MACHINE_FLAG_EDAT2 BIT(8) 33 + #define MACHINE_FLAG_TOPOLOGY BIT(10) 34 + #define MACHINE_FLAG_TE BIT(11) 35 + #define MACHINE_FLAG_TLB_LC BIT(12) 36 + #define MACHINE_FLAG_VX BIT(13) 37 + #define MACHINE_FLAG_TLB_GUEST BIT(14) 38 + #define MACHINE_FLAG_NX BIT(15) 39 + #define MACHINE_FLAG_GS BIT(16) 40 + #define MACHINE_FLAG_SCC BIT(17) 41 41 42 - #define LPP_MAGIC _BITUL(31) 42 + #define LPP_MAGIC BIT(31) 43 43 #define LPP_PID_MASK _AC(0xffffffff, UL) 44 44 45 45 /* Offsets to entry points in kernel/head.S */
+15 -15
arch/s390/include/asm/thread_info.h
··· 8 8 #ifndef _ASM_THREAD_INFO_H 9 9 #define _ASM_THREAD_INFO_H 10 10 11 - #include <linux/const.h> 11 + #include <linux/bits.h> 12 12 13 13 /* 14 14 * General size of kernel stacks ··· 82 82 #define TIF_SECCOMP 26 /* secure computing */ 83 83 #define TIF_SYSCALL_TRACEPOINT 27 /* syscall tracepoint instrumentation */ 84 84 85 - #define _TIF_NOTIFY_RESUME _BITUL(TIF_NOTIFY_RESUME) 86 - #define _TIF_SIGPENDING _BITUL(TIF_SIGPENDING) 87 - #define _TIF_NEED_RESCHED _BITUL(TIF_NEED_RESCHED) 88 - #define _TIF_UPROBE _BITUL(TIF_UPROBE) 89 - #define _TIF_GUARDED_STORAGE _BITUL(TIF_GUARDED_STORAGE) 90 - #define _TIF_PATCH_PENDING _BITUL(TIF_PATCH_PENDING) 91 - #define _TIF_ISOLATE_BP _BITUL(TIF_ISOLATE_BP) 92 - #define _TIF_ISOLATE_BP_GUEST _BITUL(TIF_ISOLATE_BP_GUEST) 85 + #define _TIF_NOTIFY_RESUME BIT(TIF_NOTIFY_RESUME) 86 + #define _TIF_SIGPENDING BIT(TIF_SIGPENDING) 87 + #define _TIF_NEED_RESCHED BIT(TIF_NEED_RESCHED) 88 + #define _TIF_UPROBE BIT(TIF_UPROBE) 89 + #define _TIF_GUARDED_STORAGE BIT(TIF_GUARDED_STORAGE) 90 + #define _TIF_PATCH_PENDING BIT(TIF_PATCH_PENDING) 91 + #define _TIF_ISOLATE_BP BIT(TIF_ISOLATE_BP) 92 + #define _TIF_ISOLATE_BP_GUEST BIT(TIF_ISOLATE_BP_GUEST) 93 93 94 - #define _TIF_31BIT _BITUL(TIF_31BIT) 95 - #define _TIF_SINGLE_STEP _BITUL(TIF_SINGLE_STEP) 94 + #define _TIF_31BIT BIT(TIF_31BIT) 95 + #define _TIF_SINGLE_STEP BIT(TIF_SINGLE_STEP) 96 96 97 - #define _TIF_SYSCALL_TRACE _BITUL(TIF_SYSCALL_TRACE) 98 - #define _TIF_SYSCALL_AUDIT _BITUL(TIF_SYSCALL_AUDIT) 99 - #define _TIF_SECCOMP _BITUL(TIF_SECCOMP) 100 - #define _TIF_SYSCALL_TRACEPOINT _BITUL(TIF_SYSCALL_TRACEPOINT) 97 + #define _TIF_SYSCALL_TRACE BIT(TIF_SYSCALL_TRACE) 98 + #define _TIF_SYSCALL_AUDIT BIT(TIF_SYSCALL_AUDIT) 99 + #define _TIF_SECCOMP BIT(TIF_SECCOMP) 100 + #define _TIF_SYSCALL_TRACEPOINT BIT(TIF_SYSCALL_TRACEPOINT) 101 101 102 102 #endif /* _ASM_THREAD_INFO_H */
+1 -15
arch/s390/mm/fault.c
··· 67 67 } 68 68 early_initcall(fault_init); 69 69 70 - static inline int notify_page_fault(struct pt_regs *regs) 71 - { 72 - int ret = 0; 73 - 74 - /* kprobe_running() needs smp_processor_id() */ 75 - if (kprobes_built_in() && !user_mode(regs)) { 76 - preempt_disable(); 77 - if (kprobe_running() && kprobe_fault_handler(regs, 14)) 78 - ret = 1; 79 - preempt_enable(); 80 - } 81 - return ret; 82 - } 83 - 84 70 /* 85 71 * Find out which address space caused the exception. 86 72 */ ··· 398 412 */ 399 413 clear_pt_regs_flag(regs, PIF_PER_TRAP); 400 414 401 - if (notify_page_fault(regs)) 415 + if (kprobe_page_fault(regs, 14)) 402 416 return 0; 403 417 404 418 mm = tsk->mm;
+2 -16
arch/sh/mm/fault.c
··· 24 24 #include <asm/tlbflush.h> 25 25 #include <asm/traps.h> 26 26 27 - static inline int notify_page_fault(struct pt_regs *regs, int trap) 28 - { 29 - int ret = 0; 30 - 31 - if (kprobes_built_in() && !user_mode(regs)) { 32 - preempt_disable(); 33 - if (kprobe_running() && kprobe_fault_handler(regs, trap)) 34 - ret = 1; 35 - preempt_enable(); 36 - } 37 - 38 - return ret; 39 - } 40 - 41 27 static void 42 28 force_sig_info_fault(int si_signo, int si_code, unsigned long address) 43 29 { ··· 398 412 if (unlikely(fault_in_kernel_space(address))) { 399 413 if (vmalloc_fault(address) >= 0) 400 414 return; 401 - if (notify_page_fault(regs, vec)) 415 + if (kprobe_page_fault(regs, vec)) 402 416 return; 403 417 404 418 bad_area_nosemaphore(regs, error_code, address); 405 419 return; 406 420 } 407 421 408 - if (unlikely(notify_page_fault(regs, vec))) 422 + if (unlikely(kprobe_page_fault(regs, vec))) 409 423 return; 410 424 411 425 /* Only enable interrupts if they were on before the fault */
-6
arch/sparc/include/uapi/asm/mman.h
··· 22 22 #define MCL_FUTURE 0x4000 /* lock all additions to address space */ 23 23 #define MCL_ONFAULT 0x8000 /* lock all pages that are faulted in */ 24 24 25 - #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 26 - #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 27 - #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 28 - #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 29 - 30 - 31 25 #endif /* _UAPI__SPARC_MMAN_H__ */
+1 -15
arch/sparc/mm/fault_64.c
··· 38 38 39 39 int show_unhandled_signals = 1; 40 40 41 - static inline __kprobes int notify_page_fault(struct pt_regs *regs) 42 - { 43 - int ret = 0; 44 - 45 - /* kprobe_running() needs smp_processor_id() */ 46 - if (kprobes_built_in() && !user_mode(regs)) { 47 - preempt_disable(); 48 - if (kprobe_running() && kprobe_fault_handler(regs, 0)) 49 - ret = 1; 50 - preempt_enable(); 51 - } 52 - return ret; 53 - } 54 - 55 41 static void __kprobes unhandled_fault(unsigned long address, 56 42 struct task_struct *tsk, 57 43 struct pt_regs *regs) ··· 271 285 272 286 fault_code = get_thread_fault_code(); 273 287 274 - if (notify_page_fault(regs)) 288 + if (kprobe_page_fault(regs, 0)) 275 289 goto exit_exception; 276 290 277 291 si_code = SEGV_MAPERR;
+1 -1
arch/x86/Kconfig
··· 70 70 select ARCH_HAS_KCOV if X86_64 71 71 select ARCH_HAS_MEMBARRIER_SYNC_CORE 72 72 select ARCH_HAS_PMEM_API if X86_64 73 + select ARCH_HAS_PTE_DEVMAP if X86_64 73 74 select ARCH_HAS_PTE_SPECIAL 74 75 select ARCH_HAS_REFCOUNT 75 76 select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 ··· 81 80 select ARCH_HAS_STRICT_MODULE_RWX 82 81 select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE 83 82 select ARCH_HAS_UBSAN_SANITIZE_ALL 84 - select ARCH_HAS_ZONE_DEVICE if X86_64 85 83 select ARCH_HAVE_NMI_SAFE_CMPXCHG 86 84 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 87 85 select ARCH_MIGHT_HAVE_PC_PARPORT
-1
arch/x86/include/asm/io.h
··· 165 165 { 166 166 return (unsigned int)virt_to_phys(address); 167 167 } 168 - #define isa_page_to_bus(page) ((unsigned int)page_to_phys(page)) 169 168 #define isa_bus_to_virt phys_to_virt 170 169 171 170 /*
+2 -2
arch/x86/include/asm/pgtable.h
··· 271 271 return boot_cpu_has(X86_FEATURE_PSE); 272 272 } 273 273 274 - #ifdef __HAVE_ARCH_PTE_DEVMAP 274 + #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP 275 275 static inline int pmd_devmap(pmd_t pmd) 276 276 { 277 277 return !!(pmd_val(pmd) & _PAGE_DEVMAP); ··· 732 732 return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE); 733 733 } 734 734 735 - #ifdef __HAVE_ARCH_PTE_DEVMAP 735 + #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP 736 736 static inline int pte_devmap(pte_t a) 737 737 { 738 738 return (pte_flags(a) & _PAGE_DEVMAP) == _PAGE_DEVMAP;
-1
arch/x86/include/asm/pgtable_types.h
··· 103 103 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) 104 104 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) 105 105 #define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) 106 - #define __HAVE_ARCH_PTE_DEVMAP 107 106 #else 108 107 #define _PAGE_NX (_AT(pteval_t, 0)) 109 108 #define _PAGE_DEVMAP (_AT(pteval_t, 0))
+2 -19
arch/x86/mm/fault.c
··· 46 46 return 0; 47 47 } 48 48 49 - static nokprobe_inline int kprobes_fault(struct pt_regs *regs) 50 - { 51 - if (!kprobes_built_in()) 52 - return 0; 53 - if (user_mode(regs)) 54 - return 0; 55 - /* 56 - * To be potentially processing a kprobe fault and to be allowed to call 57 - * kprobe_running(), we have to be non-preemptible. 58 - */ 59 - if (preemptible()) 60 - return 0; 61 - if (!kprobe_running()) 62 - return 0; 63 - return kprobe_fault_handler(regs, X86_TRAP_PF); 64 - } 65 - 66 49 /* 67 50 * Prefetch quirks: 68 51 * ··· 1265 1282 return; 1266 1283 1267 1284 /* kprobes don't want to hook the spurious faults: */ 1268 - if (kprobes_fault(regs)) 1285 + if (kprobe_page_fault(regs, X86_TRAP_PF)) 1269 1286 return; 1270 1287 1271 1288 /* ··· 1296 1313 mm = tsk->mm; 1297 1314 1298 1315 /* kprobes don't want to hook the spurious faults: */ 1299 - if (unlikely(kprobes_fault(regs))) 1316 + if (unlikely(kprobe_page_fault(regs, X86_TRAP_PF))) 1300 1317 return; 1301 1318 1302 1319 /*
+5
arch/x86/mm/ioremap.c
··· 459 459 } 460 460 EXPORT_SYMBOL(iounmap); 461 461 462 + int __init arch_ioremap_p4d_supported(void) 463 + { 464 + return 0; 465 + } 466 + 462 467 int __init arch_ioremap_pud_supported(void) 463 468 { 464 469 #ifdef CONFIG_X86_64
+1 -5
arch/xtensa/include/uapi/asm/mman.h
··· 56 56 #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ 57 57 #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ 58 58 #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ 59 - #ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED 60 - # define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be 59 + #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be 61 60 * uninitialized */ 62 - #else 63 - # define MAP_UNINITIALIZED 0x0 /* Don't support this flag */ 64 - #endif 65 61 66 62 /* 67 63 * Flags for msync
+2
drivers/dax/dax-private.h
··· 43 43 * @target_node: effective numa node if dev_dax memory range is onlined 44 44 * @dev - device core 45 45 * @pgmap - pgmap for memmap setup / lifetime (driver owned) 46 + * @dax_mem_res: physical address range of hotadded DAX memory 46 47 */ 47 48 struct dev_dax { 48 49 struct dax_region *region; ··· 51 50 int target_node; 52 51 struct device dev; 53 52 struct dev_pagemap pgmap; 53 + struct resource *dax_kmem_res; 54 54 }; 55 55 56 56 static inline struct dev_dax *to_dev_dax(struct device *dev)
+41 -5
drivers/dax/kmem.c
··· 66 66 new_res->name = dev_name(dev); 67 67 68 68 rc = add_memory(numa_node, new_res->start, resource_size(new_res)); 69 - if (rc) 69 + if (rc) { 70 + release_resource(new_res); 71 + kfree(new_res); 70 72 return rc; 73 + } 74 + dev_dax->dax_kmem_res = new_res; 71 75 72 76 return 0; 73 77 } 74 78 79 + #ifdef CONFIG_MEMORY_HOTREMOVE 80 + static int dev_dax_kmem_remove(struct device *dev) 81 + { 82 + struct dev_dax *dev_dax = to_dev_dax(dev); 83 + struct resource *res = dev_dax->dax_kmem_res; 84 + resource_size_t kmem_start = res->start; 85 + resource_size_t kmem_size = resource_size(res); 86 + int rc; 87 + 88 + /* 89 + * We have one shot for removing memory, if some memory blocks were not 90 + * offline prior to calling this function remove_memory() will fail, and 91 + * there is no way to hotremove this memory until reboot because device 92 + * unbind will succeed even if we return failure. 93 + */ 94 + rc = remove_memory(dev_dax->target_node, kmem_start, kmem_size); 95 + if (rc) { 96 + dev_err(dev, 97 + "DAX region %pR cannot be hotremoved until the next reboot\n", 98 + res); 99 + return rc; 100 + } 101 + 102 + /* Release and free dax resources */ 103 + release_resource(res); 104 + kfree(res); 105 + dev_dax->dax_kmem_res = NULL; 106 + 107 + return 0; 108 + } 109 + #else 75 110 static int dev_dax_kmem_remove(struct device *dev) 76 111 { 77 112 /* 78 - * Purposely leak the request_mem_region() for the device-dax 79 - * range and return '0' to ->remove() attempts. The removal of 80 - * the device from the driver always succeeds, but the region 81 - * is permanently pinned as reserved by the unreleased 113 + * Without hotremove purposely leak the request_mem_region() for the 114 + * device-dax range and return '0' to ->remove() attempts. The removal 115 + * of the device from the driver always succeeds, but the region is 116 + * permanently pinned as reserved by the unreleased 82 117 * request_mem_region(). 83 118 */ 84 119 return 0; 85 120 } 121 + #endif /* CONFIG_MEMORY_HOTREMOVE */ 86 122 87 123 static struct dax_device_driver device_dax_kmem_driver = { 88 124 .drv = {
+4 -49
drivers/fpga/dfl-afu-dma-region.c
··· 12 12 #include <linux/dma-mapping.h> 13 13 #include <linux/sched/signal.h> 14 14 #include <linux/uaccess.h> 15 + #include <linux/mm.h> 15 16 16 17 #include "dfl-afu.h" 17 18 ··· 33 32 } 34 33 35 34 /** 36 - * afu_dma_adjust_locked_vm - adjust locked memory 37 - * @dev: port device 38 - * @npages: number of pages 39 - * @incr: increase or decrease locked memory 40 - * 41 - * Increase or decrease the locked memory size with npages input. 42 - * 43 - * Return 0 on success. 44 - * Return -ENOMEM if locked memory size is over the limit and no CAP_IPC_LOCK. 45 - */ 46 - static int afu_dma_adjust_locked_vm(struct device *dev, long npages, bool incr) 47 - { 48 - unsigned long locked, lock_limit; 49 - int ret = 0; 50 - 51 - /* the task is exiting. */ 52 - if (!current->mm) 53 - return 0; 54 - 55 - down_write(&current->mm->mmap_sem); 56 - 57 - if (incr) { 58 - locked = current->mm->locked_vm + npages; 59 - lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; 60 - 61 - if (locked > lock_limit && !capable(CAP_IPC_LOCK)) 62 - ret = -ENOMEM; 63 - else 64 - current->mm->locked_vm += npages; 65 - } else { 66 - if (WARN_ON_ONCE(npages > current->mm->locked_vm)) 67 - npages = current->mm->locked_vm; 68 - current->mm->locked_vm -= npages; 69 - } 70 - 71 - dev_dbg(dev, "[%d] RLIMIT_MEMLOCK %c%ld %ld/%ld%s\n", current->pid, 72 - incr ? '+' : '-', npages << PAGE_SHIFT, 73 - current->mm->locked_vm << PAGE_SHIFT, rlimit(RLIMIT_MEMLOCK), 74 - ret ? "- exceeded" : ""); 75 - 76 - up_write(&current->mm->mmap_sem); 77 - 78 - return ret; 79 - } 80 - 81 - /** 82 35 * afu_dma_pin_pages - pin pages of given dma memory region 83 36 * @pdata: feature device platform data 84 37 * @region: dma memory region to be pinned ··· 47 92 struct device *dev = &pdata->dev->dev; 48 93 int ret, pinned; 49 94 50 - ret = afu_dma_adjust_locked_vm(dev, npages, true); 95 + ret = account_locked_vm(current->mm, npages, true); 51 96 if (ret) 52 97 return ret; 53 98 ··· 76 121 free_pages: 77 122 kfree(region->pages); 78 123 unlock_vm: 79 - afu_dma_adjust_locked_vm(dev, npages, false); 124 + account_locked_vm(current->mm, npages, false); 80 125 return ret; 81 126 } 82 127 ··· 96 141 97 142 put_all_pages(region->pages, npages); 98 143 kfree(region->pages); 99 - afu_dma_adjust_locked_vm(dev, npages, false); 144 + account_locked_vm(current->mm, npages, false); 100 145 101 146 dev_dbg(dev, "%ld pages unpinned\n", npages); 102 147 }
+1 -1
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
··· 53 53 pad = round_up(skb->len, 4) + 4 - skb->len; 54 54 55 55 /* First packet of a A-MSDU burst keeps track of the whole burst 56 - * length, need to update lenght of it and the last packet. 56 + * length, need to update length of it and the last packet. 57 57 */ 58 58 skb_walk_frags(skb, iter) { 59 59 last = iter;
+8
drivers/pps/pps.c
··· 152 152 pps->params.mode |= PPS_CANWAIT; 153 153 pps->params.api_version = PPS_API_VERS; 154 154 155 + /* 156 + * Clear unused fields of pps_kparams to avoid leaking 157 + * uninitialized data of the PPS_SETPARAMS caller via 158 + * PPS_GETPARAMS 159 + */ 160 + pps->params.assert_off_tu.flags = 0; 161 + pps->params.clear_off_tu.flags = 0; 162 + 155 163 spin_unlock_irq(&pps->lock); 156 164 157 165 break;
+2
drivers/rapidio/devices/rio_mport_cdev.c
··· 1686 1686 1687 1687 if (copy_from_user(&dev_info, arg, sizeof(dev_info))) 1688 1688 return -EFAULT; 1689 + dev_info.name[sizeof(dev_info.name) - 1] = '\0'; 1689 1690 1690 1691 rmcd_debug(RDEV, "name:%s ct:0x%x did:0x%x hc:0x%x", dev_info.name, 1691 1692 dev_info.comptag, dev_info.destid, dev_info.hopcount); ··· 1818 1817 1819 1818 if (copy_from_user(&dev_info, arg, sizeof(dev_info))) 1820 1819 return -EFAULT; 1820 + dev_info.name[sizeof(dev_info.name) - 1] = '\0'; 1821 1821 1822 1822 mport = priv->md->mport; 1823 1823
+5 -49
drivers/vfio/vfio_iommu_spapr_tce.c
··· 19 19 #include <linux/vmalloc.h> 20 20 #include <linux/sched/mm.h> 21 21 #include <linux/sched/signal.h> 22 + #include <linux/mm.h> 22 23 23 24 #include <asm/iommu.h> 24 25 #include <asm/tce.h> ··· 31 30 32 31 static void tce_iommu_detach_group(void *iommu_data, 33 32 struct iommu_group *iommu_group); 34 - 35 - static long try_increment_locked_vm(struct mm_struct *mm, long npages) 36 - { 37 - long ret = 0, locked, lock_limit; 38 - 39 - if (WARN_ON_ONCE(!mm)) 40 - return -EPERM; 41 - 42 - if (!npages) 43 - return 0; 44 - 45 - down_write(&mm->mmap_sem); 46 - locked = mm->locked_vm + npages; 47 - lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; 48 - if (locked > lock_limit && !capable(CAP_IPC_LOCK)) 49 - ret = -ENOMEM; 50 - else 51 - mm->locked_vm += npages; 52 - 53 - pr_debug("[%d] RLIMIT_MEMLOCK +%ld %ld/%ld%s\n", current->pid, 54 - npages << PAGE_SHIFT, 55 - mm->locked_vm << PAGE_SHIFT, 56 - rlimit(RLIMIT_MEMLOCK), 57 - ret ? " - exceeded" : ""); 58 - 59 - up_write(&mm->mmap_sem); 60 - 61 - return ret; 62 - } 63 - 64 - static void decrement_locked_vm(struct mm_struct *mm, long npages) 65 - { 66 - if (!mm || !npages) 67 - return; 68 - 69 - down_write(&mm->mmap_sem); 70 - if (WARN_ON_ONCE(npages > mm->locked_vm)) 71 - npages = mm->locked_vm; 72 - mm->locked_vm -= npages; 73 - pr_debug("[%d] RLIMIT_MEMLOCK -%ld %ld/%ld\n", current->pid, 74 - npages << PAGE_SHIFT, 75 - mm->locked_vm << PAGE_SHIFT, 76 - rlimit(RLIMIT_MEMLOCK)); 77 - up_write(&mm->mmap_sem); 78 - } 79 33 80 34 /* 81 35 * VFIO IOMMU fd for SPAPR_TCE IOMMU implementation ··· 289 333 return ret; 290 334 291 335 locked = table_group->tce32_size >> PAGE_SHIFT; 292 - ret = try_increment_locked_vm(container->mm, locked); 336 + ret = account_locked_vm(container->mm, locked, true); 293 337 if (ret) 294 338 return ret; 295 339 ··· 308 352 container->enabled = false; 309 353 310 354 BUG_ON(!container->mm); 311 - decrement_locked_vm(container->mm, container->locked_pages); 355 + account_locked_vm(container->mm, container->locked_pages, false); 312 356 } 313 357 314 358 static void *tce_iommu_open(unsigned long arg) ··· 612 656 if (!table_size) 613 657 return -EINVAL; 614 658 615 - ret = try_increment_locked_vm(container->mm, table_size >> PAGE_SHIFT); 659 + ret = account_locked_vm(container->mm, table_size >> PAGE_SHIFT, true); 616 660 if (ret) 617 661 return ret; 618 662 ··· 631 675 unsigned long pages = tbl->it_allocated_size >> PAGE_SHIFT; 632 676 633 677 iommu_tce_table_put(tbl); 634 - decrement_locked_vm(container->mm, pages); 678 + account_locked_vm(container->mm, pages, false); 635 679 } 636 680 637 681 static long tce_iommu_create_window(struct tce_container *container,
+2 -15
drivers/vfio/vfio_iommu_type1.c
··· 272 272 273 273 ret = down_write_killable(&mm->mmap_sem); 274 274 if (!ret) { 275 - if (npage > 0) { 276 - if (!dma->lock_cap) { 277 - unsigned long limit; 278 - 279 - limit = task_rlimit(dma->task, 280 - RLIMIT_MEMLOCK) >> PAGE_SHIFT; 281 - 282 - if (mm->locked_vm + npage > limit) 283 - ret = -ENOMEM; 284 - } 285 - } 286 - 287 - if (!ret) 288 - mm->locked_vm += npage; 289 - 275 + ret = __account_locked_vm(mm, abs(npage), npage > 0, dma->task, 276 + dma->lock_cap); 290 277 up_write(&mm->mmap_sem); 291 278 } 292 279
+8 -12
fs/aio.c
··· 2094 2094 const struct __aio_sigset __user *, usig) 2095 2095 { 2096 2096 struct __aio_sigset ksig = { NULL, }; 2097 - sigset_t ksigmask, sigsaved; 2098 2097 struct timespec64 ts; 2099 2098 bool interrupted; 2100 2099 int ret; ··· 2104 2105 if (usig && copy_from_user(&ksig, usig, sizeof(ksig))) 2105 2106 return -EFAULT; 2106 2107 2107 - ret = set_user_sigmask(ksig.sigmask, &ksigmask, &sigsaved, ksig.sigsetsize); 2108 + ret = set_user_sigmask(ksig.sigmask, ksig.sigsetsize); 2108 2109 if (ret) 2109 2110 return ret; 2110 2111 2111 2112 ret = do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &ts : NULL); 2112 2113 2113 2114 interrupted = signal_pending(current); 2114 - restore_user_sigmask(ksig.sigmask, &sigsaved, interrupted); 2115 + restore_saved_sigmask_unless(interrupted); 2115 2116 if (interrupted && !ret) 2116 2117 ret = -ERESTARTNOHAND; 2117 2118 ··· 2129 2130 const struct __aio_sigset __user *, usig) 2130 2131 { 2131 2132 struct __aio_sigset ksig = { NULL, }; 2132 - sigset_t ksigmask, sigsaved; 2133 2133 struct timespec64 ts; 2134 2134 bool interrupted; 2135 2135 int ret; ··· 2140 2142 return -EFAULT; 2141 2143 2142 2144 2143 - ret = set_user_sigmask(ksig.sigmask, &ksigmask, &sigsaved, ksig.sigsetsize); 2145 + ret = set_user_sigmask(ksig.sigmask, ksig.sigsetsize); 2144 2146 if (ret) 2145 2147 return ret; 2146 2148 2147 2149 ret = do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &ts : NULL); 2148 2150 2149 2151 interrupted = signal_pending(current); 2150 - restore_user_sigmask(ksig.sigmask, &sigsaved, interrupted); 2152 + restore_saved_sigmask_unless(interrupted); 2151 2153 if (interrupted && !ret) 2152 2154 ret = -ERESTARTNOHAND; 2153 2155 ··· 2196 2198 const struct __compat_aio_sigset __user *, usig) 2197 2199 { 2198 2200 struct __compat_aio_sigset ksig = { NULL, }; 2199 - sigset_t ksigmask, sigsaved; 2200 2201 struct timespec64 t; 2201 2202 bool interrupted; 2202 2203 int ret; ··· 2206 2209 if (usig && copy_from_user(&ksig, usig, sizeof(ksig))) 2207 2210 return -EFAULT; 2208 2211 2209 - ret = set_compat_user_sigmask(ksig.sigmask, &ksigmask, &sigsaved, ksig.sigsetsize); 2212 + ret = set_compat_user_sigmask(ksig.sigmask, ksig.sigsetsize); 2210 2213 if (ret) 2211 2214 return ret; 2212 2215 2213 2216 ret = do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &t : NULL); 2214 2217 2215 2218 interrupted = signal_pending(current); 2216 - restore_user_sigmask(ksig.sigmask, &sigsaved, interrupted); 2219 + restore_saved_sigmask_unless(interrupted); 2217 2220 if (interrupted && !ret) 2218 2221 ret = -ERESTARTNOHAND; 2219 2222 ··· 2231 2234 const struct __compat_aio_sigset __user *, usig) 2232 2235 { 2233 2236 struct __compat_aio_sigset ksig = { NULL, }; 2234 - sigset_t ksigmask, sigsaved; 2235 2237 struct timespec64 t; 2236 2238 bool interrupted; 2237 2239 int ret; ··· 2241 2245 if (usig && copy_from_user(&ksig, usig, sizeof(ksig))) 2242 2246 return -EFAULT; 2243 2247 2244 - ret = set_compat_user_sigmask(ksig.sigmask, &ksigmask, &sigsaved, ksig.sigsetsize); 2248 + ret = set_compat_user_sigmask(ksig.sigmask, ksig.sigsetsize); 2245 2249 if (ret) 2246 2250 return ret; 2247 2251 2248 2252 ret = do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &t : NULL); 2249 2253 2250 2254 interrupted = signal_pending(current); 2251 - restore_user_sigmask(ksig.sigmask, &sigsaved, interrupted); 2255 + restore_saved_sigmask_unless(interrupted); 2252 2256 if (interrupted && !ret) 2253 2257 ret = -ERESTARTNOHAND; 2254 2258
-1
fs/binfmt_elf.c
··· 1127 1127 load_addr, interp_load_addr); 1128 1128 if (retval < 0) 1129 1129 goto out; 1130 - /* N.B. passed_fileno might not be initialized? */ 1131 1130 current->mm->end_code = end_code; 1132 1131 current->mm->start_code = start_code; 1133 1132 current->mm->start_data = start_data;
-2
fs/binfmt_flat.c
··· 431 431 unsigned long len, memp, memp_size, extra, rlim; 432 432 __be32 __user *reloc; 433 433 u32 __user *rp; 434 - struct inode *inode; 435 434 int i, rev, relocs; 436 435 loff_t fpos; 437 436 unsigned long start_code, end_code; ··· 438 439 int ret; 439 440 440 441 hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */ 441 - inode = file_inode(bprm->file); 442 442 443 443 text_len = ntohl(hdr->data_start); 444 444 data_len = ntohl(hdr->data_end) - ntohl(hdr->data_start);
+2 -1
fs/coda/Makefile
··· 6 6 obj-$(CONFIG_CODA_FS) += coda.o 7 7 8 8 coda-objs := psdev.o cache.o cnode.o inode.o dir.o file.o upcall.o \ 9 - coda_linux.o symlink.o pioctl.o sysctl.o 9 + coda_linux.o symlink.o pioctl.o 10 + coda-$(CONFIG_SYSCTL) += sysctl.o 10 11 11 12 # If you want debugging output, please uncomment the following line. 12 13
+1 -1
fs/coda/cache.c
··· 21 21 #include <linux/spinlock.h> 22 22 23 23 #include <linux/coda.h> 24 - #include <linux/coda_psdev.h> 24 + #include "coda_psdev.h" 25 25 #include "coda_linux.h" 26 26 #include "coda_cache.h" 27 27
+11 -6
fs/coda/cnode.c
··· 8 8 #include <linux/time.h> 9 9 10 10 #include <linux/coda.h> 11 - #include <linux/coda_psdev.h> 12 11 #include <linux/pagemap.h> 12 + #include "coda_psdev.h" 13 13 #include "coda_linux.h" 14 14 15 15 static inline int coda_fideq(struct CodaFid *fid1, struct CodaFid *fid2) ··· 137 137 struct inode *inode; 138 138 unsigned long hash = coda_f2i(fid); 139 139 140 - if ( !sb ) { 141 - pr_warn("%s: no sb!\n", __func__); 142 - return NULL; 143 - } 144 - 145 140 inode = ilookup5(sb, hash, coda_test_inode, fid); 146 141 if ( !inode ) 147 142 return NULL; ··· 146 151 BUG_ON(inode->i_state & I_NEW); 147 152 148 153 return inode; 154 + } 155 + 156 + struct coda_file_info *coda_ftoc(struct file *file) 157 + { 158 + struct coda_file_info *cfi = file->private_data; 159 + 160 + BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 161 + 162 + return cfi; 163 + 149 164 } 150 165 151 166 /* the CONTROL inode is made without asking attributes from Venus */
+2 -2
fs/coda/coda_fs_i.h
··· 40 40 int cfi_magic; /* magic number */ 41 41 struct file *cfi_container; /* container file for this cnode */ 42 42 unsigned int cfi_mapcount; /* nr of times this file is mapped */ 43 + bool cfi_access_intent; /* is access intent supported */ 43 44 }; 44 - 45 - #define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data)) 46 45 47 46 /* flags */ 48 47 #define C_VATTR 0x1 /* Validity of vattr in inode */ ··· 53 54 struct inode *coda_iget(struct super_block *sb, struct CodaFid *fid, struct coda_vattr *attr); 54 55 struct inode *coda_cnode_makectl(struct super_block *sb); 55 56 struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb); 57 + struct coda_file_info *coda_ftoc(struct file *file); 56 58 void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *); 57 59 58 60 #endif
+10
fs/coda/coda_int.h
··· 13 13 void coda_destroy_inodecache(void); 14 14 int __init coda_init_inodecache(void); 15 15 int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync); 16 + 17 + #ifdef CONFIG_SYSCTL 16 18 void coda_sysctl_init(void); 17 19 void coda_sysctl_clean(void); 20 + #else 21 + static inline void coda_sysctl_init(void) 22 + { 23 + } 18 24 25 + static inline void coda_sysctl_clean(void) 26 + { 27 + } 28 + #endif 19 29 #endif /* _CODA_INT_ */ 20 30 21 31
+32 -13
fs/coda/coda_linux.c
··· 18 18 #include <linux/string.h> 19 19 20 20 #include <linux/coda.h> 21 - #include <linux/coda_psdev.h> 21 + #include "coda_psdev.h" 22 22 #include "coda_linux.h" 23 23 24 24 /* initialize the debugging variables */ ··· 66 66 return coda_flags; 67 67 } 68 68 69 + static struct timespec64 coda_to_timespec64(struct coda_timespec ts) 70 + { 71 + struct timespec64 ts64 = { 72 + .tv_sec = ts.tv_sec, 73 + .tv_nsec = ts.tv_nsec, 74 + }; 75 + 76 + return ts64; 77 + } 78 + 79 + static struct coda_timespec timespec64_to_coda(struct timespec64 ts64) 80 + { 81 + struct coda_timespec ts = { 82 + .tv_sec = ts64.tv_sec, 83 + .tv_nsec = ts64.tv_nsec, 84 + }; 85 + 86 + return ts; 87 + } 69 88 70 89 /* utility functions below */ 71 90 void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr) ··· 124 105 if (attr->va_size != -1) 125 106 inode->i_blocks = (attr->va_size + 511) >> 9; 126 107 if (attr->va_atime.tv_sec != -1) 127 - inode->i_atime = timespec_to_timespec64(attr->va_atime); 108 + inode->i_atime = coda_to_timespec64(attr->va_atime); 128 109 if (attr->va_mtime.tv_sec != -1) 129 - inode->i_mtime = timespec_to_timespec64(attr->va_mtime); 110 + inode->i_mtime = coda_to_timespec64(attr->va_mtime); 130 111 if (attr->va_ctime.tv_sec != -1) 131 - inode->i_ctime = timespec_to_timespec64(attr->va_ctime); 112 + inode->i_ctime = coda_to_timespec64(attr->va_ctime); 132 113 } 133 114 134 115 ··· 149 130 vattr->va_uid = (vuid_t) -1; 150 131 vattr->va_gid = (vgid_t) -1; 151 132 vattr->va_size = (off_t) -1; 152 - vattr->va_atime.tv_sec = (time_t) -1; 153 - vattr->va_atime.tv_nsec = (time_t) -1; 154 - vattr->va_mtime.tv_sec = (time_t) -1; 155 - vattr->va_mtime.tv_nsec = (time_t) -1; 156 - vattr->va_ctime.tv_sec = (time_t) -1; 157 - vattr->va_ctime.tv_nsec = (time_t) -1; 133 + vattr->va_atime.tv_sec = (int64_t) -1; 134 + vattr->va_atime.tv_nsec = (long) -1; 135 + vattr->va_mtime.tv_sec = (int64_t) -1; 136 + vattr->va_mtime.tv_nsec = (long) -1; 137 + vattr->va_ctime.tv_sec = (int64_t) -1; 138 + vattr->va_ctime.tv_nsec = (long) -1; 158 139 vattr->va_type = C_VNON; 159 140 vattr->va_fileid = -1; 160 141 vattr->va_gen = -1; ··· 194 175 vattr->va_size = iattr->ia_size; 195 176 } 196 177 if ( valid & ATTR_ATIME ) { 197 - vattr->va_atime = timespec64_to_timespec(iattr->ia_atime); 178 + vattr->va_atime = timespec64_to_coda(iattr->ia_atime); 198 179 } 199 180 if ( valid & ATTR_MTIME ) { 200 - vattr->va_mtime = timespec64_to_timespec(iattr->ia_mtime); 181 + vattr->va_mtime = timespec64_to_coda(iattr->ia_mtime); 201 182 } 202 183 if ( valid & ATTR_CTIME ) { 203 - vattr->va_ctime = timespec64_to_timespec(iattr->ia_ctime); 184 + vattr->va_ctime = timespec64_to_coda(iattr->ia_ctime); 204 185 } 205 186 } 206 187
-16
fs/coda/coda_linux.h
··· 59 59 void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *); 60 60 unsigned short coda_flags_to_cflags(unsigned short); 61 61 62 - /* sysctl.h */ 63 - void coda_sysctl_init(void); 64 - void coda_sysctl_clean(void); 65 - 66 - #define CODA_ALLOC(ptr, cast, size) do { \ 67 - if (size < PAGE_SIZE) \ 68 - ptr = kzalloc((unsigned long) size, GFP_KERNEL); \ 69 - else \ 70 - ptr = (cast)vzalloc((unsigned long) size); \ 71 - if (!ptr) \ 72 - pr_warn("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \ 73 - } while (0) 74 - 75 - 76 - #define CODA_FREE(ptr, size) kvfree((ptr)) 77 - 78 62 /* inode to cnode access functions */ 79 63 80 64 static inline struct coda_inode_info *ITOC(struct inode *inode)
+5 -7
fs/coda/dir.c
··· 23 23 #include <linux/uaccess.h> 24 24 25 25 #include <linux/coda.h> 26 - #include <linux/coda_psdev.h> 26 + #include "coda_psdev.h" 27 27 #include "coda_linux.h" 28 28 #include "coda_cache.h" 29 29 ··· 47 47 int type = 0; 48 48 49 49 if (length > CODA_MAXNAMLEN) { 50 - pr_err("name too long: lookup, %s (%*s)\n", 51 - coda_i2s(dir), (int)length, name); 50 + pr_err("name too long: lookup, %s %zu\n", 51 + coda_i2s(dir), length); 52 52 return ERR_PTR(-ENAMETOOLONG); 53 53 } 54 54 ··· 356 356 ino_t ino; 357 357 int ret; 358 358 359 - cfi = CODA_FTOC(coda_file); 360 - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 359 + cfi = coda_ftoc(coda_file); 361 360 host_file = cfi->cfi_container; 362 361 363 362 cii = ITOC(file_inode(coda_file)); ··· 425 426 struct file *host_file; 426 427 int ret; 427 428 428 - cfi = CODA_FTOC(coda_file); 429 - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 429 + cfi = coda_ftoc(coda_file); 430 430 host_file = cfi->cfi_container; 431 431 432 432 if (host_file->f_op->iterate || host_file->f_op->iterate_shared) {
+119 -24
fs/coda/file.c
··· 20 20 #include <linux/string.h> 21 21 #include <linux/slab.h> 22 22 #include <linux/uaccess.h> 23 + #include <linux/uio.h> 23 24 24 25 #include <linux/coda.h> 25 - #include <linux/coda_psdev.h> 26 - 26 + #include "coda_psdev.h" 27 27 #include "coda_linux.h" 28 28 #include "coda_int.h" 29 + 30 + struct coda_vm_ops { 31 + atomic_t refcnt; 32 + struct file *coda_file; 33 + const struct vm_operations_struct *host_vm_ops; 34 + struct vm_operations_struct vm_ops; 35 + }; 29 36 30 37 static ssize_t 31 38 coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to) 32 39 { 33 40 struct file *coda_file = iocb->ki_filp; 34 - struct coda_file_info *cfi = CODA_FTOC(coda_file); 41 + struct inode *coda_inode = file_inode(coda_file); 42 + struct coda_file_info *cfi = coda_ftoc(coda_file); 43 + loff_t ki_pos = iocb->ki_pos; 44 + size_t count = iov_iter_count(to); 45 + ssize_t ret; 35 46 36 - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 47 + ret = venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), 48 + &cfi->cfi_access_intent, 49 + count, ki_pos, CODA_ACCESS_TYPE_READ); 50 + if (ret) 51 + goto finish_read; 37 52 38 - return vfs_iter_read(cfi->cfi_container, to, &iocb->ki_pos, 0); 53 + ret = vfs_iter_read(cfi->cfi_container, to, &iocb->ki_pos, 0); 54 + 55 + finish_read: 56 + venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), 57 + &cfi->cfi_access_intent, 58 + count, ki_pos, CODA_ACCESS_TYPE_READ_FINISH); 59 + return ret; 39 60 } 40 61 41 62 static ssize_t ··· 64 43 { 65 44 struct file *coda_file = iocb->ki_filp; 66 45 struct inode *coda_inode = file_inode(coda_file); 67 - struct coda_file_info *cfi = CODA_FTOC(coda_file); 68 - struct file *host_file; 46 + struct coda_file_info *cfi = coda_ftoc(coda_file); 47 + struct file *host_file = cfi->cfi_container; 48 + loff_t ki_pos = iocb->ki_pos; 49 + size_t count = iov_iter_count(to); 69 50 ssize_t ret; 70 51 71 - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 52 + ret = venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), 53 + &cfi->cfi_access_intent, 54 + count, ki_pos, CODA_ACCESS_TYPE_WRITE); 55 + if (ret) 56 + goto finish_write; 72 57 73 - host_file = cfi->cfi_container; 74 58 file_start_write(host_file); 75 59 inode_lock(coda_inode); 76 60 ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos, 0); ··· 84 58 coda_inode->i_mtime = coda_inode->i_ctime = current_time(coda_inode); 85 59 inode_unlock(coda_inode); 86 60 file_end_write(host_file); 61 + 62 + finish_write: 63 + venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), 64 + &cfi->cfi_access_intent, 65 + count, ki_pos, CODA_ACCESS_TYPE_WRITE_FINISH); 87 66 return ret; 67 + } 68 + 69 + static void 70 + coda_vm_open(struct vm_area_struct *vma) 71 + { 72 + struct coda_vm_ops *cvm_ops = 73 + container_of(vma->vm_ops, struct coda_vm_ops, vm_ops); 74 + 75 + atomic_inc(&cvm_ops->refcnt); 76 + 77 + if (cvm_ops->host_vm_ops && cvm_ops->host_vm_ops->open) 78 + cvm_ops->host_vm_ops->open(vma); 79 + } 80 + 81 + static void 82 + coda_vm_close(struct vm_area_struct *vma) 83 + { 84 + struct coda_vm_ops *cvm_ops = 85 + container_of(vma->vm_ops, struct coda_vm_ops, vm_ops); 86 + 87 + if (cvm_ops->host_vm_ops && cvm_ops->host_vm_ops->close) 88 + cvm_ops->host_vm_ops->close(vma); 89 + 90 + if (atomic_dec_and_test(&cvm_ops->refcnt)) { 91 + vma->vm_ops = cvm_ops->host_vm_ops; 92 + fput(cvm_ops->coda_file); 93 + kfree(cvm_ops); 94 + } 88 95 } 89 96 90 97 static int 91 98 coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) 92 99 { 93 - struct coda_file_info *cfi; 100 + struct inode *coda_inode = file_inode(coda_file); 101 + struct coda_file_info *cfi = coda_ftoc(coda_file); 102 + struct file *host_file = cfi->cfi_container; 103 + struct inode *host_inode = file_inode(host_file); 94 104 struct coda_inode_info *cii; 95 - struct file *host_file; 96 - struct inode *coda_inode, *host_inode; 97 - 98 - cfi = CODA_FTOC(coda_file); 99 - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 100 - host_file = cfi->cfi_container; 105 + struct coda_vm_ops *cvm_ops; 106 + loff_t ppos; 107 + size_t count; 108 + int ret; 101 109 102 110 if (!host_file->f_op->mmap) 103 111 return -ENODEV; 104 112 105 - coda_inode = file_inode(coda_file); 106 - host_inode = file_inode(host_file); 113 + if (WARN_ON(coda_file != vma->vm_file)) 114 + return -EIO; 115 + 116 + count = vma->vm_end - vma->vm_start; 117 + ppos = vma->vm_pgoff * PAGE_SIZE; 118 + 119 + ret = venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), 120 + &cfi->cfi_access_intent, 121 + count, ppos, CODA_ACCESS_TYPE_MMAP); 122 + if (ret) 123 + return ret; 124 + 125 + cvm_ops = kmalloc(sizeof(struct coda_vm_ops), GFP_KERNEL); 126 + if (!cvm_ops) 127 + return -ENOMEM; 107 128 108 129 cii = ITOC(coda_inode); 109 130 spin_lock(&cii->c_lock); ··· 162 89 * the container file on us! */ 163 90 else if (coda_inode->i_mapping != host_inode->i_mapping) { 164 91 spin_unlock(&cii->c_lock); 92 + kfree(cvm_ops); 165 93 return -EBUSY; 166 94 } 167 95 ··· 171 97 cfi->cfi_mapcount++; 172 98 spin_unlock(&cii->c_lock); 173 99 174 - return call_mmap(host_file, vma); 100 + vma->vm_file = get_file(host_file); 101 + ret = call_mmap(vma->vm_file, vma); 102 + 103 + if (ret) { 104 + /* if call_mmap fails, our caller will put coda_file so we 105 + * should drop the reference to the host_file that we got. 106 + */ 107 + fput(host_file); 108 + kfree(cvm_ops); 109 + } else { 110 + /* here we add redirects for the open/close vm_operations */ 111 + cvm_ops->host_vm_ops = vma->vm_ops; 112 + if (vma->vm_ops) 113 + cvm_ops->vm_ops = *vma->vm_ops; 114 + 115 + cvm_ops->vm_ops.open = coda_vm_open; 116 + cvm_ops->vm_ops.close = coda_vm_close; 117 + cvm_ops->coda_file = coda_file; 118 + atomic_set(&cvm_ops->refcnt, 1); 119 + 120 + vma->vm_ops = &cvm_ops->vm_ops; 121 + } 122 + return ret; 175 123 } 176 124 177 125 int coda_open(struct inode *coda_inode, struct file *coda_file) ··· 223 127 cfi->cfi_magic = CODA_MAGIC; 224 128 cfi->cfi_mapcount = 0; 225 129 cfi->cfi_container = host_file; 130 + /* assume access intents are supported unless we hear otherwise */ 131 + cfi->cfi_access_intent = true; 226 132 227 133 BUG_ON(coda_file->private_data != NULL); 228 134 coda_file->private_data = cfi; ··· 240 142 struct inode *host_inode; 241 143 int err; 242 144 243 - cfi = CODA_FTOC(coda_file); 244 - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 145 + cfi = coda_ftoc(coda_file); 245 146 246 147 err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode), 247 148 coda_flags, coda_file->f_cred->fsuid); ··· 282 185 return err; 283 186 inode_lock(coda_inode); 284 187 285 - cfi = CODA_FTOC(coda_file); 286 - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 188 + cfi = coda_ftoc(coda_file); 287 189 host_file = cfi->cfi_container; 288 190 289 191 err = vfs_fsync(host_file, datasync); ··· 303 207 .fsync = coda_fsync, 304 208 .splice_read = generic_file_splice_read, 305 209 }; 306 -
+2 -1
fs/coda/inode.c
··· 27 27 #include <linux/vmalloc.h> 28 28 29 29 #include <linux/coda.h> 30 - #include <linux/coda_psdev.h> 30 + #include "coda_psdev.h" 31 31 #include "coda_linux.h" 32 32 #include "coda_cache.h" 33 33 ··· 236 236 vcp->vc_sb = NULL; 237 237 sb->s_fs_info = NULL; 238 238 mutex_unlock(&vcp->vc_mutex); 239 + mutex_destroy(&vcp->vc_mutex); 239 240 240 241 pr_info("Bye bye.\n"); 241 242 }
+1 -2
fs/coda/pioctl.c
··· 20 20 #include <linux/uaccess.h> 21 21 22 22 #include <linux/coda.h> 23 - #include <linux/coda_psdev.h> 24 - 23 + #include "coda_psdev.h" 25 24 #include "coda_linux.h" 26 25 27 26 /* pioctl ops */
+23 -13
fs/coda/psdev.c
··· 38 38 #include <linux/uaccess.h> 39 39 40 40 #include <linux/coda.h> 41 - #include <linux/coda_psdev.h> 42 - 41 + #include "coda_psdev.h" 43 42 #include "coda_linux.h" 44 43 45 44 #include "coda_int.h" ··· 99 100 ssize_t retval = 0, count = 0; 100 101 int error; 101 102 103 + /* make sure there is enough to copy out the (opcode, unique) values */ 104 + if (nbytes < (2 * sizeof(u_int32_t))) 105 + return -EINVAL; 106 + 102 107 /* Peek at the opcode, uniquefier */ 103 - if (copy_from_user(&hdr, buf, 2 * sizeof(u_long))) 108 + if (copy_from_user(&hdr, buf, 2 * sizeof(u_int32_t))) 104 109 return -EFAULT; 105 110 106 111 if (DOWNCALL(hdr.opcode)) { ··· 122 119 hdr.opcode, hdr.unique); 123 120 nbytes = size; 124 121 } 125 - CODA_ALLOC(dcbuf, union outputArgs *, nbytes); 122 + dcbuf = kvmalloc(nbytes, GFP_KERNEL); 123 + if (!dcbuf) { 124 + retval = -ENOMEM; 125 + goto out; 126 + } 126 127 if (copy_from_user(dcbuf, buf, nbytes)) { 127 - CODA_FREE(dcbuf, nbytes); 128 + kvfree(dcbuf); 128 129 retval = -EFAULT; 129 130 goto out; 130 131 } 131 132 132 133 /* what downcall errors does Venus handle ? */ 133 - error = coda_downcall(vcp, hdr.opcode, dcbuf); 134 + error = coda_downcall(vcp, hdr.opcode, dcbuf, nbytes); 134 135 135 - CODA_FREE(dcbuf, nbytes); 136 + kvfree(dcbuf); 136 137 if (error) { 137 138 pr_warn("%s: coda_downcall error: %d\n", 138 139 __func__, error); ··· 189 182 if (req->uc_opcode == CODA_OPEN_BY_FD) { 190 183 struct coda_open_by_fd_out *outp = 191 184 (struct coda_open_by_fd_out *)req->uc_data; 192 - if (!outp->oh.result) 185 + if (!outp->oh.result) { 193 186 outp->fh = fget(outp->fd); 187 + if (!outp->fh) 188 + return -EBADF; 189 + } 194 190 } 195 191 196 192 wake_up(&req->uc_sleep); ··· 262 252 goto out; 263 253 } 264 254 265 - CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); 255 + kvfree(req->uc_data); 266 256 kfree(req); 267 257 out: 268 258 mutex_unlock(&vcp->vc_mutex); ··· 324 314 325 315 /* Async requests need to be freed here */ 326 316 if (req->uc_flags & CODA_REQ_ASYNC) { 327 - CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); 317 + kvfree(req->uc_data); 328 318 kfree(req); 329 319 continue; 330 320 } ··· 357 347 .llseek = noop_llseek, 358 348 }; 359 349 360 - static int init_coda_psdev(void) 350 + static int __init init_coda_psdev(void) 361 351 { 362 352 int i, err = 0; 363 353 if (register_chrdev(CODA_PSDEV_MAJOR, "coda", &coda_psdev_fops)) { 364 354 pr_err("%s: unable to get major %d\n", 365 355 __func__, CODA_PSDEV_MAJOR); 366 - return -EIO; 356 + return -EIO; 367 357 } 368 358 coda_psdev_class = class_create(THIS_MODULE, "coda"); 369 359 if (IS_ERR(coda_psdev_class)) { ··· 388 378 MODULE_DESCRIPTION("Coda Distributed File System VFS interface"); 389 379 MODULE_ALIAS_CHARDEV_MAJOR(CODA_PSDEV_MAJOR); 390 380 MODULE_LICENSE("GPL"); 391 - MODULE_VERSION("6.6"); 381 + MODULE_VERSION("7.0"); 392 382 393 383 static int __init init_coda(void) 394 384 {
+1 -2
fs/coda/symlink.c
··· 17 17 #include <linux/pagemap.h> 18 18 19 19 #include <linux/coda.h> 20 - #include <linux/coda_psdev.h> 21 - 20 + #include "coda_psdev.h" 22 21 #include "coda_linux.h" 23 22 24 23 static int coda_symlink_filler(struct file *file, struct page *page)
-11
fs/coda/sysctl.c
··· 12 12 13 13 #include "coda_int.h" 14 14 15 - #ifdef CONFIG_SYSCTL 16 15 static struct ctl_table_header *fs_table_header; 17 16 18 17 static struct ctl_table coda_table[] = { ··· 61 62 fs_table_header = NULL; 62 63 } 63 64 } 64 - 65 - #else 66 - void coda_sysctl_init(void) 67 - { 68 - } 69 - 70 - void coda_sysctl_clean(void) 71 - { 72 - } 73 - #endif
+114 -36
fs/coda/upcall.c
··· 33 33 #include <linux/vfs.h> 34 34 35 35 #include <linux/coda.h> 36 - #include <linux/coda_psdev.h> 36 + #include "coda_psdev.h" 37 37 #include "coda_linux.h" 38 38 #include "coda_cache.h" 39 39 ··· 46 46 { 47 47 union inputArgs *inp; 48 48 49 - CODA_ALLOC(inp, union inputArgs *, size); 49 + inp = kvzalloc(size, GFP_KERNEL); 50 50 if (!inp) 51 51 return ERR_PTR(-ENOMEM); 52 52 ··· 85 85 if (!error) 86 86 *fidp = outp->coda_root.VFid; 87 87 88 - CODA_FREE(inp, insize); 88 + kvfree(inp); 89 89 return error; 90 90 } 91 91 ··· 104 104 if (!error) 105 105 *attr = outp->coda_getattr.attr; 106 106 107 - CODA_FREE(inp, insize); 107 + kvfree(inp); 108 108 return error; 109 109 } 110 110 ··· 123 123 124 124 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 125 125 126 - CODA_FREE(inp, insize); 126 + kvfree(inp); 127 127 return error; 128 128 } 129 129 ··· 153 153 *type = outp->coda_lookup.vtype; 154 154 } 155 155 156 - CODA_FREE(inp, insize); 156 + kvfree(inp); 157 157 return error; 158 158 } 159 159 ··· 173 173 174 174 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 175 175 176 - CODA_FREE(inp, insize); 176 + kvfree(inp); 177 177 return error; 178 178 } 179 179 ··· 194 194 if (!error) 195 195 *fh = outp->coda_open_by_fd.fh; 196 196 197 - CODA_FREE(inp, insize); 197 + kvfree(inp); 198 198 return error; 199 199 } 200 200 ··· 224 224 *newfid = outp->coda_mkdir.VFid; 225 225 } 226 226 227 - CODA_FREE(inp, insize); 227 + kvfree(inp); 228 228 return error; 229 229 } 230 230 ··· 262 262 263 263 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 264 264 265 - CODA_FREE(inp, insize); 265 + kvfree(inp); 266 266 return error; 267 267 } 268 268 ··· 295 295 *newfid = outp->coda_create.VFid; 296 296 } 297 297 298 - CODA_FREE(inp, insize); 298 + kvfree(inp); 299 299 return error; 300 300 } 301 301 ··· 318 318 319 319 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 320 320 321 - CODA_FREE(inp, insize); 321 + kvfree(inp); 322 322 return error; 323 323 } 324 324 ··· 340 340 341 341 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 342 342 343 - CODA_FREE(inp, insize); 343 + kvfree(inp); 344 344 return error; 345 345 } 346 346 ··· 370 370 *(buffer + retlen) = '\0'; 371 371 } 372 372 373 - CODA_FREE(inp, insize); 373 + kvfree(inp); 374 374 return error; 375 375 } 376 376 ··· 398 398 399 399 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 400 400 401 - CODA_FREE(inp, insize); 401 + kvfree(inp); 402 402 return error; 403 403 } 404 404 ··· 433 433 434 434 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 435 435 436 - CODA_FREE(inp, insize); 436 + kvfree(inp); 437 437 return error; 438 438 } 439 439 ··· 449 449 inp->coda_fsync.VFid = *fid; 450 450 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 451 451 452 - CODA_FREE(inp, insize); 452 + kvfree(inp); 453 453 return error; 454 454 } 455 455 ··· 467 467 468 468 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp); 469 469 470 - CODA_FREE(inp, insize); 470 + kvfree(inp); 471 471 return error; 472 472 } 473 473 ··· 543 543 } 544 544 545 545 exit: 546 - CODA_FREE(inp, insize); 546 + kvfree(inp); 547 547 return error; 548 548 } 549 549 ··· 553 553 union outputArgs *outp; 554 554 int insize, outsize, error; 555 555 556 - insize = max_t(unsigned int, INSIZE(statfs), OUTSIZE(statfs)); 556 + insize = SIZE(statfs); 557 557 UPARG(CODA_STATFS); 558 558 559 559 error = coda_upcall(coda_vcp(dentry->d_sb), insize, &outsize, inp); ··· 565 565 sfs->f_ffree = outp->coda_statfs.stat.f_ffree; 566 566 } 567 567 568 - CODA_FREE(inp, insize); 568 + kvfree(inp); 569 569 return error; 570 + } 571 + 572 + int venus_access_intent(struct super_block *sb, struct CodaFid *fid, 573 + bool *access_intent_supported, 574 + size_t count, loff_t ppos, int type) 575 + { 576 + union inputArgs *inp; 577 + union outputArgs *outp; 578 + int insize, outsize, error; 579 + bool finalizer = 580 + type == CODA_ACCESS_TYPE_READ_FINISH || 581 + type == CODA_ACCESS_TYPE_WRITE_FINISH; 582 + 583 + if (!*access_intent_supported && !finalizer) 584 + return 0; 585 + 586 + insize = SIZE(access_intent); 587 + UPARG(CODA_ACCESS_INTENT); 588 + 589 + inp->coda_access_intent.VFid = *fid; 590 + inp->coda_access_intent.count = count; 591 + inp->coda_access_intent.pos = ppos; 592 + inp->coda_access_intent.type = type; 593 + 594 + error = coda_upcall(coda_vcp(sb), insize, 595 + finalizer ? NULL : &outsize, inp); 596 + 597 + /* 598 + * we have to free the request buffer for synchronous upcalls 599 + * or when asynchronous upcalls fail, but not when asynchronous 600 + * upcalls succeed 601 + */ 602 + if (!finalizer || error) 603 + kvfree(inp); 604 + 605 + /* Chunked access is not supported or an old Coda client */ 606 + if (error == -EOPNOTSUPP) { 607 + *access_intent_supported = false; 608 + error = 0; 609 + } 610 + return error; 570 611 } 571 612 572 613 /* ··· 639 598 * has seen them, 640 599 * - CODA_CLOSE or CODA_RELEASE upcall (to avoid reference count problems) 641 600 * - CODA_STORE (to avoid data loss) 601 + * - CODA_ACCESS_INTENT (to avoid reference count problems) 642 602 */ 643 603 #define CODA_INTERRUPTIBLE(r) (!coda_hard && \ 644 604 (((r)->uc_opcode != CODA_CLOSE && \ 645 605 (r)->uc_opcode != CODA_STORE && \ 606 + (r)->uc_opcode != CODA_ACCESS_INTENT && \ 646 607 (r)->uc_opcode != CODA_RELEASE) || \ 647 608 (r)->uc_flags & CODA_REQ_READ)) 648 609 ··· 730 687 goto exit; 731 688 } 732 689 733 - req->uc_data = (void *)buffer; 734 - req->uc_flags = 0; 735 - req->uc_inSize = inSize; 736 - req->uc_outSize = *outSize ? *outSize : inSize; 737 - req->uc_opcode = ((union inputArgs *)buffer)->ih.opcode; 738 - req->uc_unique = ++vcp->vc_seq; 739 - init_waitqueue_head(&req->uc_sleep); 690 + buffer->ih.unique = ++vcp->vc_seq; 740 691 741 - /* Fill in the common input args. */ 742 - ((union inputArgs *)buffer)->ih.unique = req->uc_unique; 692 + req->uc_data = (void *)buffer; 693 + req->uc_flags = outSize ? 0 : CODA_REQ_ASYNC; 694 + req->uc_inSize = inSize; 695 + req->uc_outSize = (outSize && *outSize) ? *outSize : inSize; 696 + req->uc_opcode = buffer->ih.opcode; 697 + req->uc_unique = buffer->ih.unique; 698 + init_waitqueue_head(&req->uc_sleep); 743 699 744 700 /* Append msg to pending queue and poke Venus. */ 745 701 list_add_tail(&req->uc_chain, &vcp->vc_pending); 746 - 747 702 wake_up_interruptible(&vcp->vc_waitq); 703 + 704 + if (req->uc_flags & CODA_REQ_ASYNC) { 705 + mutex_unlock(&vcp->vc_mutex); 706 + return 0; 707 + } 708 + 748 709 /* We can be interrupted while we wait for Venus to process 749 710 * our request. If the interrupt occurs before Venus has read 750 711 * the request, we dequeue and return. If it occurs after the ··· 790 743 sig_req = kmalloc(sizeof(struct upc_req), GFP_KERNEL); 791 744 if (!sig_req) goto exit; 792 745 793 - CODA_ALLOC((sig_req->uc_data), char *, sizeof(struct coda_in_hdr)); 794 - if (!sig_req->uc_data) { 746 + sig_inputArgs = kvzalloc(sizeof(struct coda_in_hdr), GFP_KERNEL); 747 + if (!sig_inputArgs) { 795 748 kfree(sig_req); 796 749 goto exit; 797 750 } 798 751 799 752 error = -EINTR; 800 - sig_inputArgs = (union inputArgs *)sig_req->uc_data; 801 753 sig_inputArgs->ih.opcode = CODA_SIGNAL; 802 754 sig_inputArgs->ih.unique = req->uc_unique; 803 755 804 756 sig_req->uc_flags = CODA_REQ_ASYNC; 805 757 sig_req->uc_opcode = sig_inputArgs->ih.opcode; 806 758 sig_req->uc_unique = sig_inputArgs->ih.unique; 759 + sig_req->uc_data = (void *)sig_inputArgs; 807 760 sig_req->uc_inSize = sizeof(struct coda_in_hdr); 808 761 sig_req->uc_outSize = sizeof(struct coda_in_hdr); 809 762 ··· 851 804 * 852 805 * CODA_REPLACE -- replace one CodaFid with another throughout the name cache */ 853 806 854 - int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out) 807 + int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out, 808 + size_t nbytes) 855 809 { 856 810 struct inode *inode = NULL; 857 811 struct CodaFid *fid = NULL, *newfid; 858 812 struct super_block *sb; 813 + 814 + /* 815 + * Make sure we have received enough data from the cache 816 + * manager to populate the necessary fields in the buffer 817 + */ 818 + switch (opcode) { 819 + case CODA_PURGEUSER: 820 + if (nbytes < sizeof(struct coda_purgeuser_out)) 821 + return -EINVAL; 822 + break; 823 + 824 + case CODA_ZAPDIR: 825 + if (nbytes < sizeof(struct coda_zapdir_out)) 826 + return -EINVAL; 827 + break; 828 + 829 + case CODA_ZAPFILE: 830 + if (nbytes < sizeof(struct coda_zapfile_out)) 831 + return -EINVAL; 832 + break; 833 + 834 + case CODA_PURGEFID: 835 + if (nbytes < sizeof(struct coda_purgefid_out)) 836 + return -EINVAL; 837 + break; 838 + 839 + case CODA_REPLACE: 840 + if (nbytes < sizeof(struct coda_replace_out)) 841 + return -EINVAL; 842 + break; 843 + } 859 844 860 845 /* Handle invalidation requests. */ 861 846 mutex_lock(&vcp->vc_mutex); ··· 958 879 iput(inode); 959 880 return 0; 960 881 } 961 -
+4 -8
fs/eventpoll.c
··· 2313 2313 size_t, sigsetsize) 2314 2314 { 2315 2315 int error; 2316 - sigset_t ksigmask, sigsaved; 2317 2316 2318 2317 /* 2319 2318 * If the caller wants a certain signal mask to be set during the wait, 2320 2319 * we apply it here. 2321 2320 */ 2322 - error = set_user_sigmask(sigmask, &ksigmask, &sigsaved, sigsetsize); 2321 + error = set_user_sigmask(sigmask, sigsetsize); 2323 2322 if (error) 2324 2323 return error; 2325 2324 2326 2325 error = do_epoll_wait(epfd, events, maxevents, timeout); 2327 - 2328 - restore_user_sigmask(sigmask, &sigsaved, error == -EINTR); 2326 + restore_saved_sigmask_unless(error == -EINTR); 2329 2327 2330 2328 return error; 2331 2329 } ··· 2336 2338 compat_size_t, sigsetsize) 2337 2339 { 2338 2340 long err; 2339 - sigset_t ksigmask, sigsaved; 2340 2341 2341 2342 /* 2342 2343 * If the caller wants a certain signal mask to be set during the wait, 2343 2344 * we apply it here. 2344 2345 */ 2345 - err = set_compat_user_sigmask(sigmask, &ksigmask, &sigsaved, sigsetsize); 2346 + err = set_compat_user_sigmask(sigmask, sigsetsize); 2346 2347 if (err) 2347 2348 return err; 2348 2349 2349 2350 err = do_epoll_wait(epfd, events, maxevents, timeout); 2350 - 2351 - restore_user_sigmask(sigmask, &sigsaved, err == -EINTR); 2351 + restore_saved_sigmask_unless(err == -EINTR); 2352 2352 2353 2353 return err; 2354 2354 }
+1 -1
fs/hfsplus/xattr.c
··· 407 407 int offset = 0; 408 408 409 409 if (!is_known_namespace(xattr_name)) { 410 - strncpy(buffer, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN); 410 + memcpy(buffer, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN); 411 411 offset += XATTR_MAC_OSX_PREFIX_LEN; 412 412 len += XATTR_MAC_OSX_PREFIX_LEN; 413 413 }
+3 -8
fs/io_uring.c
··· 2400 2400 const sigset_t __user *sig, size_t sigsz) 2401 2401 { 2402 2402 struct io_cq_ring *ring = ctx->cq_ring; 2403 - sigset_t ksigmask, sigsaved; 2404 2403 int ret; 2405 2404 2406 2405 if (io_cqring_events(ring) >= min_events) ··· 2409 2410 #ifdef CONFIG_COMPAT 2410 2411 if (in_compat_syscall()) 2411 2412 ret = set_compat_user_sigmask((const compat_sigset_t __user *)sig, 2412 - &ksigmask, &sigsaved, sigsz); 2413 + sigsz); 2413 2414 else 2414 2415 #endif 2415 - ret = set_user_sigmask(sig, &ksigmask, 2416 - &sigsaved, sigsz); 2416 + ret = set_user_sigmask(sig, sigsz); 2417 2417 2418 2418 if (ret) 2419 2419 return ret; 2420 2420 } 2421 2421 2422 2422 ret = wait_event_interruptible(ctx->wait, io_cqring_events(ring) >= min_events); 2423 - 2424 - if (sig) 2425 - restore_user_sigmask(sig, &sigsaved, ret == -ERESTARTSYS); 2426 - 2423 + restore_saved_sigmask_unless(ret == -ERESTARTSYS); 2427 2424 if (ret == -ERESTARTSYS) 2428 2425 ret = -EINTR; 2429 2426
+2 -1
fs/proc/Kconfig
··· 58 58 snapshot. 59 59 60 60 If you say Y here, the collected device dumps will be added 61 - as ELF notes to /proc/vmcore. 61 + as ELF notes to /proc/vmcore. You can still disable device 62 + dump using the kernel command line option 'novmcoredd'. 62 63 63 64 config PROC_SYSCTL 64 65 bool "Sysctl support (/proc/sys)" if EXPERT
+17 -10
fs/proc/inode.c
··· 200 200 struct proc_dir_entry *pde = PDE(file_inode(file)); 201 201 loff_t rv = -EINVAL; 202 202 if (use_pde(pde)) { 203 - loff_t (*llseek)(struct file *, loff_t, int); 203 + typeof_member(struct file_operations, llseek) llseek; 204 + 204 205 llseek = pde->proc_fops->llseek; 205 206 if (!llseek) 206 207 llseek = default_llseek; ··· 213 212 214 213 static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 215 214 { 216 - ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); 217 215 struct proc_dir_entry *pde = PDE(file_inode(file)); 218 216 ssize_t rv = -EIO; 219 217 if (use_pde(pde)) { 218 + typeof_member(struct file_operations, read) read; 219 + 220 220 read = pde->proc_fops->read; 221 221 if (read) 222 222 rv = read(file, buf, count, ppos); ··· 228 226 229 227 static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 230 228 { 231 - ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); 232 229 struct proc_dir_entry *pde = PDE(file_inode(file)); 233 230 ssize_t rv = -EIO; 234 231 if (use_pde(pde)) { 232 + typeof_member(struct file_operations, write) write; 233 + 235 234 write = pde->proc_fops->write; 236 235 if (write) 237 236 rv = write(file, buf, count, ppos); ··· 245 242 { 246 243 struct proc_dir_entry *pde = PDE(file_inode(file)); 247 244 __poll_t rv = DEFAULT_POLLMASK; 248 - __poll_t (*poll)(struct file *, struct poll_table_struct *); 249 245 if (use_pde(pde)) { 246 + typeof_member(struct file_operations, poll) poll; 247 + 250 248 poll = pde->proc_fops->poll; 251 249 if (poll) 252 250 rv = poll(file, pts); ··· 260 256 { 261 257 struct proc_dir_entry *pde = PDE(file_inode(file)); 262 258 long rv = -ENOTTY; 263 - long (*ioctl)(struct file *, unsigned int, unsigned long); 264 259 if (use_pde(pde)) { 260 + typeof_member(struct file_operations, unlocked_ioctl) ioctl; 261 + 265 262 ioctl = pde->proc_fops->unlocked_ioctl; 266 263 if (ioctl) 267 264 rv = ioctl(file, cmd, arg); ··· 276 271 { 277 272 struct proc_dir_entry *pde = PDE(file_inode(file)); 278 273 long rv = -ENOTTY; 279 - long (*compat_ioctl)(struct file *, unsigned int, unsigned long); 280 274 if (use_pde(pde)) { 275 + typeof_member(struct file_operations, compat_ioctl) compat_ioctl; 276 + 281 277 compat_ioctl = pde->proc_fops->compat_ioctl; 282 278 if (compat_ioctl) 283 279 rv = compat_ioctl(file, cmd, arg); ··· 292 286 { 293 287 struct proc_dir_entry *pde = PDE(file_inode(file)); 294 288 int rv = -EIO; 295 - int (*mmap)(struct file *, struct vm_area_struct *); 296 289 if (use_pde(pde)) { 290 + typeof_member(struct file_operations, mmap) mmap; 291 + 297 292 mmap = pde->proc_fops->mmap; 298 293 if (mmap) 299 294 rv = mmap(file, vma); ··· 312 305 unsigned long rv = -EIO; 313 306 314 307 if (use_pde(pde)) { 315 - typeof(proc_reg_get_unmapped_area) *get_area; 308 + typeof_member(struct file_operations, get_unmapped_area) get_area; 316 309 317 310 get_area = pde->proc_fops->get_unmapped_area; 318 311 #ifdef CONFIG_MMU ··· 333 326 { 334 327 struct proc_dir_entry *pde = PDE(inode); 335 328 int rv = 0; 336 - int (*open)(struct inode *, struct file *); 337 - int (*release)(struct inode *, struct file *); 329 + typeof_member(struct file_operations, open) open; 330 + typeof_member(struct file_operations, release) release; 338 331 struct pde_opener *pdeo; 339 332 340 333 /*
+4
fs/proc/proc_sysctl.c
··· 499 499 500 500 if (root->set_ownership) 501 501 root->set_ownership(head, table, &inode->i_uid, &inode->i_gid); 502 + else { 503 + inode->i_uid = GLOBAL_ROOT_UID; 504 + inode->i_gid = GLOBAL_ROOT_GID; 505 + } 502 506 503 507 return inode; 504 508 }
+9
fs/proc/vmcore.c
··· 21 21 #include <linux/init.h> 22 22 #include <linux/crash_dump.h> 23 23 #include <linux/list.h> 24 + #include <linux/moduleparam.h> 24 25 #include <linux/mutex.h> 25 26 #include <linux/vmalloc.h> 26 27 #include <linux/pagemap.h> ··· 55 54 /* Device Dump list and mutex to synchronize access to list */ 56 55 static LIST_HEAD(vmcoredd_list); 57 56 static DEFINE_MUTEX(vmcoredd_mutex); 57 + 58 + static bool vmcoredd_disabled; 59 + core_param(novmcoredd, vmcoredd_disabled, bool, 0); 58 60 #endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */ 59 61 60 62 /* Device Dump Size */ ··· 1455 1451 void *buf = NULL; 1456 1452 size_t data_size; 1457 1453 int ret; 1454 + 1455 + if (vmcoredd_disabled) { 1456 + pr_err_once("Device dump is disabled\n"); 1457 + return -EINVAL; 1458 + } 1458 1459 1459 1460 if (!data || !strlen(data->dump_name) || 1460 1461 !data->vmcoredd_callback || !data->size)
+2 -4
fs/reiserfs/journal.c
··· 94 94 struct super_block *sb); 95 95 static void release_journal_dev(struct super_block *super, 96 96 struct reiserfs_journal *journal); 97 - static int dirty_one_transaction(struct super_block *s, 97 + static void dirty_one_transaction(struct super_block *s, 98 98 struct reiserfs_journal_list *jl); 99 99 static void flush_async_commits(struct work_struct *work); 100 100 static void queue_log_writer(struct super_block *s); ··· 1682 1682 } 1683 1683 1684 1684 /* used by flush_commit_list */ 1685 - static int dirty_one_transaction(struct super_block *s, 1685 + static void dirty_one_transaction(struct super_block *s, 1686 1686 struct reiserfs_journal_list *jl) 1687 1687 { 1688 1688 struct reiserfs_journal_cnode *cn; 1689 1689 struct reiserfs_journal_list *pjl; 1690 - int ret = 0; 1691 1690 1692 1691 jl->j_state |= LIST_DIRTY; 1693 1692 cn = jl->j_realblock; ··· 1715 1716 } 1716 1717 cn = cn->next; 1717 1718 } 1718 - return ret; 1719 1719 } 1720 1720 1721 1721 static int kupdate_transactions(struct super_block *s,
+25 -71
fs/select.c
··· 294 294 PT_OLD_TIMESPEC = 3, 295 295 }; 296 296 297 - static int poll_select_copy_remaining(struct timespec64 *end_time, 298 - void __user *p, 299 - enum poll_time_type pt_type, int ret) 297 + static int poll_select_finish(struct timespec64 *end_time, 298 + void __user *p, 299 + enum poll_time_type pt_type, int ret) 300 300 { 301 301 struct timespec64 rts; 302 + 303 + restore_saved_sigmask_unless(ret == -ERESTARTNOHAND); 302 304 303 305 if (!p) 304 306 return ret; ··· 716 714 } 717 715 718 716 ret = core_sys_select(n, inp, outp, exp, to); 719 - ret = poll_select_copy_remaining(&end_time, tvp, PT_TIMEVAL, ret); 720 - 721 - return ret; 717 + return poll_select_finish(&end_time, tvp, PT_TIMEVAL, ret); 722 718 } 723 719 724 720 SYSCALL_DEFINE5(select, int, n, fd_set __user *, inp, fd_set __user *, outp, ··· 730 730 const sigset_t __user *sigmask, size_t sigsetsize, 731 731 enum poll_time_type type) 732 732 { 733 - sigset_t ksigmask, sigsaved; 734 733 struct timespec64 ts, end_time, *to = NULL; 735 734 int ret; 736 735 ··· 752 753 return -EINVAL; 753 754 } 754 755 755 - ret = set_user_sigmask(sigmask, &ksigmask, &sigsaved, sigsetsize); 756 + ret = set_user_sigmask(sigmask, sigsetsize); 756 757 if (ret) 757 758 return ret; 758 759 759 760 ret = core_sys_select(n, inp, outp, exp, to); 760 - restore_user_sigmask(sigmask, &sigsaved, ret == -ERESTARTNOHAND); 761 - ret = poll_select_copy_remaining(&end_time, tsp, type, ret); 762 - 763 - return ret; 761 + return poll_select_finish(&end_time, tsp, type, ret); 764 762 } 765 763 766 764 /* ··· 922 926 if (!count) { 923 927 count = wait->error; 924 928 if (signal_pending(current)) 925 - count = -EINTR; 929 + count = -ERESTARTNOHAND; 926 930 } 927 931 if (count || timed_out) 928 932 break; ··· 961 965 struct timespec64 *end_time) 962 966 { 963 967 struct poll_wqueues table; 964 - int err = -EFAULT, fdcount, len, size; 968 + int err = -EFAULT, fdcount, len; 965 969 /* Allocate small arguments on the stack to save memory and be 966 970 faster - use long to make sure the buffer is aligned properly 967 971 on 64 bit archs to avoid unaligned access */ ··· 989 993 break; 990 994 991 995 len = min(todo, POLLFD_PER_PAGE); 992 - size = sizeof(struct poll_list) + sizeof(struct pollfd) * len; 993 - walk = walk->next = kmalloc(size, GFP_KERNEL); 996 + walk = walk->next = kmalloc(struct_size(walk, entries, len), 997 + GFP_KERNEL); 994 998 if (!walk) { 995 999 err = -ENOMEM; 996 1000 goto out_fds; ··· 1037 1041 1038 1042 ret = do_sys_poll(ufds, nfds, to); 1039 1043 1040 - if (ret == -EINTR) { 1044 + if (ret == -ERESTARTNOHAND) { 1041 1045 restart_block->fn = do_restart_poll; 1042 1046 ret = -ERESTART_RESTARTBLOCK; 1043 1047 } ··· 1058 1062 1059 1063 ret = do_sys_poll(ufds, nfds, to); 1060 1064 1061 - if (ret == -EINTR) { 1065 + if (ret == -ERESTARTNOHAND) { 1062 1066 struct restart_block *restart_block; 1063 1067 1064 1068 restart_block = &current->restart_block; ··· 1082 1086 struct __kernel_timespec __user *, tsp, const sigset_t __user *, sigmask, 1083 1087 size_t, sigsetsize) 1084 1088 { 1085 - sigset_t ksigmask, sigsaved; 1086 1089 struct timespec64 ts, end_time, *to = NULL; 1087 1090 int ret; 1088 1091 ··· 1094 1099 return -EINVAL; 1095 1100 } 1096 1101 1097 - ret = set_user_sigmask(sigmask, &ksigmask, &sigsaved, sigsetsize); 1102 + ret = set_user_sigmask(sigmask, sigsetsize); 1098 1103 if (ret) 1099 1104 return ret; 1100 1105 1101 1106 ret = do_sys_poll(ufds, nfds, to); 1102 - 1103 - restore_user_sigmask(sigmask, &sigsaved, ret == -EINTR); 1104 - /* We can restart this syscall, usually */ 1105 - if (ret == -EINTR) 1106 - ret = -ERESTARTNOHAND; 1107 - 1108 - ret = poll_select_copy_remaining(&end_time, tsp, PT_TIMESPEC, ret); 1109 - 1110 - return ret; 1107 + return poll_select_finish(&end_time, tsp, PT_TIMESPEC, ret); 1111 1108 } 1112 1109 1113 1110 #if defined(CONFIG_COMPAT_32BIT_TIME) && !defined(CONFIG_64BIT) ··· 1108 1121 struct old_timespec32 __user *, tsp, const sigset_t __user *, sigmask, 1109 1122 size_t, sigsetsize) 1110 1123 { 1111 - sigset_t ksigmask, sigsaved; 1112 1124 struct timespec64 ts, end_time, *to = NULL; 1113 1125 int ret; 1114 1126 ··· 1120 1134 return -EINVAL; 1121 1135 } 1122 1136 1123 - ret = set_user_sigmask(sigmask, &ksigmask, &sigsaved, sigsetsize); 1137 + ret = set_user_sigmask(sigmask, sigsetsize); 1124 1138 if (ret) 1125 1139 return ret; 1126 1140 1127 1141 ret = do_sys_poll(ufds, nfds, to); 1128 - 1129 - restore_user_sigmask(sigmask, &sigsaved, ret == -EINTR); 1130 - /* We can restart this syscall, usually */ 1131 - if (ret == -EINTR) 1132 - ret = -ERESTARTNOHAND; 1133 - 1134 - ret = poll_select_copy_remaining(&end_time, tsp, PT_OLD_TIMESPEC, ret); 1135 - 1136 - return ret; 1142 + return poll_select_finish(&end_time, tsp, PT_OLD_TIMESPEC, ret); 1137 1143 } 1138 1144 #endif 1139 1145 ··· 1262 1284 } 1263 1285 1264 1286 ret = compat_core_sys_select(n, inp, outp, exp, to); 1265 - ret = poll_select_copy_remaining(&end_time, tvp, PT_OLD_TIMEVAL, ret); 1266 - 1267 - return ret; 1287 + return poll_select_finish(&end_time, tvp, PT_OLD_TIMEVAL, ret); 1268 1288 } 1269 1289 1270 1290 COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp, ··· 1295 1319 void __user *tsp, compat_sigset_t __user *sigmask, 1296 1320 compat_size_t sigsetsize, enum poll_time_type type) 1297 1321 { 1298 - sigset_t ksigmask, sigsaved; 1299 1322 struct timespec64 ts, end_time, *to = NULL; 1300 1323 int ret; 1301 1324 ··· 1317 1342 return -EINVAL; 1318 1343 } 1319 1344 1320 - ret = set_compat_user_sigmask(sigmask, &ksigmask, &sigsaved, sigsetsize); 1345 + ret = set_compat_user_sigmask(sigmask, sigsetsize); 1321 1346 if (ret) 1322 1347 return ret; 1323 1348 1324 1349 ret = compat_core_sys_select(n, inp, outp, exp, to); 1325 - restore_user_sigmask(sigmask, &sigsaved, ret == -ERESTARTNOHAND); 1326 - ret = poll_select_copy_remaining(&end_time, tsp, type, ret); 1327 - 1328 - return ret; 1350 + return poll_select_finish(&end_time, tsp, type, ret); 1329 1351 } 1330 1352 1331 1353 COMPAT_SYSCALL_DEFINE6(pselect6_time64, int, n, compat_ulong_t __user *, inp, ··· 1374 1402 unsigned int, nfds, struct old_timespec32 __user *, tsp, 1375 1403 const compat_sigset_t __user *, sigmask, compat_size_t, sigsetsize) 1376 1404 { 1377 - sigset_t ksigmask, sigsaved; 1378 1405 struct timespec64 ts, end_time, *to = NULL; 1379 1406 int ret; 1380 1407 ··· 1386 1415 return -EINVAL; 1387 1416 } 1388 1417 1389 - ret = set_compat_user_sigmask(sigmask, &ksigmask, &sigsaved, sigsetsize); 1418 + ret = set_compat_user_sigmask(sigmask, sigsetsize); 1390 1419 if (ret) 1391 1420 return ret; 1392 1421 1393 1422 ret = do_sys_poll(ufds, nfds, to); 1394 - 1395 - restore_user_sigmask(sigmask, &sigsaved, ret == -EINTR); 1396 - /* We can restart this syscall, usually */ 1397 - if (ret == -EINTR) 1398 - ret = -ERESTARTNOHAND; 1399 - 1400 - ret = poll_select_copy_remaining(&end_time, tsp, PT_OLD_TIMESPEC, ret); 1401 - 1402 - return ret; 1423 + return poll_select_finish(&end_time, tsp, PT_OLD_TIMESPEC, ret); 1403 1424 } 1404 1425 #endif 1405 1426 ··· 1400 1437 unsigned int, nfds, struct __kernel_timespec __user *, tsp, 1401 1438 const compat_sigset_t __user *, sigmask, compat_size_t, sigsetsize) 1402 1439 { 1403 - sigset_t ksigmask, sigsaved; 1404 1440 struct timespec64 ts, end_time, *to = NULL; 1405 1441 int ret; 1406 1442 ··· 1412 1450 return -EINVAL; 1413 1451 } 1414 1452 1415 - ret = set_compat_user_sigmask(sigmask, &ksigmask, &sigsaved, sigsetsize); 1453 + ret = set_compat_user_sigmask(sigmask, sigsetsize); 1416 1454 if (ret) 1417 1455 return ret; 1418 1456 1419 1457 ret = do_sys_poll(ufds, nfds, to); 1420 - 1421 - restore_user_sigmask(sigmask, &sigsaved, ret == -EINTR); 1422 - /* We can restart this syscall, usually */ 1423 - if (ret == -EINTR) 1424 - ret = -ERESTARTNOHAND; 1425 - 1426 - ret = poll_select_copy_remaining(&end_time, tsp, PT_TIMESPEC, ret); 1427 - 1428 - return ret; 1458 + return poll_select_finish(&end_time, tsp, PT_TIMESPEC, ret); 1429 1459 } 1430 1460 1431 1461 #endif
-2
fs/ufs/super.c
··· 1407 1407 struct super_block *sb = dentry->d_sb; 1408 1408 struct ufs_sb_private_info *uspi= UFS_SB(sb)->s_uspi; 1409 1409 unsigned flags = UFS_SB(sb)->s_flags; 1410 - struct ufs_super_block_third *usb3; 1411 1410 u64 id = huge_encode_dev(sb->s_bdev->bd_dev); 1412 1411 1413 1412 mutex_lock(&UFS_SB(sb)->s_lock); 1414 - usb3 = ubh_get_usb_third(uspi); 1415 1413 1416 1414 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) 1417 1415 buf->f_type = UFS2_MAGIC;
+4 -2
include/asm-generic/bug.h
··· 104 104 warn_slowpath_fmt_taint(__FILE__, __LINE__, taint, arg) 105 105 #else 106 106 extern __printf(1, 2) void __warn_printk(const char *fmt, ...); 107 - #define __WARN() __WARN_TAINT(TAINT_WARN) 108 - #define __WARN_printf(arg...) do { __warn_printk(arg); __WARN(); } while (0) 107 + #define __WARN() do { \ 108 + printk(KERN_WARNING CUT_HERE); __WARN_TAINT(TAINT_WARN); \ 109 + } while (0) 110 + #define __WARN_printf(arg...) __WARN_printf_taint(TAINT_WARN, arg) 109 111 #define __WARN_printf_taint(taint, arg...) \ 110 112 do { __warn_printk(arg); __WARN_TAINT(taint); } while (0) 111 113 #endif
+60 -14
include/asm-generic/cacheflush.h
··· 5 5 /* Keep includes the same across arches. */ 6 6 #include <linux/mm.h> 7 7 8 + #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 9 + 8 10 /* 9 11 * The cache doesn't need to be flushed when TLB entries change when 10 12 * the cache is mapped to physical memory, not virtual memory 11 13 */ 12 - #define flush_cache_all() do { } while (0) 13 - #define flush_cache_mm(mm) do { } while (0) 14 - #define flush_cache_dup_mm(mm) do { } while (0) 15 - #define flush_cache_range(vma, start, end) do { } while (0) 16 - #define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 17 - #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 18 - #define flush_dcache_page(page) do { } while (0) 19 - #define flush_dcache_mmap_lock(mapping) do { } while (0) 20 - #define flush_dcache_mmap_unlock(mapping) do { } while (0) 21 - #define flush_icache_range(start, end) do { } while (0) 22 - #define flush_icache_page(vma,pg) do { } while (0) 23 - #define flush_icache_user_range(vma,pg,adr,len) do { } while (0) 24 - #define flush_cache_vmap(start, end) do { } while (0) 25 - #define flush_cache_vunmap(start, end) do { } while (0) 14 + static inline void flush_cache_all(void) 15 + { 16 + } 17 + 18 + static inline void flush_cache_mm(struct mm_struct *mm) 19 + { 20 + } 21 + 22 + static inline void flush_cache_dup_mm(struct mm_struct *mm) 23 + { 24 + } 25 + 26 + static inline void flush_cache_range(struct vm_area_struct *vma, 27 + unsigned long start, 28 + unsigned long end) 29 + { 30 + } 31 + 32 + static inline void flush_cache_page(struct vm_area_struct *vma, 33 + unsigned long vmaddr, 34 + unsigned long pfn) 35 + { 36 + } 37 + 38 + static inline void flush_dcache_page(struct page *page) 39 + { 40 + } 41 + 42 + static inline void flush_dcache_mmap_lock(struct address_space *mapping) 43 + { 44 + } 45 + 46 + static inline void flush_dcache_mmap_unlock(struct address_space *mapping) 47 + { 48 + } 49 + 50 + static inline void flush_icache_range(unsigned long start, unsigned long end) 51 + { 52 + } 53 + 54 + static inline void flush_icache_page(struct vm_area_struct *vma, 55 + struct page *page) 56 + { 57 + } 58 + 59 + static inline void flush_icache_user_range(struct vm_area_struct *vma, 60 + struct page *page, 61 + unsigned long addr, int len) 62 + { 63 + } 64 + 65 + static inline void flush_cache_vmap(unsigned long start, unsigned long end) 66 + { 67 + } 68 + 69 + static inline void flush_cache_vunmap(unsigned long start, unsigned long end) 70 + { 71 + } 26 72 27 73 #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 28 74 do { \
+10 -7
include/linux/bits.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 #ifndef __LINUX_BITS_H 3 3 #define __LINUX_BITS_H 4 + 5 + #include <linux/const.h> 4 6 #include <asm/bitsperlong.h> 5 7 6 - #define BIT(nr) (1UL << (nr)) 7 - #define BIT_ULL(nr) (1ULL << (nr)) 8 - #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) 8 + #define BIT(nr) (UL(1) << (nr)) 9 + #define BIT_ULL(nr) (ULL(1) << (nr)) 10 + #define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG)) 9 11 #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 10 - #define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) 12 + #define BIT_ULL_MASK(nr) (ULL(1) << ((nr) % BITS_PER_LONG_LONG)) 11 13 #define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) 12 14 #define BITS_PER_BYTE 8 13 15 ··· 19 17 * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. 20 18 */ 21 19 #define GENMASK(h, l) \ 22 - (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) 20 + (((~UL(0)) - (UL(1) << (l)) + 1) & \ 21 + (~UL(0) >> (BITS_PER_LONG - 1 - (h)))) 23 22 24 23 #define GENMASK_ULL(h, l) \ 25 - (((~0ULL) - (1ULL << (l)) + 1) & \ 26 - (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) 24 + (((~ULL(0)) - (ULL(1) << (l)) + 1) & \ 25 + (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h)))) 27 26 28 27 #endif /* __LINUX_BITS_H */
+1 -2
include/linux/coda.h
··· 58 58 #ifndef _CODA_HEADER_ 59 59 #define _CODA_HEADER_ 60 60 61 - #if defined(__linux__) 62 61 typedef unsigned long long u_quad_t; 63 - #endif 62 + 64 63 #include <uapi/linux/coda.h> 65 64 #endif
+39 -16
include/linux/coda_psdev.h fs/coda/coda_psdev.h
··· 3 3 #define __CODA_PSDEV_H 4 4 5 5 #include <linux/backing-dev.h> 6 + #include <linux/magic.h> 6 7 #include <linux/mutex.h> 7 - #include <uapi/linux/coda_psdev.h> 8 + 9 + #define CODA_PSDEV_MAJOR 67 10 + #define MAX_CODADEVS 5 /* how many do we allow */ 8 11 9 12 struct kstatfs; 13 + 14 + /* messages between coda filesystem in kernel and Venus */ 15 + struct upc_req { 16 + struct list_head uc_chain; 17 + caddr_t uc_data; 18 + u_short uc_flags; 19 + u_short uc_inSize; /* Size is at most 5000 bytes */ 20 + u_short uc_outSize; 21 + u_short uc_opcode; /* copied from data to save lookup */ 22 + int uc_unique; 23 + wait_queue_head_t uc_sleep; /* process' wait queue */ 24 + }; 25 + 26 + #define CODA_REQ_ASYNC 0x1 27 + #define CODA_REQ_READ 0x2 28 + #define CODA_REQ_WRITE 0x4 29 + #define CODA_REQ_ABORT 0x8 10 30 11 31 /* communication pending/processing queues */ 12 32 struct venus_comm { ··· 39 19 struct mutex vc_mutex; 40 20 }; 41 21 42 - 43 22 static inline struct venus_comm *coda_vcp(struct super_block *sb) 44 23 { 45 24 return (struct venus_comm *)((sb)->s_fs_info); ··· 49 30 int venus_getattr(struct super_block *sb, struct CodaFid *fid, 50 31 struct coda_vattr *attr); 51 32 int venus_setattr(struct super_block *, struct CodaFid *, struct coda_vattr *); 52 - int venus_lookup(struct super_block *sb, struct CodaFid *fid, 53 - const char *name, int length, int *type, 33 + int venus_lookup(struct super_block *sb, struct CodaFid *fid, 34 + const char *name, int length, int *type, 54 35 struct CodaFid *resfid); 55 36 int venus_close(struct super_block *sb, struct CodaFid *fid, int flags, 56 37 kuid_t uid); 57 38 int venus_open(struct super_block *sb, struct CodaFid *fid, int flags, 58 39 struct file **f); 59 - int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid, 60 - const char *name, int length, 40 + int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid, 41 + const char *name, int length, 61 42 struct CodaFid *newfid, struct coda_vattr *attrs); 62 - int venus_create(struct super_block *sb, struct CodaFid *dirfid, 43 + int venus_create(struct super_block *sb, struct CodaFid *dirfid, 63 44 const char *name, int length, int excl, int mode, 64 - struct CodaFid *newfid, struct coda_vattr *attrs) ; 65 - int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid, 45 + struct CodaFid *newfid, struct coda_vattr *attrs); 46 + int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid, 66 47 const char *name, int length); 67 - int venus_remove(struct super_block *sb, struct CodaFid *dirfid, 48 + int venus_remove(struct super_block *sb, struct CodaFid *dirfid, 68 49 const char *name, int length); 69 - int venus_readlink(struct super_block *sb, struct CodaFid *fid, 50 + int venus_readlink(struct super_block *sb, struct CodaFid *fid, 70 51 char *buffer, int *length); 71 - int venus_rename(struct super_block *, struct CodaFid *new_fid, 72 - struct CodaFid *old_fid, size_t old_length, 73 - size_t new_length, const char *old_name, 52 + int venus_rename(struct super_block *sb, struct CodaFid *new_fid, 53 + struct CodaFid *old_fid, size_t old_length, 54 + size_t new_length, const char *old_name, 74 55 const char *new_name); 75 - int venus_link(struct super_block *sb, struct CodaFid *fid, 56 + int venus_link(struct super_block *sb, struct CodaFid *fid, 76 57 struct CodaFid *dirfid, const char *name, int len ); 77 58 int venus_symlink(struct super_block *sb, struct CodaFid *fid, 78 59 const char *name, int len, const char *symname, int symlen); 79 60 int venus_access(struct super_block *sb, struct CodaFid *fid, int mask); 80 61 int venus_pioctl(struct super_block *sb, struct CodaFid *fid, 81 62 unsigned int cmd, struct PioctlData *data); 82 - int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out); 63 + int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out, 64 + size_t nbytes); 83 65 int venus_fsync(struct super_block *sb, struct CodaFid *fid); 84 66 int venus_statfs(struct dentry *dentry, struct kstatfs *sfs); 67 + int venus_access_intent(struct super_block *sb, struct CodaFid *fid, 68 + bool *access_intent_supported, 69 + size_t count, loff_t ppos, int type); 85 70 86 71 /* 87 72 * Statistics
+1 -2
include/linux/compat.h
··· 138 138 compat_sigset_word sig[_COMPAT_NSIG_WORDS]; 139 139 } compat_sigset_t; 140 140 141 - int set_compat_user_sigmask(const compat_sigset_t __user *usigmask, 142 - sigset_t *set, sigset_t *oldset, 141 + int set_compat_user_sigmask(const compat_sigset_t __user *umask, 143 142 size_t sigsetsize); 144 143 145 144 struct compat_sigaction {
+1
include/linux/io.h
··· 33 33 34 34 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP 35 35 void __init ioremap_huge_init(void); 36 + int arch_ioremap_p4d_supported(void); 36 37 int arch_ioremap_pud_supported(void); 37 38 int arch_ioremap_pmd_supported(void); 38 39 #else
+2
include/linux/kernel.h
··· 88 88 */ 89 89 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 90 90 91 + #define typeof_member(T, m) typeof(((T*)0)->m) 92 + 91 93 #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP 92 94 93 95 #define DIV_ROUND_DOWN_ULL(ll, d) \
+19
include/linux/kprobes.h
··· 458 458 } 459 459 #endif 460 460 461 + /* Returns true if kprobes handled the fault */ 462 + static nokprobe_inline bool kprobe_page_fault(struct pt_regs *regs, 463 + unsigned int trap) 464 + { 465 + if (!kprobes_built_in()) 466 + return false; 467 + if (user_mode(regs)) 468 + return false; 469 + /* 470 + * To be potentially processing a kprobe fault and to be allowed 471 + * to call kprobe_running(), we have to be non-preemptible. 472 + */ 473 + if (preemptible()) 474 + return false; 475 + if (!kprobe_running()) 476 + return false; 477 + return kprobe_fault_handler(regs, trap); 478 + } 479 + 461 480 #endif /* _LINUX_KPROBES_H */
+9 -9
include/linux/lz4.h
··· 278 278 * @compressedSize: is the precise full size of the compressed block 279 279 * @maxDecompressedSize: is the size of 'dest' buffer 280 280 * 281 - * Decompresses data fom 'source' into 'dest'. 281 + * Decompresses data from 'source' into 'dest'. 282 282 * If the source stream is detected malformed, the function will 283 283 * stop decoding and return a negative result. 284 284 * This function is protected against buffer overflow exploits, ··· 522 522 const char *dictionary, int dictSize); 523 523 524 524 /** 525 - * LZ4_decompress_fast_continue() - Decompress blocks in streaming mode 525 + * LZ4_decompress_safe_continue() - Decompress blocks in streaming mode 526 526 * @LZ4_streamDecode: the 'LZ4_streamDecode_t' structure 527 527 * @source: source address of the compressed data 528 528 * @dest: output buffer address of the uncompressed data ··· 530 530 * @compressedSize: is the precise full size of the compressed block 531 531 * @maxDecompressedSize: is the size of 'dest' buffer 532 532 * 533 - * These decoding function allows decompression of multiple blocks 533 + * This decoding function allows decompression of multiple blocks 534 534 * in "streaming" mode. 535 535 * Previously decoded blocks *must* remain available at the memory position 536 536 * where they were decoded (up to 64 KB) ··· 569 569 * which must be already allocated with 'originalSize' bytes 570 570 * @originalSize: is the original and therefore uncompressed size 571 571 * 572 - * These decoding function allows decompression of multiple blocks 572 + * This decoding function allows decompression of multiple blocks 573 573 * in "streaming" mode. 574 574 * Previously decoded blocks *must* remain available at the memory position 575 575 * where they were decoded (up to 64 KB) ··· 610 610 * @dictStart: pointer to the start of the dictionary in memory 611 611 * @dictSize: size of dictionary 612 612 * 613 - * These decoding function works the same as 613 + * This decoding function works the same as 614 614 * a combination of LZ4_setStreamDecode() followed by 615 615 * LZ4_decompress_safe_continue() 616 - * It is stand-alone, and don'tn eed a LZ4_streamDecode_t structure. 616 + * It is stand-alone, and doesn't need an LZ4_streamDecode_t structure. 617 617 * 618 618 * Return: number of bytes decompressed into destination buffer 619 619 * (necessarily <= maxDecompressedSize) ··· 633 633 * @dictStart: pointer to the start of the dictionary in memory 634 634 * @dictSize: size of dictionary 635 635 * 636 - * These decoding function works the same as 636 + * This decoding function works the same as 637 637 * a combination of LZ4_setStreamDecode() followed by 638 - * LZ4_decompress_safe_continue() 639 - * It is stand-alone, and don'tn eed a LZ4_streamDecode_t structure. 638 + * LZ4_decompress_fast_continue() 639 + * It is stand-alone, and doesn't need an LZ4_streamDecode_t structure. 640 640 * 641 641 * Return: number of bytes decompressed into destination buffer 642 642 * (necessarily <= maxDecompressedSize)
+6 -2
include/linux/memory_hotplug.h
··· 324 324 extern bool is_mem_section_removable(unsigned long pfn, unsigned long nr_pages); 325 325 extern void try_offline_node(int nid); 326 326 extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); 327 - extern void remove_memory(int nid, u64 start, u64 size); 327 + extern int remove_memory(int nid, u64 start, u64 size); 328 328 extern void __remove_memory(int nid, u64 start, u64 size); 329 329 330 330 #else ··· 341 341 return -EINVAL; 342 342 } 343 343 344 - static inline void remove_memory(int nid, u64 start, u64 size) {} 344 + static inline int remove_memory(int nid, u64 start, u64 size) 345 + { 346 + return -EBUSY; 347 + } 348 + 345 349 static inline void __remove_memory(int nid, u64 start, u64 size) {} 346 350 #endif /* CONFIG_MEMORY_HOTREMOVE */ 347 351
+21 -24
include/linux/mm.h
··· 547 547 struct mmu_gather; 548 548 struct inode; 549 549 550 - #if !defined(__HAVE_ARCH_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE) 550 + #if !defined(CONFIG_ARCH_HAS_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE) 551 551 static inline int pmd_devmap(pmd_t pmd) 552 552 { 553 553 return 0; ··· 956 956 return false; 957 957 } 958 958 959 - static inline bool is_device_private_page(const struct page *page) 960 - { 961 - return is_zone_device_page(page) && 962 - page->pgmap->type == MEMORY_DEVICE_PRIVATE; 963 - } 964 - 965 - #ifdef CONFIG_PCI_P2PDMA 966 - static inline bool is_pci_p2pdma_page(const struct page *page) 967 - { 968 - return is_zone_device_page(page) && 969 - page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA; 970 - } 971 - #else /* CONFIG_PCI_P2PDMA */ 972 - static inline bool is_pci_p2pdma_page(const struct page *page) 973 - { 974 - return false; 975 - } 976 - #endif /* CONFIG_PCI_P2PDMA */ 977 - 978 959 #else /* CONFIG_DEV_PAGEMAP_OPS */ 979 960 static inline bool put_devmap_managed_page(struct page *page) 980 961 { 981 962 return false; 982 963 } 964 + #endif /* CONFIG_DEV_PAGEMAP_OPS */ 983 965 984 966 static inline bool is_device_private_page(const struct page *page) 985 967 { 986 - return false; 968 + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && 969 + IS_ENABLED(CONFIG_DEVICE_PRIVATE) && 970 + is_zone_device_page(page) && 971 + page->pgmap->type == MEMORY_DEVICE_PRIVATE; 987 972 } 988 973 989 974 static inline bool is_pci_p2pdma_page(const struct page *page) 990 975 { 991 - return false; 976 + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && 977 + IS_ENABLED(CONFIG_PCI_P2PDMA) && 978 + is_zone_device_page(page) && 979 + page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA; 992 980 } 993 - #endif /* CONFIG_DEV_PAGEMAP_OPS */ 994 981 995 982 /* 127: arbitrary random number, small enough to assemble well */ 996 983 #define page_ref_zero_or_close_to_overflow(page) \ ··· 1543 1556 int get_user_pages_fast(unsigned long start, int nr_pages, 1544 1557 unsigned int gup_flags, struct page **pages); 1545 1558 1559 + int account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc); 1560 + int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc, 1561 + struct task_struct *task, bool bypass_rlim); 1562 + 1546 1563 /* Container for pinned pfns / pages */ 1547 1564 struct frame_vector { 1548 1565 unsigned int nr_allocated; /* Number of frames we have space for */ ··· 1754 1763 } 1755 1764 #endif 1756 1765 1757 - #ifndef __HAVE_ARCH_PTE_DEVMAP 1766 + #ifndef CONFIG_ARCH_HAS_PTE_DEVMAP 1758 1767 static inline int pte_devmap(pte_t pte) 1759 1768 { 1760 1769 return 0; ··· 2758 2767 #endif 2759 2768 2760 2769 const char * arch_vma_name(struct vm_area_struct *vma); 2770 + #ifdef CONFIG_MMU 2761 2771 void print_vma_addr(char *prefix, unsigned long rip); 2772 + #else 2773 + static inline void print_vma_addr(char *prefix, unsigned long rip) 2774 + { 2775 + } 2776 + #endif 2762 2777 2763 2778 void *sparse_buffer_alloc(unsigned long size); 2764 2779 struct page *sparse_mem_map_populate(unsigned long pnum, int nid,
+2 -2
include/linux/pfn_t.h
··· 97 97 #endif 98 98 #endif 99 99 100 - #ifdef __HAVE_ARCH_PTE_DEVMAP 100 + #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP 101 101 static inline bool pfn_t_devmap(pfn_t pfn) 102 102 { 103 103 const u64 flags = PFN_DEV|PFN_MAP; ··· 115 115 defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) 116 116 pud_t pud_mkdevmap(pud_t pud); 117 117 #endif 118 - #endif /* __HAVE_ARCH_PTE_DEVMAP */ 118 + #endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */ 119 119 120 120 #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL 121 121 static inline bool pfn_t_special(pfn_t pfn)
+3 -2
include/linux/pid.h
··· 4 4 5 5 #include <linux/rculist.h> 6 6 #include <linux/wait.h> 7 + #include <linux/refcount.h> 7 8 8 9 enum pid_type 9 10 { ··· 58 57 59 58 struct pid 60 59 { 61 - atomic_t count; 60 + refcount_t count; 62 61 unsigned int level; 63 62 /* lists of tasks that use this pid */ 64 63 struct hlist_head tasks[PIDTYPE_MAX]; ··· 75 74 static inline struct pid *get_pid(struct pid *pid) 76 75 { 77 76 if (pid) 78 - atomic_inc(&pid->count); 77 + refcount_inc(&pid->count); 79 78 return pid; 80 79 } 81 80
+1 -1
include/linux/poison.h
··· 21 21 * non-initialized list entries. 22 22 */ 23 23 #define LIST_POISON1 ((void *) 0x100 + POISON_POINTER_DELTA) 24 - #define LIST_POISON2 ((void *) 0x200 + POISON_POINTER_DELTA) 24 + #define LIST_POISON2 ((void *) 0x122 + POISON_POINTER_DELTA) 25 25 26 26 /********** include/linux/timer.h **********/ 27 27 /*
+46 -24
include/linux/rbtree.h
··· 32 32 struct rb_node *rb_node; 33 33 }; 34 34 35 - /* 36 - * Leftmost-cached rbtrees. 37 - * 38 - * We do not cache the rightmost node based on footprint 39 - * size vs number of potential users that could benefit 40 - * from O(1) rb_last(). Just not worth it, users that want 41 - * this feature can always implement the logic explicitly. 42 - * Furthermore, users that want to cache both pointers may 43 - * find it a bit asymmetric, but that's ok. 44 - */ 45 - struct rb_root_cached { 46 - struct rb_root rb_root; 47 - struct rb_node *rb_leftmost; 48 - }; 49 - 50 35 #define rb_parent(r) ((struct rb_node *)((r)->__rb_parent_color & ~3)) 51 36 52 37 #define RB_ROOT (struct rb_root) { NULL, } 53 - #define RB_ROOT_CACHED (struct rb_root_cached) { {NULL, }, NULL } 54 38 #define rb_entry(ptr, type, member) container_of(ptr, type, member) 55 39 56 40 #define RB_EMPTY_ROOT(root) (READ_ONCE((root)->rb_node) == NULL) ··· 56 72 extern struct rb_node *rb_first(const struct rb_root *); 57 73 extern struct rb_node *rb_last(const struct rb_root *); 58 74 59 - extern void rb_insert_color_cached(struct rb_node *, 60 - struct rb_root_cached *, bool); 61 - extern void rb_erase_cached(struct rb_node *node, struct rb_root_cached *); 62 - /* Same as rb_first(), but O(1) */ 63 - #define rb_first_cached(root) (root)->rb_leftmost 64 - 65 75 /* Postorder iteration - always visit the parent after its children */ 66 76 extern struct rb_node *rb_first_postorder(const struct rb_root *); 67 77 extern struct rb_node *rb_next_postorder(const struct rb_node *); ··· 65 87 struct rb_root *root); 66 88 extern void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new, 67 89 struct rb_root *root); 68 - extern void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new, 69 - struct rb_root_cached *root); 70 90 71 91 static inline void rb_link_node(struct rb_node *node, struct rb_node *parent, 72 92 struct rb_node **rb_link) ··· 111 135 pos && ({ n = rb_entry_safe(rb_next_postorder(&pos->field), \ 112 136 typeof(*pos), field); 1; }); \ 113 137 pos = n) 138 + 139 + /* 140 + * Leftmost-cached rbtrees. 141 + * 142 + * We do not cache the rightmost node based on footprint 143 + * size vs number of potential users that could benefit 144 + * from O(1) rb_last(). Just not worth it, users that want 145 + * this feature can always implement the logic explicitly. 146 + * Furthermore, users that want to cache both pointers may 147 + * find it a bit asymmetric, but that's ok. 148 + */ 149 + struct rb_root_cached { 150 + struct rb_root rb_root; 151 + struct rb_node *rb_leftmost; 152 + }; 153 + 154 + #define RB_ROOT_CACHED (struct rb_root_cached) { {NULL, }, NULL } 155 + 156 + /* Same as rb_first(), but O(1) */ 157 + #define rb_first_cached(root) (root)->rb_leftmost 158 + 159 + static inline void rb_insert_color_cached(struct rb_node *node, 160 + struct rb_root_cached *root, 161 + bool leftmost) 162 + { 163 + if (leftmost) 164 + root->rb_leftmost = node; 165 + rb_insert_color(node, &root->rb_root); 166 + } 167 + 168 + static inline void rb_erase_cached(struct rb_node *node, 169 + struct rb_root_cached *root) 170 + { 171 + if (root->rb_leftmost == node) 172 + root->rb_leftmost = rb_next(node); 173 + rb_erase(node, &root->rb_root); 174 + } 175 + 176 + static inline void rb_replace_node_cached(struct rb_node *victim, 177 + struct rb_node *new, 178 + struct rb_root_cached *root) 179 + { 180 + if (root->rb_leftmost == victim) 181 + root->rb_leftmost = new; 182 + rb_replace_node(victim, new, &root->rb_root); 183 + } 114 184 115 185 #endif /* _LINUX_RBTREE_H */
+10 -17
include/linux/rbtree_augmented.h
··· 30 30 void (*rotate)(struct rb_node *old, struct rb_node *new); 31 31 }; 32 32 33 - extern void __rb_insert_augmented(struct rb_node *node, 34 - struct rb_root *root, 35 - bool newleft, struct rb_node **leftmost, 33 + extern void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, 36 34 void (*augment_rotate)(struct rb_node *old, struct rb_node *new)); 35 + 37 36 /* 38 37 * Fixup the rbtree and update the augmented information when rebalancing. 39 38 * ··· 47 48 rb_insert_augmented(struct rb_node *node, struct rb_root *root, 48 49 const struct rb_augment_callbacks *augment) 49 50 { 50 - __rb_insert_augmented(node, root, false, NULL, augment->rotate); 51 + __rb_insert_augmented(node, root, augment->rotate); 51 52 } 52 53 53 54 static inline void ··· 55 56 struct rb_root_cached *root, bool newleft, 56 57 const struct rb_augment_callbacks *augment) 57 58 { 58 - __rb_insert_augmented(node, &root->rb_root, 59 - newleft, &root->rb_leftmost, augment->rotate); 59 + if (newleft) 60 + root->rb_leftmost = node; 61 + rb_insert_augmented(node, &root->rb_root, augment); 60 62 } 61 63 62 64 #define RB_DECLARE_CALLBACKS(rbstatic, rbname, rbstruct, rbfield, \ ··· 150 150 151 151 static __always_inline struct rb_node * 152 152 __rb_erase_augmented(struct rb_node *node, struct rb_root *root, 153 - struct rb_node **leftmost, 154 153 const struct rb_augment_callbacks *augment) 155 154 { 156 155 struct rb_node *child = node->rb_right; 157 156 struct rb_node *tmp = node->rb_left; 158 157 struct rb_node *parent, *rebalance; 159 158 unsigned long pc; 160 - 161 - if (leftmost && node == *leftmost) 162 - *leftmost = rb_next(node); 163 159 164 160 if (!tmp) { 165 161 /* ··· 256 260 rb_erase_augmented(struct rb_node *node, struct rb_root *root, 257 261 const struct rb_augment_callbacks *augment) 258 262 { 259 - struct rb_node *rebalance = __rb_erase_augmented(node, root, 260 - NULL, augment); 263 + struct rb_node *rebalance = __rb_erase_augmented(node, root, augment); 261 264 if (rebalance) 262 265 __rb_erase_color(rebalance, root, augment->rotate); 263 266 } ··· 265 270 rb_erase_augmented_cached(struct rb_node *node, struct rb_root_cached *root, 266 271 const struct rb_augment_callbacks *augment) 267 272 { 268 - struct rb_node *rebalance = __rb_erase_augmented(node, &root->rb_root, 269 - &root->rb_leftmost, 270 - augment); 271 - if (rebalance) 272 - __rb_erase_color(rebalance, &root->rb_root, augment->rotate); 273 + if (root->rb_leftmost == node) 274 + root->rb_leftmost = rb_next(node); 275 + rb_erase_augmented(node, &root->rb_root, augment); 273 276 } 274 277 275 278 #endif /* _LINUX_RBTREE_AUGMENTED_H */
+12 -4
include/linux/sched/signal.h
··· 15 15 */ 16 16 17 17 struct sighand_struct { 18 - refcount_t count; 19 - struct k_sigaction action[_NSIG]; 20 18 spinlock_t siglock; 19 + refcount_t count; 21 20 wait_queue_head_t signalfd_wqh; 21 + struct k_sigaction action[_NSIG]; 22 22 }; 23 23 24 24 /* ··· 420 420 static inline void set_restore_sigmask(void) 421 421 { 422 422 set_thread_flag(TIF_RESTORE_SIGMASK); 423 - WARN_ON(!test_thread_flag(TIF_SIGPENDING)); 424 423 } 425 424 426 425 static inline void clear_tsk_restore_sigmask(struct task_struct *task) ··· 450 451 static inline void set_restore_sigmask(void) 451 452 { 452 453 current->restore_sigmask = true; 453 - WARN_ON(!test_thread_flag(TIF_SIGPENDING)); 454 454 } 455 455 static inline void clear_tsk_restore_sigmask(struct task_struct *task) 456 456 { ··· 480 482 { 481 483 if (test_and_clear_restore_sigmask()) 482 484 __set_current_blocked(&current->saved_sigmask); 485 + } 486 + 487 + extern int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize); 488 + 489 + static inline void restore_saved_sigmask_unless(bool interrupted) 490 + { 491 + if (interrupted) 492 + WARN_ON(!test_thread_flag(TIF_SIGPENDING)); 493 + else 494 + restore_saved_sigmask(); 483 495 } 484 496 485 497 static inline sigset_t *sigmask_to_save(void)
-4
include/linux/signal.h
··· 273 273 struct task_struct *p, enum pid_type type); 274 274 extern int __group_send_sig_info(int, struct kernel_siginfo *, struct task_struct *); 275 275 extern int sigprocmask(int, sigset_t *, sigset_t *); 276 - extern int set_user_sigmask(const sigset_t __user *usigmask, sigset_t *set, 277 - sigset_t *oldset, size_t sigsetsize); 278 - extern void restore_user_sigmask(const void __user *usigmask, 279 - sigset_t *sigsaved, bool interrupted); 280 276 extern void set_current_blocked(sigset_t *); 281 277 extern void __set_current_blocked(const sigset_t *); 282 278 extern int show_unhandled_signals;
+3 -2
include/linux/swapops.h
··· 6 6 #include <linux/bug.h> 7 7 #include <linux/mm_types.h> 8 8 9 + #ifdef CONFIG_MMU 10 + 9 11 /* 10 12 * swapcache pages are stored in the swapper_space radix tree. We want to 11 13 * get good packing density in that tree, so the index should be dense in ··· 52 50 return entry.val & SWP_OFFSET_MASK; 53 51 } 54 52 55 - #ifdef CONFIG_MMU 56 53 /* check whether a pte points to a swap entry */ 57 54 static inline int is_swap_pte(pte_t pte) 58 55 { 59 56 return !pte_none(pte) && !pte_present(pte); 60 57 } 61 - #endif 62 58 63 59 /* 64 60 * Convert the arch-dependent pte representation of a swp_entry_t into an ··· 360 360 } 361 361 #endif 362 362 363 + #endif /* CONFIG_MMU */ 363 364 #endif /* _LINUX_SWAPOPS_H */
+6 -3
include/linux/tracehook.h
··· 54 54 /* 55 55 * ptrace report for syscall entry and exit looks identical. 56 56 */ 57 - static inline int ptrace_report_syscall(struct pt_regs *regs) 57 + static inline int ptrace_report_syscall(struct pt_regs *regs, 58 + unsigned long message) 58 59 { 59 60 int ptrace = current->ptrace; 60 61 61 62 if (!(ptrace & PT_PTRACED)) 62 63 return 0; 63 64 65 + current->ptrace_message = message; 64 66 ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); 65 67 66 68 /* ··· 75 73 current->exit_code = 0; 76 74 } 77 75 76 + current->ptrace_message = 0; 78 77 return fatal_signal_pending(current); 79 78 } 80 79 ··· 101 98 static inline __must_check int tracehook_report_syscall_entry( 102 99 struct pt_regs *regs) 103 100 { 104 - return ptrace_report_syscall(regs); 101 + return ptrace_report_syscall(regs, PTRACE_EVENTMSG_SYSCALL_ENTRY); 105 102 } 106 103 107 104 /** ··· 126 123 if (step) 127 124 user_single_step_report(regs); 128 125 else 129 - ptrace_report_syscall(regs); 126 + ptrace_report_syscall(regs, PTRACE_EVENTMSG_SYSCALL_EXIT); 130 127 } 131 128 132 129 /**
+9 -6
include/uapi/asm-generic/mman-common.h
··· 19 19 #define MAP_TYPE 0x0f /* Mask for type of mapping */ 20 20 #define MAP_FIXED 0x10 /* Interpret addr exactly */ 21 21 #define MAP_ANONYMOUS 0x20 /* don't use a file */ 22 - #ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED 23 - # define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be uninitialized */ 24 - #else 25 - # define MAP_UNINITIALIZED 0x0 /* Don't support this flag */ 26 - #endif 27 22 28 - /* 0x0100 - 0x80000 flags are defined in asm-generic/mman.h */ 23 + /* 0x0100 - 0x4000 flags are defined in asm-generic/mman.h */ 24 + #define MAP_POPULATE 0x008000 /* populate (prefault) pagetables */ 25 + #define MAP_NONBLOCK 0x010000 /* do not block on IO */ 26 + #define MAP_STACK 0x020000 /* give out an address that is best suited for process/thread stacks */ 27 + #define MAP_HUGETLB 0x040000 /* create a huge page mapping */ 28 + #define MAP_SYNC 0x080000 /* perform synchronous page faults for the mapping */ 29 29 #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ 30 + 31 + #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be 32 + * uninitialized */ 30 33 31 34 /* 32 35 * Flags for mlock
+4 -6
include/uapi/asm-generic/mman.h
··· 9 9 #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ 10 10 #define MAP_LOCKED 0x2000 /* pages are locked */ 11 11 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 12 - #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 13 - #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 14 - #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 15 - #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 16 - #define MAP_SYNC 0x80000 /* perform synchronous page faults for the mapping */ 17 12 18 - /* Bits [26:31] are reserved, see mman-common.h for MAP_HUGETLB usage */ 13 + /* 14 + * Bits [26:31] are reserved, see asm-generic/hugetlb_encode.h 15 + * for MAP_HUGETLB usage 16 + */ 19 17 20 18 #define MCL_CURRENT 1 /* lock all current mappings */ 21 19 #define MCL_FUTURE 2 /* lock all future mappings */
+38 -18
include/uapi/linux/coda.h
··· 86 86 87 87 #define inline 88 88 89 - struct timespec { 90 - long ts_sec; 91 - long ts_nsec; 92 - }; 93 89 #else /* DJGPP but not KERNEL */ 94 90 #include <sys/time.h> 95 91 typedef unsigned long long u_quad_t; ··· 104 108 #endif /* __KERNEL__ */ 105 109 #else 106 110 #define cdev_t dev_t 107 - #endif 108 - 109 - #ifdef __CYGWIN32__ 110 - struct timespec { 111 - time_t tv_sec; /* seconds */ 112 - long tv_nsec; /* nanoseconds */ 113 - }; 114 111 #endif 115 112 116 113 #ifndef __BIT_TYPES_DEFINED__ ··· 200 211 */ 201 212 enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD }; 202 213 214 + struct coda_timespec { 215 + int64_t tv_sec; /* seconds */ 216 + long tv_nsec; /* nanoseconds */ 217 + }; 218 + 203 219 struct coda_vattr { 204 220 long va_type; /* vnode type (for create) */ 205 221 u_short va_mode; /* files access mode and type */ ··· 214 220 long va_fileid; /* file id */ 215 221 u_quad_t va_size; /* file size in bytes */ 216 222 long va_blocksize; /* blocksize preferred for i/o */ 217 - struct timespec va_atime; /* time of last access */ 218 - struct timespec va_mtime; /* time of last modification */ 219 - struct timespec va_ctime; /* time file changed */ 223 + struct coda_timespec va_atime; /* time of last access */ 224 + struct coda_timespec va_mtime; /* time of last modification */ 225 + struct coda_timespec va_ctime; /* time file changed */ 220 226 u_long va_gen; /* generation number of file */ 221 227 u_long va_flags; /* flags defined for file */ 222 228 cdev_t va_rdev; /* device special file represents */ ··· 271 277 #define CODA_STATFS 34 272 278 #define CODA_STORE 35 273 279 #define CODA_RELEASE 36 274 - #define CODA_NCALLS 37 280 + #define CODA_ACCESS_INTENT 37 281 + #define CODA_NCALLS 38 275 282 276 283 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID) 277 284 ··· 282 287 283 288 #define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t) 284 289 285 - #define CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */ 290 + // CODA_KERNEL_VERSION 0 /* don't care about kernel version number */ 291 + // CODA_KERNEL_VERSION 1 /* The old venus 4.6 compatible interface */ 292 + // CODA_KERNEL_VERSION 2 /* venus_lookup gets an extra parameter */ 293 + // CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */ 294 + // CODA_KERNEL_VERSION 4 /* 64-bit timespec */ 295 + #define CODA_KERNEL_VERSION 5 /* access intent support */ 286 296 287 297 /* 288 298 * Venus <-> Coda RPC arguments ··· 295 295 struct coda_in_hdr { 296 296 u_int32_t opcode; 297 297 u_int32_t unique; /* Keep multiple outstanding msgs distinct */ 298 - pid_t pid; 299 - pid_t pgid; 298 + __kernel_pid_t pid; 299 + __kernel_pid_t pgid; 300 300 vuid_t uid; 301 301 }; 302 302 ··· 642 642 struct coda_statfs stat; 643 643 }; 644 644 645 + #define CODA_ACCESS_TYPE_READ 1 646 + #define CODA_ACCESS_TYPE_WRITE 2 647 + #define CODA_ACCESS_TYPE_MMAP 3 648 + #define CODA_ACCESS_TYPE_READ_FINISH 4 649 + #define CODA_ACCESS_TYPE_WRITE_FINISH 5 650 + 651 + /* coda_access_intent: NO_OUT */ 652 + struct coda_access_intent_in { 653 + struct coda_in_hdr ih; 654 + struct CodaFid VFid; 655 + int count; 656 + int pos; 657 + int type; 658 + }; 659 + 660 + struct coda_access_intent_out { 661 + struct coda_out_hdr out; 662 + }; 663 + 645 664 /* 646 665 * Occasionally, we don't cache the fid returned by CODA_LOOKUP. 647 666 * For instance, if the fid is inconsistent. ··· 692 673 struct coda_open_by_fd_in coda_open_by_fd; 693 674 struct coda_open_by_path_in coda_open_by_path; 694 675 struct coda_statfs_in coda_statfs; 676 + struct coda_access_intent_in coda_access_intent; 695 677 }; 696 678 697 679 union outputArgs {
-28
include/uapi/linux/coda_psdev.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - #ifndef _UAPI__CODA_PSDEV_H 3 - #define _UAPI__CODA_PSDEV_H 4 - 5 - #include <linux/magic.h> 6 - 7 - #define CODA_PSDEV_MAJOR 67 8 - #define MAX_CODADEVS 5 /* how many do we allow */ 9 - 10 - 11 - /* messages between coda filesystem in kernel and Venus */ 12 - struct upc_req { 13 - struct list_head uc_chain; 14 - caddr_t uc_data; 15 - u_short uc_flags; 16 - u_short uc_inSize; /* Size is at most 5000 bytes */ 17 - u_short uc_outSize; 18 - u_short uc_opcode; /* copied from data to save lookup */ 19 - int uc_unique; 20 - wait_queue_head_t uc_sleep; /* process' wait queue */ 21 - }; 22 - 23 - #define CODA_REQ_ASYNC 0x1 24 - #define CODA_REQ_READ 0x2 25 - #define CODA_REQ_WRITE 0x4 26 - #define CODA_REQ_ABORT 0x8 27 - 28 - #endif /* _UAPI__CODA_PSDEV_H */
+35
include/uapi/linux/ptrace.h
··· 73 73 __u64 flags; /* Output: filter's flags */ 74 74 }; 75 75 76 + #define PTRACE_GET_SYSCALL_INFO 0x420e 77 + #define PTRACE_SYSCALL_INFO_NONE 0 78 + #define PTRACE_SYSCALL_INFO_ENTRY 1 79 + #define PTRACE_SYSCALL_INFO_EXIT 2 80 + #define PTRACE_SYSCALL_INFO_SECCOMP 3 81 + 82 + struct ptrace_syscall_info { 83 + __u8 op; /* PTRACE_SYSCALL_INFO_* */ 84 + __u32 arch __attribute__((__aligned__(sizeof(__u32)))); 85 + __u64 instruction_pointer; 86 + __u64 stack_pointer; 87 + union { 88 + struct { 89 + __u64 nr; 90 + __u64 args[6]; 91 + } entry; 92 + struct { 93 + __s64 rval; 94 + __u8 is_error; 95 + } exit; 96 + struct { 97 + __u64 nr; 98 + __u64 args[6]; 99 + __u32 ret_data; 100 + } seccomp; 101 + }; 102 + }; 103 + 104 + /* 105 + * These values are stored in task->ptrace_message 106 + * by tracehook_report_syscall_* to describe the current syscall-stop. 107 + */ 108 + #define PTRACE_EVENTMSG_SYSCALL_ENTRY 1 109 + #define PTRACE_EVENTMSG_SYSCALL_EXIT 2 110 + 76 111 /* Read signals from a shared (process wide) queue */ 77 112 #define PTRACE_PEEKSIGINFO_SHARED (1 << 0) 78 113
+2 -2
init/Kconfig
··· 1827 1827 help 1828 1828 Many kernel heap attacks try to target slab cache metadata and 1829 1829 other infrastructure. This options makes minor performance 1830 - sacrifies to harden the kernel slab allocator against common 1830 + sacrifices to harden the kernel slab allocator against common 1831 1831 freelist exploit methods. 1832 1832 1833 1833 config SHUFFLE_PAGE_ALLOCATOR ··· 1859 1859 depends on SLUB && SMP 1860 1860 bool "SLUB per cpu partial cache" 1861 1861 help 1862 - Per cpu partial caches accellerate objects allocation and freeing 1862 + Per cpu partial caches accelerate objects allocation and freeing 1863 1863 that is local to a processor at the price of more indeterminism 1864 1864 in the latency of the free. On overflow these caches will be cleared 1865 1865 which requires the taking of locks that may cause latency spikes.
+10 -9
ipc/mqueue.c
··· 438 438 { 439 439 struct mqueue_inode_info *info; 440 440 struct user_struct *user; 441 - unsigned long mq_bytes, mq_treesize; 442 441 struct ipc_namespace *ipc_ns; 443 442 struct msg_msg *msg, *nmsg; 444 443 LIST_HEAD(tmp_msg); ··· 460 461 free_msg(msg); 461 462 } 462 463 463 - /* Total amount of bytes accounted for the mqueue */ 464 - mq_treesize = info->attr.mq_maxmsg * sizeof(struct msg_msg) + 465 - min_t(unsigned int, info->attr.mq_maxmsg, MQ_PRIO_MAX) * 466 - sizeof(struct posix_msg_tree_node); 467 - 468 - mq_bytes = mq_treesize + (info->attr.mq_maxmsg * 469 - info->attr.mq_msgsize); 470 - 471 464 user = info->user; 472 465 if (user) { 466 + unsigned long mq_bytes, mq_treesize; 467 + 468 + /* Total amount of bytes accounted for the mqueue */ 469 + mq_treesize = info->attr.mq_maxmsg * sizeof(struct msg_msg) + 470 + min_t(unsigned int, info->attr.mq_maxmsg, MQ_PRIO_MAX) * 471 + sizeof(struct posix_msg_tree_node); 472 + 473 + mq_bytes = mq_treesize + (info->attr.mq_maxmsg * 474 + info->attr.mq_msgsize); 475 + 473 476 spin_lock(&mq_lock); 474 477 user->mq_bytes -= mq_bytes; 475 478 /*
+4 -5
kernel/pid.c
··· 37 37 #include <linux/init_task.h> 38 38 #include <linux/syscalls.h> 39 39 #include <linux/proc_ns.h> 40 - #include <linux/proc_fs.h> 40 + #include <linux/refcount.h> 41 41 #include <linux/anon_inodes.h> 42 42 #include <linux/sched/signal.h> 43 43 #include <linux/sched/task.h> 44 44 #include <linux/idr.h> 45 45 46 46 struct pid init_struct_pid = { 47 - .count = ATOMIC_INIT(1), 47 + .count = REFCOUNT_INIT(1), 48 48 .tasks = { 49 49 { .first = NULL }, 50 50 { .first = NULL }, ··· 108 108 return; 109 109 110 110 ns = pid->numbers[pid->level].ns; 111 - if ((atomic_read(&pid->count) == 1) || 112 - atomic_dec_and_test(&pid->count)) { 111 + if (refcount_dec_and_test(&pid->count)) { 113 112 kmem_cache_free(ns->pid_cachep, pid); 114 113 put_pid_ns(ns); 115 114 } ··· 211 212 } 212 213 213 214 get_pid_ns(ns); 214 - atomic_set(&pid->count, 1); 215 + refcount_set(&pid->count, 1); 215 216 for (type = 0; type < PIDTYPE_MAX; ++type) 216 217 INIT_HLIST_HEAD(&pid->tasks[type]); 217 218
+100 -1
kernel/ptrace.c
··· 32 32 #include <linux/compat.h> 33 33 #include <linux/sched/signal.h> 34 34 35 + #include <asm/syscall.h> /* for syscall_get_* */ 36 + 35 37 /* 36 38 * Access another process' address space via ptrace. 37 39 * Source/target buffer must be kernel space, ··· 899 897 * to ensure no machine forgets it. 900 898 */ 901 899 EXPORT_SYMBOL_GPL(task_user_regset_view); 902 - #endif 900 + 901 + static unsigned long 902 + ptrace_get_syscall_info_entry(struct task_struct *child, struct pt_regs *regs, 903 + struct ptrace_syscall_info *info) 904 + { 905 + unsigned long args[ARRAY_SIZE(info->entry.args)]; 906 + int i; 907 + 908 + info->op = PTRACE_SYSCALL_INFO_ENTRY; 909 + info->entry.nr = syscall_get_nr(child, regs); 910 + syscall_get_arguments(child, regs, args); 911 + for (i = 0; i < ARRAY_SIZE(args); i++) 912 + info->entry.args[i] = args[i]; 913 + 914 + /* args is the last field in struct ptrace_syscall_info.entry */ 915 + return offsetofend(struct ptrace_syscall_info, entry.args); 916 + } 917 + 918 + static unsigned long 919 + ptrace_get_syscall_info_seccomp(struct task_struct *child, struct pt_regs *regs, 920 + struct ptrace_syscall_info *info) 921 + { 922 + /* 923 + * As struct ptrace_syscall_info.entry is currently a subset 924 + * of struct ptrace_syscall_info.seccomp, it makes sense to 925 + * initialize that subset using ptrace_get_syscall_info_entry(). 926 + * This can be reconsidered in the future if these structures 927 + * diverge significantly enough. 928 + */ 929 + ptrace_get_syscall_info_entry(child, regs, info); 930 + info->op = PTRACE_SYSCALL_INFO_SECCOMP; 931 + info->seccomp.ret_data = child->ptrace_message; 932 + 933 + /* ret_data is the last field in struct ptrace_syscall_info.seccomp */ 934 + return offsetofend(struct ptrace_syscall_info, seccomp.ret_data); 935 + } 936 + 937 + static unsigned long 938 + ptrace_get_syscall_info_exit(struct task_struct *child, struct pt_regs *regs, 939 + struct ptrace_syscall_info *info) 940 + { 941 + info->op = PTRACE_SYSCALL_INFO_EXIT; 942 + info->exit.rval = syscall_get_error(child, regs); 943 + info->exit.is_error = !!info->exit.rval; 944 + if (!info->exit.is_error) 945 + info->exit.rval = syscall_get_return_value(child, regs); 946 + 947 + /* is_error is the last field in struct ptrace_syscall_info.exit */ 948 + return offsetofend(struct ptrace_syscall_info, exit.is_error); 949 + } 950 + 951 + static int 952 + ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size, 953 + void __user *datavp) 954 + { 955 + struct pt_regs *regs = task_pt_regs(child); 956 + struct ptrace_syscall_info info = { 957 + .op = PTRACE_SYSCALL_INFO_NONE, 958 + .arch = syscall_get_arch(child), 959 + .instruction_pointer = instruction_pointer(regs), 960 + .stack_pointer = user_stack_pointer(regs), 961 + }; 962 + unsigned long actual_size = offsetof(struct ptrace_syscall_info, entry); 963 + unsigned long write_size; 964 + 965 + /* 966 + * This does not need lock_task_sighand() to access 967 + * child->last_siginfo because ptrace_freeze_traced() 968 + * called earlier by ptrace_check_attach() ensures that 969 + * the tracee cannot go away and clear its last_siginfo. 970 + */ 971 + switch (child->last_siginfo ? child->last_siginfo->si_code : 0) { 972 + case SIGTRAP | 0x80: 973 + switch (child->ptrace_message) { 974 + case PTRACE_EVENTMSG_SYSCALL_ENTRY: 975 + actual_size = ptrace_get_syscall_info_entry(child, regs, 976 + &info); 977 + break; 978 + case PTRACE_EVENTMSG_SYSCALL_EXIT: 979 + actual_size = ptrace_get_syscall_info_exit(child, regs, 980 + &info); 981 + break; 982 + } 983 + break; 984 + case SIGTRAP | (PTRACE_EVENT_SECCOMP << 8): 985 + actual_size = ptrace_get_syscall_info_seccomp(child, regs, 986 + &info); 987 + break; 988 + } 989 + 990 + write_size = min(actual_size, user_size); 991 + return copy_to_user(datavp, &info, write_size) ? -EFAULT : actual_size; 992 + } 993 + #endif /* CONFIG_HAVE_ARCH_TRACEHOOK */ 903 994 904 995 int ptrace_request(struct task_struct *child, long request, 905 996 unsigned long addr, unsigned long data) ··· 1209 1114 ret = __put_user(kiov.iov_len, &uiov->iov_len); 1210 1115 break; 1211 1116 } 1117 + 1118 + case PTRACE_GET_SYSCALL_INFO: 1119 + ret = ptrace_get_syscall_info(child, addr, datavp); 1120 + break; 1212 1121 #endif 1213 1122 1214 1123 case PTRACE_SECCOMP_GET_FILTER:
+19 -50
kernel/signal.c
··· 2951 2951 * 2952 2952 * This is useful for syscalls such as ppoll, pselect, io_pgetevents and 2953 2953 * epoll_pwait where a new sigmask is passed from userland for the syscalls. 2954 + * 2955 + * Note that it does set_restore_sigmask() in advance, so it must be always 2956 + * paired with restore_saved_sigmask_unless() before return from syscall. 2954 2957 */ 2955 - int set_user_sigmask(const sigset_t __user *usigmask, sigset_t *set, 2956 - sigset_t *oldset, size_t sigsetsize) 2958 + int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize) 2957 2959 { 2958 - if (!usigmask) 2959 - return 0; 2960 + sigset_t kmask; 2960 2961 2962 + if (!umask) 2963 + return 0; 2961 2964 if (sigsetsize != sizeof(sigset_t)) 2962 2965 return -EINVAL; 2963 - if (copy_from_user(set, usigmask, sizeof(sigset_t))) 2966 + if (copy_from_user(&kmask, umask, sizeof(sigset_t))) 2964 2967 return -EFAULT; 2965 2968 2966 - *oldset = current->blocked; 2967 - set_current_blocked(set); 2969 + set_restore_sigmask(); 2970 + current->saved_sigmask = current->blocked; 2971 + set_current_blocked(&kmask); 2968 2972 2969 2973 return 0; 2970 2974 } 2971 - EXPORT_SYMBOL(set_user_sigmask); 2972 2975 2973 2976 #ifdef CONFIG_COMPAT 2974 - int set_compat_user_sigmask(const compat_sigset_t __user *usigmask, 2975 - sigset_t *set, sigset_t *oldset, 2977 + int set_compat_user_sigmask(const compat_sigset_t __user *umask, 2976 2978 size_t sigsetsize) 2977 2979 { 2978 - if (!usigmask) 2979 - return 0; 2980 + sigset_t kmask; 2980 2981 2982 + if (!umask) 2983 + return 0; 2981 2984 if (sigsetsize != sizeof(compat_sigset_t)) 2982 2985 return -EINVAL; 2983 - if (get_compat_sigset(set, usigmask)) 2986 + if (get_compat_sigset(&kmask, umask)) 2984 2987 return -EFAULT; 2985 2988 2986 - *oldset = current->blocked; 2987 - set_current_blocked(set); 2989 + set_restore_sigmask(); 2990 + current->saved_sigmask = current->blocked; 2991 + set_current_blocked(&kmask); 2988 2992 2989 2993 return 0; 2990 2994 } 2991 - EXPORT_SYMBOL(set_compat_user_sigmask); 2992 2995 #endif 2993 - 2994 - /* 2995 - * restore_user_sigmask: 2996 - * usigmask: sigmask passed in from userland. 2997 - * sigsaved: saved sigmask when the syscall started and changed the sigmask to 2998 - * usigmask. 2999 - * 3000 - * This is useful for syscalls such as ppoll, pselect, io_pgetevents and 3001 - * epoll_pwait where a new sigmask is passed in from userland for the syscalls. 3002 - */ 3003 - void restore_user_sigmask(const void __user *usigmask, sigset_t *sigsaved, 3004 - bool interrupted) 3005 - { 3006 - 3007 - if (!usigmask) 3008 - return; 3009 - /* 3010 - * When signals are pending, do not restore them here. 3011 - * Restoring sigmask here can lead to delivering signals that the above 3012 - * syscalls are intended to block because of the sigmask passed in. 3013 - */ 3014 - if (interrupted) { 3015 - current->saved_sigmask = *sigsaved; 3016 - set_restore_sigmask(); 3017 - return; 3018 - } 3019 - 3020 - /* 3021 - * This is needed because the fast syscall return path does not restore 3022 - * saved_sigmask when signals are not pending. 3023 - */ 3024 - set_current_blocked(sigsaved); 3025 - } 3026 - EXPORT_SYMBOL(restore_user_sigmask); 3027 2996 3028 2997 /** 3029 2998 * sys_rt_sigprocmask - change the list of currently blocked signals
+9 -9
kernel/sysctl.c
··· 188 188 * enum sysctl_writes_mode - supported sysctl write modes 189 189 * 190 190 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value 191 - * to be written, and multiple writes on the same sysctl file descriptor 192 - * will rewrite the sysctl value, regardless of file position. No warning 193 - * is issued when the initial position is not 0. 191 + * to be written, and multiple writes on the same sysctl file descriptor 192 + * will rewrite the sysctl value, regardless of file position. No warning 193 + * is issued when the initial position is not 0. 194 194 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is 195 - * not 0. 195 + * not 0. 196 196 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at 197 - * file position 0 and the value must be fully contained in the buffer 198 - * sent to the write syscall. If dealing with strings respect the file 199 - * position, but restrict this to the max length of the buffer, anything 200 - * passed the max lenght will be ignored. Multiple writes will append 201 - * to the buffer. 197 + * file position 0 and the value must be fully contained in the buffer 198 + * sent to the write syscall. If dealing with strings respect the file 199 + * position, but restrict this to the max length of the buffer, anything 200 + * passed the max length will be ignored. Multiple writes will append 201 + * to the buffer. 202 202 * 203 203 * These write modes control how current file position affects the behavior of 204 204 * updating sysctl values through the proc interface on each write.
+8
lib/Kconfig.debug
··· 2076 2076 2077 2077 If unsure, say N. 2078 2078 2079 + config TEST_MEMINIT 2080 + tristate "Test heap/page initialization" 2081 + help 2082 + Test if the kernel is zero-initializing heap and page allocations. 2083 + This can be useful to test init_on_alloc and init_on_free features. 2084 + 2085 + If unsure, say N. 2086 + 2079 2087 endif # RUNTIME_TESTING_MENU 2080 2088 2081 2089 config MEMTEST
+1
lib/Makefile
··· 92 92 obj-$(CONFIG_TEST_OBJAGG) += test_objagg.o 93 93 obj-$(CONFIG_TEST_STACKINIT) += test_stackinit.o 94 94 obj-$(CONFIG_TEST_BLACKHOLE_DEV) += test_blackhole_dev.o 95 + obj-$(CONFIG_TEST_MEMINIT) += test_meminit.o 95 96 96 97 obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/ 97 98
+11
lib/ioremap.c
··· 30 30 void __init ioremap_huge_init(void) 31 31 { 32 32 if (!ioremap_huge_disabled) { 33 + if (arch_ioremap_p4d_supported()) 34 + ioremap_p4d_capable = 1; 33 35 if (arch_ioremap_pud_supported()) 34 36 ioremap_pud_capable = 1; 35 37 if (arch_ioremap_pmd_supported()) ··· 88 86 if ((end - addr) != PMD_SIZE) 89 87 return 0; 90 88 89 + if (!IS_ALIGNED(addr, PMD_SIZE)) 90 + return 0; 91 + 91 92 if (!IS_ALIGNED(phys_addr, PMD_SIZE)) 92 93 return 0; 93 94 ··· 131 126 if ((end - addr) != PUD_SIZE) 132 127 return 0; 133 128 129 + if (!IS_ALIGNED(addr, PUD_SIZE)) 130 + return 0; 131 + 134 132 if (!IS_ALIGNED(phys_addr, PUD_SIZE)) 135 133 return 0; 136 134 ··· 172 164 return 0; 173 165 174 166 if ((end - addr) != P4D_SIZE) 167 + return 0; 168 + 169 + if (!IS_ALIGNED(addr, P4D_SIZE)) 175 170 return 0; 176 171 177 172 if (!IS_ALIGNED(phys_addr, P4D_SIZE))
+8 -8
lib/mpi/longlong.h
··· 397 397 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ 398 398 __asm__ ("addl %5,%1\n" \ 399 399 "adcl %3,%0" \ 400 - : "=r" ((USItype)(sh)), \ 401 - "=&r" ((USItype)(sl)) \ 400 + : "=r" (sh), \ 401 + "=&r" (sl) \ 402 402 : "%0" ((USItype)(ah)), \ 403 403 "g" ((USItype)(bh)), \ 404 404 "%1" ((USItype)(al)), \ ··· 406 406 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ 407 407 __asm__ ("subl %5,%1\n" \ 408 408 "sbbl %3,%0" \ 409 - : "=r" ((USItype)(sh)), \ 410 - "=&r" ((USItype)(sl)) \ 409 + : "=r" (sh), \ 410 + "=&r" (sl) \ 411 411 : "0" ((USItype)(ah)), \ 412 412 "g" ((USItype)(bh)), \ 413 413 "1" ((USItype)(al)), \ 414 414 "g" ((USItype)(bl))) 415 415 #define umul_ppmm(w1, w0, u, v) \ 416 416 __asm__ ("mull %3" \ 417 - : "=a" ((USItype)(w0)), \ 418 - "=d" ((USItype)(w1)) \ 417 + : "=a" (w0), \ 418 + "=d" (w1) \ 419 419 : "%0" ((USItype)(u)), \ 420 420 "rm" ((USItype)(v))) 421 421 #define udiv_qrnnd(q, r, n1, n0, d) \ 422 422 __asm__ ("divl %4" \ 423 - : "=a" ((USItype)(q)), \ 424 - "=d" ((USItype)(r)) \ 423 + : "=a" (q), \ 424 + "=d" (r) \ 425 425 : "0" ((USItype)(n0)), \ 426 426 "1" ((USItype)(n1)), \ 427 427 "rm" ((USItype)(d)))
+3 -37
lib/rbtree.c
··· 83 83 84 84 static __always_inline void 85 85 __rb_insert(struct rb_node *node, struct rb_root *root, 86 - bool newleft, struct rb_node **leftmost, 87 86 void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 88 87 { 89 88 struct rb_node *parent = rb_red_parent(node), *gparent, *tmp; 90 - 91 - if (newleft) 92 - *leftmost = node; 93 89 94 90 while (true) { 95 91 /* ··· 433 437 434 438 void rb_insert_color(struct rb_node *node, struct rb_root *root) 435 439 { 436 - __rb_insert(node, root, false, NULL, dummy_rotate); 440 + __rb_insert(node, root, dummy_rotate); 437 441 } 438 442 EXPORT_SYMBOL(rb_insert_color); 439 443 440 444 void rb_erase(struct rb_node *node, struct rb_root *root) 441 445 { 442 446 struct rb_node *rebalance; 443 - rebalance = __rb_erase_augmented(node, root, 444 - NULL, &dummy_callbacks); 447 + rebalance = __rb_erase_augmented(node, root, &dummy_callbacks); 445 448 if (rebalance) 446 449 ____rb_erase_color(rebalance, root, dummy_rotate); 447 450 } 448 451 EXPORT_SYMBOL(rb_erase); 449 - 450 - void rb_insert_color_cached(struct rb_node *node, 451 - struct rb_root_cached *root, bool leftmost) 452 - { 453 - __rb_insert(node, &root->rb_root, leftmost, 454 - &root->rb_leftmost, dummy_rotate); 455 - } 456 - EXPORT_SYMBOL(rb_insert_color_cached); 457 - 458 - void rb_erase_cached(struct rb_node *node, struct rb_root_cached *root) 459 - { 460 - struct rb_node *rebalance; 461 - rebalance = __rb_erase_augmented(node, &root->rb_root, 462 - &root->rb_leftmost, &dummy_callbacks); 463 - if (rebalance) 464 - ____rb_erase_color(rebalance, &root->rb_root, dummy_rotate); 465 - } 466 - EXPORT_SYMBOL(rb_erase_cached); 467 452 468 453 /* 469 454 * Augmented rbtree manipulation functions. ··· 454 477 */ 455 478 456 479 void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, 457 - bool newleft, struct rb_node **leftmost, 458 480 void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 459 481 { 460 - __rb_insert(node, root, newleft, leftmost, augment_rotate); 482 + __rb_insert(node, root, augment_rotate); 461 483 } 462 484 EXPORT_SYMBOL(__rb_insert_augmented); 463 485 ··· 566 590 __rb_change_child(victim, new, parent, root); 567 591 } 568 592 EXPORT_SYMBOL(rb_replace_node); 569 - 570 - void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new, 571 - struct rb_root_cached *root) 572 - { 573 - rb_replace_node(victim, new, &root->rb_root); 574 - 575 - if (root->rb_leftmost == victim) 576 - root->rb_leftmost = new; 577 - } 578 - EXPORT_SYMBOL(rb_replace_node_cached); 579 593 580 594 void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new, 581 595 struct rb_root *root)
+10 -1
lib/string.c
··· 400 400 * strchr - Find the first occurrence of a character in a string 401 401 * @s: The string to be searched 402 402 * @c: The character to search for 403 + * 404 + * Note that the %NUL-terminator is considered part of the string, and can 405 + * be searched for. 403 406 */ 404 407 char *strchr(const char *s, int c) 405 408 { ··· 456 453 * @s: The string to be searched 457 454 * @count: The number of characters to be searched 458 455 * @c: The character to search for 456 + * 457 + * Note that the %NUL-terminator is considered part of the string, and can 458 + * be searched for. 459 459 */ 460 460 char *strnchr(const char *s, size_t count, int c) 461 461 { 462 - for (; count-- && *s != '\0'; ++s) 462 + while (count--) { 463 463 if (*s == (char)c) 464 464 return (char *)s; 465 + if (*s++ == '\0') 466 + break; 467 + } 465 468 return NULL; 466 469 } 467 470 EXPORT_SYMBOL(strnchr);
+43 -40
lib/string_helpers.c
··· 231 231 * @src: source buffer (escaped) 232 232 * @dst: destination buffer (unescaped) 233 233 * @size: size of the destination buffer (0 to unlimit) 234 - * @flags: combination of the flags (bitwise OR): 235 - * %UNESCAPE_SPACE: 236 - * '\f' - form feed 237 - * '\n' - new line 238 - * '\r' - carriage return 239 - * '\t' - horizontal tab 240 - * '\v' - vertical tab 241 - * %UNESCAPE_OCTAL: 242 - * '\NNN' - byte with octal value NNN (1 to 3 digits) 243 - * %UNESCAPE_HEX: 244 - * '\xHH' - byte with hexadecimal value HH (1 to 2 digits) 245 - * %UNESCAPE_SPECIAL: 246 - * '\"' - double quote 247 - * '\\' - backslash 248 - * '\a' - alert (BEL) 249 - * '\e' - escape 250 - * %UNESCAPE_ANY: 251 - * all previous together 234 + * @flags: combination of the flags. 252 235 * 253 236 * Description: 254 237 * The function unquotes characters in the given string. ··· 241 258 * 242 259 * Caller must provide valid source and destination pointers. Be aware that 243 260 * destination buffer will always be NULL-terminated. Source string must be 244 - * NULL-terminated as well. 261 + * NULL-terminated as well. The supported flags are:: 262 + * 263 + * UNESCAPE_SPACE: 264 + * '\f' - form feed 265 + * '\n' - new line 266 + * '\r' - carriage return 267 + * '\t' - horizontal tab 268 + * '\v' - vertical tab 269 + * UNESCAPE_OCTAL: 270 + * '\NNN' - byte with octal value NNN (1 to 3 digits) 271 + * UNESCAPE_HEX: 272 + * '\xHH' - byte with hexadecimal value HH (1 to 2 digits) 273 + * UNESCAPE_SPECIAL: 274 + * '\"' - double quote 275 + * '\\' - backslash 276 + * '\a' - alert (BEL) 277 + * '\e' - escape 278 + * UNESCAPE_ANY: 279 + * all previous together 245 280 * 246 281 * Return: 247 282 * The amount of the characters processed to the destination buffer excluding ··· 442 441 * @isz: source buffer size 443 442 * @dst: destination buffer (escaped) 444 443 * @osz: destination buffer size 445 - * @flags: combination of the flags (bitwise OR): 444 + * @flags: combination of the flags 445 + * @only: NULL-terminated string containing characters used to limit 446 + * the selected escape class. If characters are included in @only 447 + * that would not normally be escaped by the classes selected 448 + * in @flags, they will be copied to @dst unescaped. 449 + * 450 + * Description: 451 + * The process of escaping byte buffer includes several parts. They are applied 452 + * in the following sequence. 453 + * 454 + * 1. The character is matched to the printable class, if asked, and in 455 + * case of match it passes through to the output. 456 + * 2. The character is not matched to the one from @only string and thus 457 + * must go as-is to the output. 458 + * 3. The character is checked if it falls into the class given by @flags. 459 + * %ESCAPE_OCTAL and %ESCAPE_HEX are going last since they cover any 460 + * character. Note that they actually can't go together, otherwise 461 + * %ESCAPE_HEX will be ignored. 462 + * 463 + * Caller must provide valid source and destination pointers. Be aware that 464 + * destination buffer will not be NULL-terminated, thus caller have to append 465 + * it if needs. The supported flags are:: 466 + * 446 467 * %ESCAPE_SPACE: (special white space, not space itself) 447 468 * '\f' - form feed 448 469 * '\n' - new line ··· 487 464 * all previous together 488 465 * %ESCAPE_HEX: 489 466 * '\xHH' - byte with hexadecimal value HH (2 digits) 490 - * @only: NULL-terminated string containing characters used to limit 491 - * the selected escape class. If characters are included in @only 492 - * that would not normally be escaped by the classes selected 493 - * in @flags, they will be copied to @dst unescaped. 494 - * 495 - * Description: 496 - * The process of escaping byte buffer includes several parts. They are applied 497 - * in the following sequence. 498 - * 1. The character is matched to the printable class, if asked, and in 499 - * case of match it passes through to the output. 500 - * 2. The character is not matched to the one from @only string and thus 501 - * must go as-is to the output. 502 - * 3. The character is checked if it falls into the class given by @flags. 503 - * %ESCAPE_OCTAL and %ESCAPE_HEX are going last since they cover any 504 - * character. Note that they actually can't go together, otherwise 505 - * %ESCAPE_HEX will be ignored. 506 - * 507 - * Caller must provide valid source and destination pointers. Be aware that 508 - * destination buffer will not be NULL-terminated, thus caller have to append 509 - * it if needs. 510 467 * 511 468 * Return: 512 469 * The total size of the escaped output that would be generated for
+364
lib/test_meminit.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Test cases for SL[AOU]B/page initialization at alloc/free time. 4 + */ 5 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 6 + 7 + #include <linux/init.h> 8 + #include <linux/kernel.h> 9 + #include <linux/mm.h> 10 + #include <linux/module.h> 11 + #include <linux/slab.h> 12 + #include <linux/string.h> 13 + #include <linux/vmalloc.h> 14 + 15 + #define GARBAGE_INT (0x09A7BA9E) 16 + #define GARBAGE_BYTE (0x9E) 17 + 18 + #define REPORT_FAILURES_IN_FN() \ 19 + do { \ 20 + if (failures) \ 21 + pr_info("%s failed %d out of %d times\n", \ 22 + __func__, failures, num_tests); \ 23 + else \ 24 + pr_info("all %d tests in %s passed\n", \ 25 + num_tests, __func__); \ 26 + } while (0) 27 + 28 + /* Calculate the number of uninitialized bytes in the buffer. */ 29 + static int __init count_nonzero_bytes(void *ptr, size_t size) 30 + { 31 + int i, ret = 0; 32 + unsigned char *p = (unsigned char *)ptr; 33 + 34 + for (i = 0; i < size; i++) 35 + if (p[i]) 36 + ret++; 37 + return ret; 38 + } 39 + 40 + /* Fill a buffer with garbage, skipping |skip| first bytes. */ 41 + static void __init fill_with_garbage_skip(void *ptr, int size, size_t skip) 42 + { 43 + unsigned int *p = (unsigned int *)((char *)ptr + skip); 44 + int i = 0; 45 + 46 + WARN_ON(skip > size); 47 + size -= skip; 48 + 49 + while (size >= sizeof(*p)) { 50 + p[i] = GARBAGE_INT; 51 + i++; 52 + size -= sizeof(*p); 53 + } 54 + if (size) 55 + memset(&p[i], GARBAGE_BYTE, size); 56 + } 57 + 58 + static void __init fill_with_garbage(void *ptr, size_t size) 59 + { 60 + fill_with_garbage_skip(ptr, size, 0); 61 + } 62 + 63 + static int __init do_alloc_pages_order(int order, int *total_failures) 64 + { 65 + struct page *page; 66 + void *buf; 67 + size_t size = PAGE_SIZE << order; 68 + 69 + page = alloc_pages(GFP_KERNEL, order); 70 + buf = page_address(page); 71 + fill_with_garbage(buf, size); 72 + __free_pages(page, order); 73 + 74 + page = alloc_pages(GFP_KERNEL, order); 75 + buf = page_address(page); 76 + if (count_nonzero_bytes(buf, size)) 77 + (*total_failures)++; 78 + fill_with_garbage(buf, size); 79 + __free_pages(page, order); 80 + return 1; 81 + } 82 + 83 + /* Test the page allocator by calling alloc_pages with different orders. */ 84 + static int __init test_pages(int *total_failures) 85 + { 86 + int failures = 0, num_tests = 0; 87 + int i; 88 + 89 + for (i = 0; i < 10; i++) 90 + num_tests += do_alloc_pages_order(i, &failures); 91 + 92 + REPORT_FAILURES_IN_FN(); 93 + *total_failures += failures; 94 + return num_tests; 95 + } 96 + 97 + /* Test kmalloc() with given parameters. */ 98 + static int __init do_kmalloc_size(size_t size, int *total_failures) 99 + { 100 + void *buf; 101 + 102 + buf = kmalloc(size, GFP_KERNEL); 103 + fill_with_garbage(buf, size); 104 + kfree(buf); 105 + 106 + buf = kmalloc(size, GFP_KERNEL); 107 + if (count_nonzero_bytes(buf, size)) 108 + (*total_failures)++; 109 + fill_with_garbage(buf, size); 110 + kfree(buf); 111 + return 1; 112 + } 113 + 114 + /* Test vmalloc() with given parameters. */ 115 + static int __init do_vmalloc_size(size_t size, int *total_failures) 116 + { 117 + void *buf; 118 + 119 + buf = vmalloc(size); 120 + fill_with_garbage(buf, size); 121 + vfree(buf); 122 + 123 + buf = vmalloc(size); 124 + if (count_nonzero_bytes(buf, size)) 125 + (*total_failures)++; 126 + fill_with_garbage(buf, size); 127 + vfree(buf); 128 + return 1; 129 + } 130 + 131 + /* Test kmalloc()/vmalloc() by allocating objects of different sizes. */ 132 + static int __init test_kvmalloc(int *total_failures) 133 + { 134 + int failures = 0, num_tests = 0; 135 + int i, size; 136 + 137 + for (i = 0; i < 20; i++) { 138 + size = 1 << i; 139 + num_tests += do_kmalloc_size(size, &failures); 140 + num_tests += do_vmalloc_size(size, &failures); 141 + } 142 + 143 + REPORT_FAILURES_IN_FN(); 144 + *total_failures += failures; 145 + return num_tests; 146 + } 147 + 148 + #define CTOR_BYTES (sizeof(unsigned int)) 149 + #define CTOR_PATTERN (0x41414141) 150 + /* Initialize the first 4 bytes of the object. */ 151 + static void test_ctor(void *obj) 152 + { 153 + *(unsigned int *)obj = CTOR_PATTERN; 154 + } 155 + 156 + /* 157 + * Check the invariants for the buffer allocated from a slab cache. 158 + * If the cache has a test constructor, the first 4 bytes of the object must 159 + * always remain equal to CTOR_PATTERN. 160 + * If the cache isn't an RCU-typesafe one, or if the allocation is done with 161 + * __GFP_ZERO, then the object contents must be zeroed after allocation. 162 + * If the cache is an RCU-typesafe one, the object contents must never be 163 + * zeroed after the first use. This is checked by memcmp() in 164 + * do_kmem_cache_size(). 165 + */ 166 + static bool __init check_buf(void *buf, int size, bool want_ctor, 167 + bool want_rcu, bool want_zero) 168 + { 169 + int bytes; 170 + bool fail = false; 171 + 172 + bytes = count_nonzero_bytes(buf, size); 173 + WARN_ON(want_ctor && want_zero); 174 + if (want_zero) 175 + return bytes; 176 + if (want_ctor) { 177 + if (*(unsigned int *)buf != CTOR_PATTERN) 178 + fail = 1; 179 + } else { 180 + if (bytes) 181 + fail = !want_rcu; 182 + } 183 + return fail; 184 + } 185 + 186 + /* 187 + * Test kmem_cache with given parameters: 188 + * want_ctor - use a constructor; 189 + * want_rcu - use SLAB_TYPESAFE_BY_RCU; 190 + * want_zero - use __GFP_ZERO. 191 + */ 192 + static int __init do_kmem_cache_size(size_t size, bool want_ctor, 193 + bool want_rcu, bool want_zero, 194 + int *total_failures) 195 + { 196 + struct kmem_cache *c; 197 + int iter; 198 + bool fail = false; 199 + gfp_t alloc_mask = GFP_KERNEL | (want_zero ? __GFP_ZERO : 0); 200 + void *buf, *buf_copy; 201 + 202 + c = kmem_cache_create("test_cache", size, 1, 203 + want_rcu ? SLAB_TYPESAFE_BY_RCU : 0, 204 + want_ctor ? test_ctor : NULL); 205 + for (iter = 0; iter < 10; iter++) { 206 + buf = kmem_cache_alloc(c, alloc_mask); 207 + /* Check that buf is zeroed, if it must be. */ 208 + fail = check_buf(buf, size, want_ctor, want_rcu, want_zero); 209 + fill_with_garbage_skip(buf, size, want_ctor ? CTOR_BYTES : 0); 210 + 211 + if (!want_rcu) { 212 + kmem_cache_free(c, buf); 213 + continue; 214 + } 215 + 216 + /* 217 + * If this is an RCU cache, use a critical section to ensure we 218 + * can touch objects after they're freed. 219 + */ 220 + rcu_read_lock(); 221 + /* 222 + * Copy the buffer to check that it's not wiped on 223 + * free(). 224 + */ 225 + buf_copy = kmalloc(size, GFP_KERNEL); 226 + if (buf_copy) 227 + memcpy(buf_copy, buf, size); 228 + 229 + kmem_cache_free(c, buf); 230 + /* 231 + * Check that |buf| is intact after kmem_cache_free(). 232 + * |want_zero| is false, because we wrote garbage to 233 + * the buffer already. 234 + */ 235 + fail |= check_buf(buf, size, want_ctor, want_rcu, 236 + false); 237 + if (buf_copy) { 238 + fail |= (bool)memcmp(buf, buf_copy, size); 239 + kfree(buf_copy); 240 + } 241 + rcu_read_unlock(); 242 + } 243 + kmem_cache_destroy(c); 244 + 245 + *total_failures += fail; 246 + return 1; 247 + } 248 + 249 + /* 250 + * Check that the data written to an RCU-allocated object survives 251 + * reallocation. 252 + */ 253 + static int __init do_kmem_cache_rcu_persistent(int size, int *total_failures) 254 + { 255 + struct kmem_cache *c; 256 + void *buf, *buf_contents, *saved_ptr; 257 + void **used_objects; 258 + int i, iter, maxiter = 1024; 259 + bool fail = false; 260 + 261 + c = kmem_cache_create("test_cache", size, size, SLAB_TYPESAFE_BY_RCU, 262 + NULL); 263 + buf = kmem_cache_alloc(c, GFP_KERNEL); 264 + saved_ptr = buf; 265 + fill_with_garbage(buf, size); 266 + buf_contents = kmalloc(size, GFP_KERNEL); 267 + if (!buf_contents) 268 + goto out; 269 + used_objects = kmalloc_array(maxiter, sizeof(void *), GFP_KERNEL); 270 + if (!used_objects) { 271 + kfree(buf_contents); 272 + goto out; 273 + } 274 + memcpy(buf_contents, buf, size); 275 + kmem_cache_free(c, buf); 276 + /* 277 + * Run for a fixed number of iterations. If we never hit saved_ptr, 278 + * assume the test passes. 279 + */ 280 + for (iter = 0; iter < maxiter; iter++) { 281 + buf = kmem_cache_alloc(c, GFP_KERNEL); 282 + used_objects[iter] = buf; 283 + if (buf == saved_ptr) { 284 + fail = memcmp(buf_contents, buf, size); 285 + for (i = 0; i <= iter; i++) 286 + kmem_cache_free(c, used_objects[i]); 287 + goto free_out; 288 + } 289 + } 290 + 291 + free_out: 292 + kmem_cache_destroy(c); 293 + kfree(buf_contents); 294 + kfree(used_objects); 295 + out: 296 + *total_failures += fail; 297 + return 1; 298 + } 299 + 300 + /* 301 + * Test kmem_cache allocation by creating caches of different sizes, with and 302 + * without constructors, with and without SLAB_TYPESAFE_BY_RCU. 303 + */ 304 + static int __init test_kmemcache(int *total_failures) 305 + { 306 + int failures = 0, num_tests = 0; 307 + int i, flags, size; 308 + bool ctor, rcu, zero; 309 + 310 + for (i = 0; i < 10; i++) { 311 + size = 8 << i; 312 + for (flags = 0; flags < 8; flags++) { 313 + ctor = flags & 1; 314 + rcu = flags & 2; 315 + zero = flags & 4; 316 + if (ctor & zero) 317 + continue; 318 + num_tests += do_kmem_cache_size(size, ctor, rcu, zero, 319 + &failures); 320 + } 321 + } 322 + REPORT_FAILURES_IN_FN(); 323 + *total_failures += failures; 324 + return num_tests; 325 + } 326 + 327 + /* Test the behavior of SLAB_TYPESAFE_BY_RCU caches of different sizes. */ 328 + static int __init test_rcu_persistent(int *total_failures) 329 + { 330 + int failures = 0, num_tests = 0; 331 + int i, size; 332 + 333 + for (i = 0; i < 10; i++) { 334 + size = 8 << i; 335 + num_tests += do_kmem_cache_rcu_persistent(size, &failures); 336 + } 337 + REPORT_FAILURES_IN_FN(); 338 + *total_failures += failures; 339 + return num_tests; 340 + } 341 + 342 + /* 343 + * Run the tests. Each test function returns the number of executed tests and 344 + * updates |failures| with the number of failed tests. 345 + */ 346 + static int __init test_meminit_init(void) 347 + { 348 + int failures = 0, num_tests = 0; 349 + 350 + num_tests += test_pages(&failures); 351 + num_tests += test_kvmalloc(&failures); 352 + num_tests += test_kmemcache(&failures); 353 + num_tests += test_rcu_persistent(&failures); 354 + 355 + if (failures == 0) 356 + pr_info("all %d tests passed!\n", num_tests); 357 + else 358 + pr_info("failures: %d out of %d\n", failures, num_tests); 359 + 360 + return failures ? -EINVAL : 0; 361 + } 362 + module_init(test_meminit_init); 363 + 364 + MODULE_LICENSE("GPL");
+6 -5
lib/test_overflow.c
··· 486 486 * Deal with the various forms of allocator arguments. See comments above 487 487 * the DEFINE_TEST_ALLOC() instances for mapping of the "bits". 488 488 */ 489 - #define alloc010(alloc, arg, sz) alloc(sz, GFP_KERNEL) 490 - #define alloc011(alloc, arg, sz) alloc(sz, GFP_KERNEL, NUMA_NO_NODE) 489 + #define alloc_GFP (GFP_KERNEL | __GFP_NOWARN) 490 + #define alloc010(alloc, arg, sz) alloc(sz, alloc_GFP) 491 + #define alloc011(alloc, arg, sz) alloc(sz, alloc_GFP, NUMA_NO_NODE) 491 492 #define alloc000(alloc, arg, sz) alloc(sz) 492 493 #define alloc001(alloc, arg, sz) alloc(sz, NUMA_NO_NODE) 493 - #define alloc110(alloc, arg, sz) alloc(arg, sz, GFP_KERNEL) 494 + #define alloc110(alloc, arg, sz) alloc(arg, sz, alloc_GFP) 494 495 #define free0(free, arg, ptr) free(ptr) 495 496 #define free1(free, arg, ptr) free(arg, ptr) 496 497 497 - /* Wrap around to 8K */ 498 - #define TEST_SIZE (9 << PAGE_SHIFT) 498 + /* Wrap around to 16K */ 499 + #define TEST_SIZE (5 * 4096) 499 500 500 501 #define DEFINE_TEST_ALLOC(func, free_func, want_arg, want_gfp, want_node)\ 501 502 static int __init test_ ## func (void *arg) \
+80 -3
lib/test_string.c
··· 36 36 fail: 37 37 kfree(p); 38 38 if (i < 256) 39 - return (i << 24) | (j << 16) | k; 39 + return (i << 24) | (j << 16) | k | 0x8000; 40 40 return 0; 41 41 } 42 42 ··· 72 72 fail: 73 73 kfree(p); 74 74 if (i < 256) 75 - return (i << 24) | (j << 16) | k; 75 + return (i << 24) | (j << 16) | k | 0x8000; 76 76 return 0; 77 77 } 78 78 ··· 108 108 fail: 109 109 kfree(p); 110 110 if (i < 256) 111 - return (i << 24) | (j << 16) | k; 111 + return (i << 24) | (j << 16) | k | 0x8000; 112 + return 0; 113 + } 114 + 115 + static __init int strchr_selftest(void) 116 + { 117 + const char *test_string = "abcdefghijkl"; 118 + const char *empty_string = ""; 119 + char *result; 120 + int i; 121 + 122 + for (i = 0; i < strlen(test_string) + 1; i++) { 123 + result = strchr(test_string, test_string[i]); 124 + if (result - test_string != i) 125 + return i + 'a'; 126 + } 127 + 128 + result = strchr(empty_string, '\0'); 129 + if (result != empty_string) 130 + return 0x101; 131 + 132 + result = strchr(empty_string, 'a'); 133 + if (result) 134 + return 0x102; 135 + 136 + result = strchr(test_string, 'z'); 137 + if (result) 138 + return 0x103; 139 + 140 + return 0; 141 + } 142 + 143 + static __init int strnchr_selftest(void) 144 + { 145 + const char *test_string = "abcdefghijkl"; 146 + const char *empty_string = ""; 147 + char *result; 148 + int i, j; 149 + 150 + for (i = 0; i < strlen(test_string) + 1; i++) { 151 + for (j = 0; j < strlen(test_string) + 2; j++) { 152 + result = strnchr(test_string, j, test_string[i]); 153 + if (j <= i) { 154 + if (!result) 155 + continue; 156 + return ((i + 'a') << 8) | j; 157 + } 158 + if (result - test_string != i) 159 + return ((i + 'a') << 8) | j; 160 + } 161 + } 162 + 163 + result = strnchr(empty_string, 0, '\0'); 164 + if (result) 165 + return 0x10001; 166 + 167 + result = strnchr(empty_string, 1, '\0'); 168 + if (result != empty_string) 169 + return 0x10002; 170 + 171 + result = strnchr(empty_string, 1, 'a'); 172 + if (result) 173 + return 0x10003; 174 + 175 + result = strnchr(NULL, 0, '\0'); 176 + if (result) 177 + return 0x10004; 178 + 112 179 return 0; 113 180 } 114 181 ··· 195 128 196 129 test = 3; 197 130 subtest = memset64_selftest(); 131 + if (subtest) 132 + goto fail; 133 + 134 + test = 4; 135 + subtest = strchr_selftest(); 136 + if (subtest) 137 + goto fail; 138 + 139 + test = 5; 140 + subtest = strnchr_selftest(); 198 141 if (subtest) 199 142 goto fail; 200 143
+2 -3
mm/Kconfig
··· 649 649 See Documentation/admin-guide/mm/idle_page_tracking.rst for 650 650 more details. 651 651 652 - # arch_add_memory() comprehends device memory 653 - config ARCH_HAS_ZONE_DEVICE 652 + config ARCH_HAS_PTE_DEVMAP 654 653 bool 655 654 656 655 config ZONE_DEVICE ··· 657 658 depends on MEMORY_HOTPLUG 658 659 depends on MEMORY_HOTREMOVE 659 660 depends on SPARSEMEM_VMEMMAP 660 - depends on ARCH_HAS_ZONE_DEVICE 661 + depends on ARCH_HAS_PTE_DEVMAP 661 662 select XARRAY_MULTI 662 663 663 664 help
+14 -1
mm/cma.c
··· 278 278 */ 279 279 alignment = max(alignment, (phys_addr_t)PAGE_SIZE << 280 280 max_t(unsigned long, MAX_ORDER - 1, pageblock_order)); 281 + if (fixed && base & (alignment - 1)) { 282 + ret = -EINVAL; 283 + pr_err("Region at %pa must be aligned to %pa bytes\n", 284 + &base, &alignment); 285 + goto err; 286 + } 281 287 base = ALIGN(base, alignment); 282 288 size = ALIGN(size, alignment); 283 289 limit &= ~(alignment - 1); ··· 313 307 */ 314 308 if (limit == 0 || limit > memblock_end) 315 309 limit = memblock_end; 310 + 311 + if (base + size > limit) { 312 + ret = -EINVAL; 313 + pr_err("Size (%pa) of region at %pa exceeds limit (%pa)\n", 314 + &size, &base, &limit); 315 + goto err; 316 + } 316 317 317 318 /* Reserve memory */ 318 319 if (fixed) { ··· 507 494 * @pages: Allocated pages. 508 495 * @count: Number of allocated pages. 509 496 * 510 - * This function releases memory allocated by alloc_cma(). 497 + * This function releases memory allocated by cma_alloc(). 511 498 * It returns false when provided pages do not belong to contiguous area and 512 499 * true otherwise. 513 500 */
+1 -1
mm/gup.c
··· 1895 1895 } 1896 1896 #endif /* CONFIG_ARCH_HAS_PTE_SPECIAL */ 1897 1897 1898 - #if defined(__HAVE_ARCH_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE) 1898 + #if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE) 1899 1899 static int __gup_device_huge(unsigned long pfn, unsigned long addr, 1900 1900 unsigned long end, struct page **pages, int *nr) 1901 1901 {
+15 -7
mm/memcontrol.c
··· 695 695 if (mem_cgroup_disabled()) 696 696 return; 697 697 698 - __this_cpu_add(memcg->vmstats_local->stat[idx], val); 699 - 700 698 x = val + __this_cpu_read(memcg->vmstats_percpu->stat[idx]); 701 699 if (unlikely(abs(x) > MEMCG_CHARGE_BATCH)) { 702 700 struct mem_cgroup *mi; 703 701 702 + /* 703 + * Batch local counters to keep them in sync with 704 + * the hierarchical ones. 705 + */ 706 + __this_cpu_add(memcg->vmstats_local->stat[idx], x); 704 707 for (mi = memcg; mi; mi = parent_mem_cgroup(mi)) 705 708 atomic_long_add(x, &mi->vmstats[idx]); 706 709 x = 0; ··· 752 749 /* Update memcg */ 753 750 __mod_memcg_state(memcg, idx, val); 754 751 755 - /* Update lruvec */ 756 - __this_cpu_add(pn->lruvec_stat_local->count[idx], val); 757 - 758 752 x = val + __this_cpu_read(pn->lruvec_stat_cpu->count[idx]); 759 753 if (unlikely(abs(x) > MEMCG_CHARGE_BATCH)) { 760 754 struct mem_cgroup_per_node *pi; 761 755 756 + /* 757 + * Batch local counters to keep them in sync with 758 + * the hierarchical ones. 759 + */ 760 + __this_cpu_add(pn->lruvec_stat_local->count[idx], x); 762 761 for (pi = pn; pi; pi = parent_nodeinfo(pi, pgdat->node_id)) 763 762 atomic_long_add(x, &pi->lruvec_stat[idx]); 764 763 x = 0; ··· 782 777 if (mem_cgroup_disabled()) 783 778 return; 784 779 785 - __this_cpu_add(memcg->vmstats_local->events[idx], count); 786 - 787 780 x = count + __this_cpu_read(memcg->vmstats_percpu->events[idx]); 788 781 if (unlikely(x > MEMCG_CHARGE_BATCH)) { 789 782 struct mem_cgroup *mi; 790 783 784 + /* 785 + * Batch local counters to keep them in sync with 786 + * the hierarchical ones. 787 + */ 788 + __this_cpu_add(memcg->vmstats_local->events[idx], x); 791 789 for (mi = memcg; mi; mi = parent_mem_cgroup(mi)) 792 790 atomic_long_add(x, &mi->vmevents[idx]); 793 791 x = 0;
+43 -21
mm/memory_hotplug.c
··· 1734 1734 endpa = PFN_PHYS(section_nr_to_pfn(mem->end_section_nr + 1))-1; 1735 1735 pr_warn("removing memory fails, because memory [%pa-%pa] is onlined\n", 1736 1736 &beginpa, &endpa); 1737 - } 1738 1737 1739 - return ret; 1738 + return -EBUSY; 1739 + } 1740 + return 0; 1740 1741 } 1741 1742 1742 1743 static int check_cpu_on_node(pg_data_t *pgdat) ··· 1820 1819 } 1821 1820 } 1822 1821 1823 - /** 1824 - * remove_memory 1825 - * @nid: the node ID 1826 - * @start: physical address of the region to remove 1827 - * @size: size of the region to remove 1828 - * 1829 - * NOTE: The caller must call lock_device_hotplug() to serialize hotplug 1830 - * and online/offline operations before this call, as required by 1831 - * try_offline_node(). 1832 - */ 1833 - void __ref __remove_memory(int nid, u64 start, u64 size) 1822 + static int __ref try_remove_memory(int nid, u64 start, u64 size) 1834 1823 { 1835 - int ret; 1824 + int rc = 0; 1836 1825 1837 1826 BUG_ON(check_hotplug_memory_range(start, size)); 1838 1827 ··· 1830 1839 1831 1840 /* 1832 1841 * All memory blocks must be offlined before removing memory. Check 1833 - * whether all memory blocks in question are offline and trigger a BUG() 1842 + * whether all memory blocks in question are offline and return error 1834 1843 * if this is not the case. 1835 1844 */ 1836 - ret = walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), NULL, 1837 - check_memblock_offlined_cb); 1838 - if (ret) 1839 - BUG(); 1845 + rc = walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), NULL, 1846 + check_memblock_offlined_cb); 1847 + if (rc) 1848 + goto done; 1840 1849 1841 1850 /* remove memmap entry */ 1842 1851 firmware_map_remove(start, start + size, "System RAM"); ··· 1848 1857 1849 1858 try_offline_node(nid); 1850 1859 1860 + done: 1851 1861 mem_hotplug_done(); 1862 + return rc; 1852 1863 } 1853 1864 1854 - void remove_memory(int nid, u64 start, u64 size) 1865 + /** 1866 + * remove_memory 1867 + * @nid: the node ID 1868 + * @start: physical address of the region to remove 1869 + * @size: size of the region to remove 1870 + * 1871 + * NOTE: The caller must call lock_device_hotplug() to serialize hotplug 1872 + * and online/offline operations before this call, as required by 1873 + * try_offline_node(). 1874 + */ 1875 + void __remove_memory(int nid, u64 start, u64 size) 1855 1876 { 1877 + 1878 + /* 1879 + * trigger BUG() is some memory is not offlined prior to calling this 1880 + * function 1881 + */ 1882 + if (try_remove_memory(nid, start, size)) 1883 + BUG(); 1884 + } 1885 + 1886 + /* 1887 + * Remove memory if every memory block is offline, otherwise return -EBUSY is 1888 + * some memory is not offline 1889 + */ 1890 + int remove_memory(int nid, u64 start, u64 size) 1891 + { 1892 + int rc; 1893 + 1856 1894 lock_device_hotplug(); 1857 - __remove_memory(nid, start, size); 1895 + rc = try_remove_memory(nid, start, size); 1858 1896 unlock_device_hotplug(); 1897 + 1898 + return rc; 1859 1899 } 1860 1900 EXPORT_SYMBOL_GPL(remove_memory); 1861 1901 #endif /* CONFIG_MEMORY_HOTREMOVE */
+3 -1
mm/nommu.c
··· 1261 1261 add_nommu_region(region); 1262 1262 1263 1263 /* clear anonymous mappings that don't ask for uninitialized data */ 1264 - if (!vma->vm_file && !(flags & MAP_UNINITIALIZED)) 1264 + if (!vma->vm_file && 1265 + (!IS_ENABLED(CONFIG_MMAP_ALLOW_UNINITIALIZED) || 1266 + !(flags & MAP_UNINITIALIZED))) 1265 1267 memset((void *)region->vm_start, 0, 1266 1268 region->vm_end - region->vm_start); 1267 1269
-4
mm/page_alloc.c
··· 4102 4102 __perform_reclaim(gfp_t gfp_mask, unsigned int order, 4103 4103 const struct alloc_context *ac) 4104 4104 { 4105 - struct reclaim_state reclaim_state; 4106 4105 int progress; 4107 4106 unsigned int noreclaim_flag; 4108 4107 unsigned long pflags; ··· 4113 4114 psi_memstall_enter(&pflags); 4114 4115 fs_reclaim_acquire(gfp_mask); 4115 4116 noreclaim_flag = memalloc_noreclaim_save(); 4116 - reclaim_state.reclaimed_slab = 0; 4117 - current->reclaim_state = &reclaim_state; 4118 4117 4119 4118 progress = try_to_free_pages(ac->zonelist, order, gfp_mask, 4120 4119 ac->nodemask); 4121 4120 4122 - current->reclaim_state = NULL; 4123 4121 memalloc_noreclaim_restore(noreclaim_flag); 4124 4122 fs_reclaim_release(gfp_mask); 4125 4123 psi_memstall_leave(&pflags);
+3 -1
mm/shmem.c
··· 400 400 401 401 static int shmem_huge __read_mostly; 402 402 403 - #if defined(CONFIG_SYSFS) || defined(CONFIG_TMPFS) 403 + #if defined(CONFIG_SYSFS) 404 404 static int shmem_parse_huge(const char *str) 405 405 { 406 406 if (!strcmp(str, "never")) ··· 417 417 return SHMEM_HUGE_FORCE; 418 418 return -EINVAL; 419 419 } 420 + #endif 420 421 422 + #if defined(CONFIG_SYSFS) || defined(CONFIG_TMPFS) 421 423 static const char *shmem_format_huge(int huge) 422 424 { 423 425 switch (huge) {
+2 -1
mm/slab_common.c
··· 1028 1028 } 1029 1029 1030 1030 struct kmem_cache * 1031 - kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1] __ro_after_init; 1031 + kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1] __ro_after_init = 1032 + { /* initialization for https://bugs.llvm.org/show_bug.cgi?id=42570 */ }; 1032 1033 EXPORT_SYMBOL(kmalloc_caches); 1033 1034 1034 1035 /*
+75
mm/util.c
··· 7 7 #include <linux/err.h> 8 8 #include <linux/sched.h> 9 9 #include <linux/sched/mm.h> 10 + #include <linux/sched/signal.h> 10 11 #include <linux/sched/task_stack.h> 11 12 #include <linux/security.h> 12 13 #include <linux/swap.h> ··· 300 299 mm->get_unmapped_area = arch_get_unmapped_area; 301 300 } 302 301 #endif 302 + 303 + /** 304 + * __account_locked_vm - account locked pages to an mm's locked_vm 305 + * @mm: mm to account against 306 + * @pages: number of pages to account 307 + * @inc: %true if @pages should be considered positive, %false if not 308 + * @task: task used to check RLIMIT_MEMLOCK 309 + * @bypass_rlim: %true if checking RLIMIT_MEMLOCK should be skipped 310 + * 311 + * Assumes @task and @mm are valid (i.e. at least one reference on each), and 312 + * that mmap_sem is held as writer. 313 + * 314 + * Return: 315 + * * 0 on success 316 + * * -ENOMEM if RLIMIT_MEMLOCK would be exceeded. 317 + */ 318 + int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc, 319 + struct task_struct *task, bool bypass_rlim) 320 + { 321 + unsigned long locked_vm, limit; 322 + int ret = 0; 323 + 324 + lockdep_assert_held_write(&mm->mmap_sem); 325 + 326 + locked_vm = mm->locked_vm; 327 + if (inc) { 328 + if (!bypass_rlim) { 329 + limit = task_rlimit(task, RLIMIT_MEMLOCK) >> PAGE_SHIFT; 330 + if (locked_vm + pages > limit) 331 + ret = -ENOMEM; 332 + } 333 + if (!ret) 334 + mm->locked_vm = locked_vm + pages; 335 + } else { 336 + WARN_ON_ONCE(pages > locked_vm); 337 + mm->locked_vm = locked_vm - pages; 338 + } 339 + 340 + pr_debug("%s: [%d] caller %ps %c%lu %lu/%lu%s\n", __func__, task->pid, 341 + (void *)_RET_IP_, (inc) ? '+' : '-', pages << PAGE_SHIFT, 342 + locked_vm << PAGE_SHIFT, task_rlimit(task, RLIMIT_MEMLOCK), 343 + ret ? " - exceeded" : ""); 344 + 345 + return ret; 346 + } 347 + EXPORT_SYMBOL_GPL(__account_locked_vm); 348 + 349 + /** 350 + * account_locked_vm - account locked pages to an mm's locked_vm 351 + * @mm: mm to account against, may be NULL 352 + * @pages: number of pages to account 353 + * @inc: %true if @pages should be considered positive, %false if not 354 + * 355 + * Assumes a non-NULL @mm is valid (i.e. at least one reference on it). 356 + * 357 + * Return: 358 + * * 0 on success, or if mm is NULL 359 + * * -ENOMEM if RLIMIT_MEMLOCK would be exceeded. 360 + */ 361 + int account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc) 362 + { 363 + int ret; 364 + 365 + if (pages == 0 || !mm) 366 + return 0; 367 + 368 + down_write(&mm->mmap_sem); 369 + ret = __account_locked_vm(mm, pages, inc, current, 370 + capable(CAP_IPC_LOCK)); 371 + up_write(&mm->mmap_sem); 372 + 373 + return ret; 374 + } 375 + EXPORT_SYMBOL_GPL(account_locked_vm); 303 376 304 377 unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, 305 378 unsigned long len, unsigned long prot,
+29 -15
mm/vmscan.c
··· 131 131 unsigned int file_taken; 132 132 unsigned int taken; 133 133 } nr; 134 + 135 + /* for recording the reclaimed slab by now */ 136 + struct reclaim_state reclaim_state; 134 137 }; 135 138 136 139 #ifdef ARCH_HAS_PREFETCH ··· 240 237 { 241 238 } 242 239 #endif /* CONFIG_MEMCG_KMEM */ 240 + 241 + static void set_task_reclaim_state(struct task_struct *task, 242 + struct reclaim_state *rs) 243 + { 244 + /* Check for an overwrite */ 245 + WARN_ON_ONCE(rs && task->reclaim_state); 246 + 247 + /* Check for the nulling of an already-nulled member */ 248 + WARN_ON_ONCE(!rs && !task->reclaim_state); 249 + 250 + task->reclaim_state = rs; 251 + } 243 252 244 253 #ifdef CONFIG_MEMCG 245 254 static bool global_reclaim(struct scan_control *sc) ··· 3206 3191 if (throttle_direct_reclaim(sc.gfp_mask, zonelist, nodemask)) 3207 3192 return 1; 3208 3193 3194 + set_task_reclaim_state(current, &sc.reclaim_state); 3209 3195 trace_mm_vmscan_direct_reclaim_begin(order, sc.gfp_mask); 3210 3196 3211 3197 nr_reclaimed = do_try_to_free_pages(zonelist, &sc); 3212 3198 3213 3199 trace_mm_vmscan_direct_reclaim_end(nr_reclaimed); 3200 + set_task_reclaim_state(current, NULL); 3214 3201 3215 3202 return nr_reclaimed; 3216 3203 } ··· 3235 3218 }; 3236 3219 unsigned long lru_pages; 3237 3220 3221 + set_task_reclaim_state(current, &sc.reclaim_state); 3238 3222 sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | 3239 3223 (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK); 3240 3224 ··· 3253 3235 3254 3236 trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed); 3255 3237 3238 + set_task_reclaim_state(current, NULL); 3256 3239 *nr_scanned = sc.nr_scanned; 3240 + 3257 3241 return sc.nr_reclaimed; 3258 3242 } 3259 3243 ··· 3282 3262 .may_shrinkslab = 1, 3283 3263 }; 3284 3264 3265 + set_task_reclaim_state(current, &sc.reclaim_state); 3285 3266 /* 3286 3267 * Unlike direct reclaim via alloc_pages(), memcg's reclaim doesn't 3287 3268 * take care of from where we get pages. So the node where we start the ··· 3303 3282 psi_memstall_leave(&pflags); 3304 3283 3305 3284 trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); 3285 + set_task_reclaim_state(current, NULL); 3306 3286 3307 3287 return nr_reclaimed; 3308 3288 } ··· 3505 3483 .may_unmap = 1, 3506 3484 }; 3507 3485 3486 + set_task_reclaim_state(current, &sc.reclaim_state); 3508 3487 psi_memstall_enter(&pflags); 3509 3488 __fs_reclaim_acquire(); 3510 3489 ··· 3687 3664 snapshot_refaults(NULL, pgdat); 3688 3665 __fs_reclaim_release(); 3689 3666 psi_memstall_leave(&pflags); 3667 + set_task_reclaim_state(current, NULL); 3668 + 3690 3669 /* 3691 3670 * Return the order kswapd stopped reclaiming at as 3692 3671 * prepare_kswapd_sleep() takes it into account. If another caller ··· 3812 3787 unsigned int classzone_idx = MAX_NR_ZONES - 1; 3813 3788 pg_data_t *pgdat = (pg_data_t*)p; 3814 3789 struct task_struct *tsk = current; 3815 - 3816 - struct reclaim_state reclaim_state = { 3817 - .reclaimed_slab = 0, 3818 - }; 3819 3790 const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); 3820 3791 3821 3792 if (!cpumask_empty(cpumask)) 3822 3793 set_cpus_allowed_ptr(tsk, cpumask); 3823 - current->reclaim_state = &reclaim_state; 3824 3794 3825 3795 /* 3826 3796 * Tell the memory management that we're a "memory allocator", ··· 3877 3857 } 3878 3858 3879 3859 tsk->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD); 3880 - current->reclaim_state = NULL; 3881 3860 3882 3861 return 0; 3883 3862 } ··· 3941 3922 */ 3942 3923 unsigned long shrink_all_memory(unsigned long nr_to_reclaim) 3943 3924 { 3944 - struct reclaim_state reclaim_state; 3945 3925 struct scan_control sc = { 3946 3926 .nr_to_reclaim = nr_to_reclaim, 3947 3927 .gfp_mask = GFP_HIGHUSER_MOVABLE, ··· 3952 3934 .hibernation_mode = 1, 3953 3935 }; 3954 3936 struct zonelist *zonelist = node_zonelist(numa_node_id(), sc.gfp_mask); 3955 - struct task_struct *p = current; 3956 3937 unsigned long nr_reclaimed; 3957 3938 unsigned int noreclaim_flag; 3958 3939 3959 3940 fs_reclaim_acquire(sc.gfp_mask); 3960 3941 noreclaim_flag = memalloc_noreclaim_save(); 3961 - reclaim_state.reclaimed_slab = 0; 3962 - p->reclaim_state = &reclaim_state; 3942 + set_task_reclaim_state(current, &sc.reclaim_state); 3963 3943 3964 3944 nr_reclaimed = do_try_to_free_pages(zonelist, &sc); 3965 3945 3966 - p->reclaim_state = NULL; 3946 + set_task_reclaim_state(current, NULL); 3967 3947 memalloc_noreclaim_restore(noreclaim_flag); 3968 3948 fs_reclaim_release(sc.gfp_mask); 3969 3949 ··· 4126 4110 /* Minimum pages needed in order to stay on node */ 4127 4111 const unsigned long nr_pages = 1 << order; 4128 4112 struct task_struct *p = current; 4129 - struct reclaim_state reclaim_state; 4130 4113 unsigned int noreclaim_flag; 4131 4114 struct scan_control sc = { 4132 4115 .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), ··· 4150 4135 */ 4151 4136 noreclaim_flag = memalloc_noreclaim_save(); 4152 4137 p->flags |= PF_SWAPWRITE; 4153 - reclaim_state.reclaimed_slab = 0; 4154 - p->reclaim_state = &reclaim_state; 4138 + set_task_reclaim_state(p, &sc.reclaim_state); 4155 4139 4156 4140 if (node_pagecache_reclaimable(pgdat) > pgdat->min_unmapped_pages) { 4157 4141 /* ··· 4162 4148 } while (sc.nr_reclaimed < nr_pages && --sc.priority >= 0); 4163 4149 } 4164 4150 4165 - p->reclaim_state = NULL; 4151 + set_task_reclaim_state(p, NULL); 4166 4152 current->flags &= ~PF_SWAPWRITE; 4167 4153 memalloc_noreclaim_restore(noreclaim_flag); 4168 4154 fs_reclaim_release(sc.gfp_mask);
+19 -10
mm/z3fold.c
··· 101 101 * @refcount: reference count for the z3fold page 102 102 * @work: work_struct for page layout optimization 103 103 * @slots: pointer to the structure holding buddy slots 104 + * @pool: pointer to the containing pool 104 105 * @cpu: CPU which this page "belongs" to 105 106 * @first_chunks: the size of the first buddy in chunks, 0 if free 106 107 * @middle_chunks: the size of the middle buddy in chunks, 0 if free ··· 115 114 struct kref refcount; 116 115 struct work_struct work; 117 116 struct z3fold_buddy_slots *slots; 117 + struct z3fold_pool *pool; 118 118 short cpu; 119 119 unsigned short first_chunks; 120 120 unsigned short middle_chunks; ··· 195 193 static inline struct z3fold_buddy_slots *alloc_slots(struct z3fold_pool *pool, 196 194 gfp_t gfp) 197 195 { 198 - struct z3fold_buddy_slots *slots = kmem_cache_alloc(pool->c_handle, 199 - gfp); 196 + struct z3fold_buddy_slots *slots; 197 + 198 + slots = kmem_cache_alloc(pool->c_handle, 199 + (gfp & ~(__GFP_HIGHMEM | __GFP_MOVABLE))); 200 200 201 201 if (slots) { 202 202 memset(slots->slot, 0, sizeof(slots->slot)); ··· 324 320 zhdr->start_middle = 0; 325 321 zhdr->cpu = -1; 326 322 zhdr->slots = slots; 323 + zhdr->pool = pool; 327 324 INIT_LIST_HEAD(&zhdr->buddy); 328 325 INIT_WORK(&zhdr->work, compact_page_work); 329 326 return zhdr; ··· 431 426 432 427 static inline struct z3fold_pool *zhdr_to_pool(struct z3fold_header *zhdr) 433 428 { 434 - return slots_to_pool(zhdr->slots); 429 + return zhdr->pool; 435 430 } 436 431 437 432 static void __release_z3fold_page(struct z3fold_header *zhdr, bool locked) ··· 855 850 enum buddy bud; 856 851 bool can_sleep = gfpflags_allow_blocking(gfp); 857 852 858 - if (!size || (gfp & __GFP_HIGHMEM)) 853 + if (!size) 859 854 return -EINVAL; 860 855 861 856 if (size > PAGE_SIZE) ··· 1350 1345 zhdr = page_address(page); 1351 1346 pool = zhdr_to_pool(zhdr); 1352 1347 1353 - if (!trylock_page(page)) 1354 - return -EAGAIN; 1355 - 1356 1348 if (!z3fold_page_trylock(zhdr)) { 1357 - unlock_page(page); 1358 1349 return -EAGAIN; 1359 1350 } 1360 1351 if (zhdr->mapped_count != 0) { 1361 1352 z3fold_page_unlock(zhdr); 1362 - unlock_page(page); 1363 1353 return -EBUSY; 1354 + } 1355 + if (work_pending(&zhdr->work)) { 1356 + z3fold_page_unlock(zhdr); 1357 + return -EAGAIN; 1364 1358 } 1365 1359 new_zhdr = page_address(newpage); 1366 1360 memcpy(new_zhdr, zhdr, PAGE_SIZE); ··· 1367 1363 page->private = 0; 1368 1364 z3fold_page_unlock(zhdr); 1369 1365 spin_lock_init(&new_zhdr->page_lock); 1366 + INIT_WORK(&new_zhdr->work, compact_page_work); 1367 + /* 1368 + * z3fold_page_isolate() ensures that new_zhdr->buddy is empty, 1369 + * so we only have to reinitialize it. 1370 + */ 1371 + INIT_LIST_HEAD(&new_zhdr->buddy); 1370 1372 new_mapping = page_mapping(page); 1371 1373 __ClearPageMovable(page); 1372 1374 ClearPagePrivate(page); ··· 1396 1386 queue_work_on(new_zhdr->cpu, pool->compact_wq, &new_zhdr->work); 1397 1387 1398 1388 page_mapcount_reset(page); 1399 - unlock_page(page); 1400 1389 put_page(page); 1401 1390 return 0; 1402 1391 }
+6
scripts/checkpatch.pl
··· 6639 6639 "unknown module license " . $extracted_string . "\n" . $herecurr); 6640 6640 } 6641 6641 } 6642 + 6643 + # check for sysctl duplicate constants 6644 + if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max)\b/) { 6645 + WARN("DUPLICATED_SYSCTL_CONST", 6646 + "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h\n" . $herecurr); 6647 + } 6642 6648 } 6643 6649 6644 6650 # If we have no input at all, then there is nothing to report on
+182
scripts/gdb/linux/device.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + # Copyright (c) NXP 2019 4 + 5 + import gdb 6 + 7 + from linux.utils import CachedType 8 + from linux.utils import container_of 9 + from linux.lists import list_for_each_entry 10 + 11 + 12 + device_private_type = CachedType('struct device_private') 13 + device_type = CachedType('struct device') 14 + 15 + subsys_private_type = CachedType('struct subsys_private') 16 + kobject_type = CachedType('struct kobject') 17 + kset_type = CachedType('struct kset') 18 + 19 + bus_type = CachedType('struct bus_type') 20 + class_type = CachedType('struct class') 21 + 22 + 23 + def dev_name(dev): 24 + dev_init_name = dev['init_name'] 25 + if dev_init_name: 26 + return dev_init_name.string() 27 + return dev['kobj']['name'].string() 28 + 29 + 30 + def kset_for_each_object(kset): 31 + return list_for_each_entry(kset['list'], 32 + kobject_type.get_type().pointer(), "entry") 33 + 34 + 35 + def for_each_bus(): 36 + for kobj in kset_for_each_object(gdb.parse_and_eval('bus_kset')): 37 + subsys = container_of(kobj, kset_type.get_type().pointer(), 'kobj') 38 + subsys_priv = container_of(subsys, subsys_private_type.get_type().pointer(), 'subsys') 39 + yield subsys_priv['bus'] 40 + 41 + 42 + def for_each_class(): 43 + for kobj in kset_for_each_object(gdb.parse_and_eval('class_kset')): 44 + subsys = container_of(kobj, kset_type.get_type().pointer(), 'kobj') 45 + subsys_priv = container_of(subsys, subsys_private_type.get_type().pointer(), 'subsys') 46 + yield subsys_priv['class'] 47 + 48 + 49 + def get_bus_by_name(name): 50 + for item in for_each_bus(): 51 + if item['name'].string() == name: 52 + return item 53 + raise gdb.GdbError("Can't find bus type {!r}".format(name)) 54 + 55 + 56 + def get_class_by_name(name): 57 + for item in for_each_class(): 58 + if item['name'].string() == name: 59 + return item 60 + raise gdb.GdbError("Can't find device class {!r}".format(name)) 61 + 62 + 63 + klist_type = CachedType('struct klist') 64 + klist_node_type = CachedType('struct klist_node') 65 + 66 + 67 + def klist_for_each(klist): 68 + return list_for_each_entry(klist['k_list'], 69 + klist_node_type.get_type().pointer(), 'n_node') 70 + 71 + 72 + def bus_for_each_device(bus): 73 + for kn in klist_for_each(bus['p']['klist_devices']): 74 + dp = container_of(kn, device_private_type.get_type().pointer(), 'knode_bus') 75 + yield dp['device'] 76 + 77 + 78 + def class_for_each_device(cls): 79 + for kn in klist_for_each(cls['p']['klist_devices']): 80 + dp = container_of(kn, device_private_type.get_type().pointer(), 'knode_class') 81 + yield dp['device'] 82 + 83 + 84 + def device_for_each_child(dev): 85 + for kn in klist_for_each(dev['p']['klist_children']): 86 + dp = container_of(kn, device_private_type.get_type().pointer(), 'knode_parent') 87 + yield dp['device'] 88 + 89 + 90 + def _show_device(dev, level=0, recursive=False): 91 + gdb.write('{}dev {}:\t{}\n'.format('\t' * level, dev_name(dev), dev)) 92 + if recursive: 93 + for child in device_for_each_child(dev): 94 + _show_device(child, level + 1, recursive) 95 + 96 + 97 + class LxDeviceListBus(gdb.Command): 98 + '''Print devices on a bus (or all buses if not specified)''' 99 + 100 + def __init__(self): 101 + super(LxDeviceListBus, self).__init__('lx-device-list-bus', gdb.COMMAND_DATA) 102 + 103 + def invoke(self, arg, from_tty): 104 + if not arg: 105 + for bus in for_each_bus(): 106 + gdb.write('bus {}:\t{}\n'.format(bus['name'].string(), bus)) 107 + for dev in bus_for_each_device(bus): 108 + _show_device(dev, level=1) 109 + else: 110 + bus = get_bus_by_name(arg) 111 + if not bus: 112 + raise gdb.GdbError("Can't find bus {!r}".format(arg)) 113 + for dev in bus_for_each_device(bus): 114 + _show_device(dev) 115 + 116 + 117 + class LxDeviceListClass(gdb.Command): 118 + '''Print devices in a class (or all classes if not specified)''' 119 + 120 + def __init__(self): 121 + super(LxDeviceListClass, self).__init__('lx-device-list-class', gdb.COMMAND_DATA) 122 + 123 + def invoke(self, arg, from_tty): 124 + if not arg: 125 + for cls in for_each_class(): 126 + gdb.write("class {}:\t{}\n".format(cls['name'].string(), cls)) 127 + for dev in class_for_each_device(cls): 128 + _show_device(dev, level=1) 129 + else: 130 + cls = get_class_by_name(arg) 131 + for dev in class_for_each_device(cls): 132 + _show_device(dev) 133 + 134 + 135 + class LxDeviceListTree(gdb.Command): 136 + '''Print a device and its children recursively''' 137 + 138 + def __init__(self): 139 + super(LxDeviceListTree, self).__init__('lx-device-list-tree', gdb.COMMAND_DATA) 140 + 141 + def invoke(self, arg, from_tty): 142 + if not arg: 143 + raise gdb.GdbError('Please provide pointer to struct device') 144 + dev = gdb.parse_and_eval(arg) 145 + if dev.type != device_type.get_type().pointer(): 146 + raise gdb.GdbError('Please provide pointer to struct device') 147 + _show_device(dev, level=0, recursive=True) 148 + 149 + 150 + class LxDeviceFindByBusName(gdb.Function): 151 + '''Find struct device by bus and name (both strings)''' 152 + 153 + def __init__(self): 154 + super(LxDeviceFindByBusName, self).__init__('lx_device_find_by_bus_name') 155 + 156 + def invoke(self, bus, name): 157 + name = name.string() 158 + bus = get_bus_by_name(bus.string()) 159 + for dev in bus_for_each_device(bus): 160 + if dev_name(dev) == name: 161 + return dev 162 + 163 + 164 + class LxDeviceFindByClassName(gdb.Function): 165 + '''Find struct device by class and name (both strings)''' 166 + 167 + def __init__(self): 168 + super(LxDeviceFindByClassName, self).__init__('lx_device_find_by_class_name') 169 + 170 + def invoke(self, cls, name): 171 + name = name.string() 172 + cls = get_class_by_name(cls.string()) 173 + for dev in class_for_each_device(cls): 174 + if dev_name(dev) == name: 175 + return dev 176 + 177 + 178 + LxDeviceListBus() 179 + LxDeviceListClass() 180 + LxDeviceListTree() 181 + LxDeviceFindByBusName() 182 + LxDeviceFindByClassName()
+83
scripts/gdb/linux/genpd.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + # Copyright (c) NXP 2019 4 + 5 + import gdb 6 + import sys 7 + 8 + from linux.utils import CachedType 9 + from linux.lists import list_for_each_entry 10 + 11 + generic_pm_domain_type = CachedType('struct generic_pm_domain') 12 + pm_domain_data_type = CachedType('struct pm_domain_data') 13 + device_link_type = CachedType('struct device_link') 14 + 15 + 16 + def kobject_get_path(kobj): 17 + path = kobj['name'].string() 18 + parent = kobj['parent'] 19 + if parent: 20 + path = kobject_get_path(parent) + '/' + path 21 + return path 22 + 23 + 24 + def rtpm_status_str(dev): 25 + if dev['power']['runtime_error']: 26 + return 'error' 27 + if dev['power']['disable_depth']: 28 + return 'unsupported' 29 + _RPM_STATUS_LOOKUP = [ 30 + "active", 31 + "resuming", 32 + "suspended", 33 + "suspending" 34 + ] 35 + return _RPM_STATUS_LOOKUP[dev['power']['runtime_status']] 36 + 37 + 38 + class LxGenPDSummary(gdb.Command): 39 + '''Print genpd summary 40 + 41 + Output is similar to /sys/kernel/debug/pm_genpd/pm_genpd_summary''' 42 + 43 + def __init__(self): 44 + super(LxGenPDSummary, self).__init__('lx-genpd-summary', gdb.COMMAND_DATA) 45 + 46 + def summary_one(self, genpd): 47 + if genpd['status'] == 0: 48 + status_string = 'on' 49 + else: 50 + status_string = 'off-{}'.format(genpd['state_idx']) 51 + 52 + slave_names = [] 53 + for link in list_for_each_entry( 54 + genpd['master_links'], 55 + device_link_type.get_type().pointer(), 56 + 'master_node'): 57 + slave_names.apend(link['slave']['name']) 58 + 59 + gdb.write('%-30s %-15s %s\n' % ( 60 + genpd['name'].string(), 61 + status_string, 62 + ', '.join(slave_names))) 63 + 64 + # Print devices in domain 65 + for pm_data in list_for_each_entry(genpd['dev_list'], 66 + pm_domain_data_type.get_type().pointer(), 67 + 'list_node'): 68 + dev = pm_data['dev'] 69 + kobj_path = kobject_get_path(dev['kobj']) 70 + gdb.write(' %-50s %s\n' % (kobj_path, rtpm_status_str(dev))) 71 + 72 + def invoke(self, arg, from_tty): 73 + gdb.write('domain status slaves\n'); 74 + gdb.write(' /device runtime status\n'); 75 + gdb.write('----------------------------------------------------------------------\n'); 76 + for genpd in list_for_each_entry( 77 + gdb.parse_and_eval('&gpd_list'), 78 + generic_pm_domain_type.get_type().pointer(), 79 + 'gpd_list_node'): 80 + self.summary_one(genpd) 81 + 82 + 83 + LxGenPDSummary()
+2
scripts/gdb/vmlinux-gdb.py
··· 35 35 import linux.constants 36 36 import linux.timerlist 37 37 import linux.clk 38 + import linux.genpd 39 + import linux.device
+10 -4
scripts/get_maintainer.pl
··· 27 27 my $email_maintainer = 1; 28 28 my $email_reviewer = 1; 29 29 my $email_list = 1; 30 + my $email_moderated_list = 1; 30 31 my $email_subscriber_list = 0; 31 32 my $email_git_penguin_chiefs = 0; 32 33 my $email_git = 0; ··· 249 248 'r!' => \$email_reviewer, 250 249 'n!' => \$email_usename, 251 250 'l!' => \$email_list, 251 + 'moderated!' => \$email_moderated_list, 252 252 's!' => \$email_subscriber_list, 253 253 'multiline!' => \$output_multiline, 254 254 'roles!' => \$output_roles, ··· 1025 1023 --r => include reviewer(s) if any 1026 1024 --n => include name 'Full Name <addr\@domain.tld>' 1027 1025 --l => include list(s) if any 1028 - --s => include subscriber only list(s) if any 1026 + --moderated => include moderated lists(s) if any (default: true) 1027 + --s => include subscriber only list(s) if any (default: false) 1029 1028 --remove-duplicates => minimize duplicate email names/addresses 1030 1029 --roles => show roles (status:subsystem, git-signer, list, etc...) 1031 1030 --rolestats => show roles and statistics (commits/total_commits, %) ··· 1316 1313 } else { 1317 1314 if ($email_list) { 1318 1315 if (!$hash_list_to{lc($list_address)}) { 1319 - $hash_list_to{lc($list_address)} = 1; 1320 1316 if ($list_additional =~ m/moderated/) { 1321 - push(@list_to, [$list_address, 1322 - "moderated list${list_role}"]); 1317 + if ($email_moderated_list) { 1318 + $hash_list_to{lc($list_address)} = 1; 1319 + push(@list_to, [$list_address, 1320 + "moderated list${list_role}"]); 1321 + } 1323 1322 } else { 1323 + $hash_list_to{lc($list_address)} = 1; 1324 1324 push(@list_to, [$list_address, 1325 1325 "open list${list_role}"]); 1326 1326 }
+1 -1
sound/soc/qcom/qdsp6/q6asm.c
··· 1194 1194 * q6asm_write_async() - non blocking write 1195 1195 * 1196 1196 * @ac: audio client pointer 1197 - * @len: lenght in bytes 1197 + * @len: length in bytes 1198 1198 * @msw_ts: timestamp msw 1199 1199 * @lsw_ts: timestamp lsw 1200 1200 * @wflags: flags associated with write
+1
tools/testing/selftests/proc/.gitignore
··· 12 12 /read 13 13 /self 14 14 /setns-dcache 15 + /setns-sysvipc 15 16 /thread-self
+1
tools/testing/selftests/proc/Makefile
··· 17 17 TEST_GEN_PROGS += read 18 18 TEST_GEN_PROGS += self 19 19 TEST_GEN_PROGS += setns-dcache 20 + TEST_GEN_PROGS += setns-sysvipc 20 21 TEST_GEN_PROGS += thread-self 21 22 22 23 include ../lib.mk
+15 -2
tools/testing/selftests/proc/proc-pid-vm.c
··· 215 215 "ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n"; 216 216 217 217 #ifdef __x86_64__ 218 + static void sigaction_SIGSEGV(int _, siginfo_t *__, void *___) 219 + { 220 + _exit(1); 221 + } 222 + 218 223 /* 219 224 * vsyscall page can't be unmapped, probe it with memory load. 220 225 */ ··· 236 231 if (pid == 0) { 237 232 struct rlimit rlim = {0, 0}; 238 233 (void)setrlimit(RLIMIT_CORE, &rlim); 234 + 235 + /* Hide "segfault at ffffffffff600000" messages. */ 236 + struct sigaction act; 237 + memset(&act, 0, sizeof(struct sigaction)); 238 + act.sa_flags = SA_SIGINFO; 239 + act.sa_sigaction = sigaction_SIGSEGV; 240 + (void)sigaction(SIGSEGV, &act, NULL); 241 + 239 242 *(volatile int *)0xffffffffff600000UL; 240 243 exit(0); 241 244 } 242 - wait(&wstatus); 243 - if (WIFEXITED(wstatus)) { 245 + waitpid(pid, &wstatus, 0); 246 + if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0) { 244 247 g_vsyscall = true; 245 248 } 246 249 }
+133
tools/testing/selftests/proc/setns-sysvipc.c
··· 1 + /* 2 + * Copyright © 2019 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 + /* 17 + * Test that setns(CLONE_NEWIPC) points to new /proc/sysvipc content even 18 + * if old one is in dcache. 19 + */ 20 + #undef NDEBUG 21 + #include <assert.h> 22 + #include <errno.h> 23 + #include <stdio.h> 24 + #include <sched.h> 25 + #include <signal.h> 26 + #include <stdlib.h> 27 + #include <string.h> 28 + #include <unistd.h> 29 + #include <sys/types.h> 30 + #include <sys/stat.h> 31 + #include <fcntl.h> 32 + #include <sys/ipc.h> 33 + #include <sys/shm.h> 34 + 35 + static pid_t pid = -1; 36 + 37 + static void f(void) 38 + { 39 + if (pid > 0) { 40 + kill(pid, SIGTERM); 41 + } 42 + } 43 + 44 + int main(void) 45 + { 46 + int fd[2]; 47 + char _ = 0; 48 + int nsfd; 49 + 50 + atexit(f); 51 + 52 + /* Check for priviledges and syscall availability straight away. */ 53 + if (unshare(CLONE_NEWIPC) == -1) { 54 + if (errno == ENOSYS || errno == EPERM) { 55 + return 4; 56 + } 57 + return 1; 58 + } 59 + /* Distinguisher between two otherwise empty IPC namespaces. */ 60 + if (shmget(IPC_PRIVATE, 1, IPC_CREAT) == -1) { 61 + return 1; 62 + } 63 + 64 + if (pipe(fd) == -1) { 65 + return 1; 66 + } 67 + 68 + pid = fork(); 69 + if (pid == -1) { 70 + return 1; 71 + } 72 + 73 + if (pid == 0) { 74 + if (unshare(CLONE_NEWIPC) == -1) { 75 + return 1; 76 + } 77 + 78 + if (write(fd[1], &_, 1) != 1) { 79 + return 1; 80 + } 81 + 82 + pause(); 83 + 84 + return 0; 85 + } 86 + 87 + if (read(fd[0], &_, 1) != 1) { 88 + return 1; 89 + } 90 + 91 + { 92 + char buf[64]; 93 + snprintf(buf, sizeof(buf), "/proc/%u/ns/ipc", pid); 94 + nsfd = open(buf, O_RDONLY); 95 + if (nsfd == -1) { 96 + return 1; 97 + } 98 + } 99 + 100 + /* Reliably pin dentry into dcache. */ 101 + (void)open("/proc/sysvipc/shm", O_RDONLY); 102 + 103 + if (setns(nsfd, CLONE_NEWIPC) == -1) { 104 + return 1; 105 + } 106 + 107 + kill(pid, SIGTERM); 108 + pid = 0; 109 + 110 + { 111 + char buf[4096]; 112 + ssize_t rv; 113 + int fd; 114 + 115 + fd = open("/proc/sysvipc/shm", O_RDONLY); 116 + if (fd == -1) { 117 + return 1; 118 + } 119 + 120 + #define S32 " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n" 121 + #define S64 " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n" 122 + rv = read(fd, buf, sizeof(buf)); 123 + if (rv == strlen(S32)) { 124 + assert(memcmp(buf, S32, strlen(S32)) == 0); 125 + } else if (rv == strlen(S64)) { 126 + assert(memcmp(buf, S64, strlen(S64)) == 0); 127 + } else { 128 + assert(0); 129 + } 130 + } 131 + 132 + return 0; 133 + }
+1
tools/testing/selftests/ptrace/.gitignore
··· 1 + get_syscall_info 1 2 peeksiginfo
+1 -1
tools/testing/selftests/ptrace/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 CFLAGS += -iquote../../../../include/uapi -Wall 3 3 4 - TEST_GEN_PROGS := peeksiginfo 4 + TEST_GEN_PROGS := get_syscall_info peeksiginfo 5 5 6 6 include ../lib.mk
+271
tools/testing/selftests/ptrace/get_syscall_info.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright (c) 2018 Dmitry V. Levin <ldv@altlinux.org> 4 + * All rights reserved. 5 + * 6 + * Check whether PTRACE_GET_SYSCALL_INFO semantics implemented in the kernel 7 + * matches userspace expectations. 8 + */ 9 + 10 + #include "../kselftest_harness.h" 11 + #include <err.h> 12 + #include <signal.h> 13 + #include <asm/unistd.h> 14 + #include "linux/ptrace.h" 15 + 16 + static int 17 + kill_tracee(pid_t pid) 18 + { 19 + if (!pid) 20 + return 0; 21 + 22 + int saved_errno = errno; 23 + 24 + int rc = kill(pid, SIGKILL); 25 + 26 + errno = saved_errno; 27 + return rc; 28 + } 29 + 30 + static long 31 + sys_ptrace(int request, pid_t pid, unsigned long addr, unsigned long data) 32 + { 33 + return syscall(__NR_ptrace, request, pid, addr, data); 34 + } 35 + 36 + #define LOG_KILL_TRACEE(fmt, ...) \ 37 + do { \ 38 + kill_tracee(pid); \ 39 + TH_LOG("wait #%d: " fmt, \ 40 + ptrace_stop, ##__VA_ARGS__); \ 41 + } while (0) 42 + 43 + TEST(get_syscall_info) 44 + { 45 + static const unsigned long args[][7] = { 46 + /* a sequence of architecture-agnostic syscalls */ 47 + { 48 + __NR_chdir, 49 + (unsigned long) "", 50 + 0xbad1fed1, 51 + 0xbad2fed2, 52 + 0xbad3fed3, 53 + 0xbad4fed4, 54 + 0xbad5fed5 55 + }, 56 + { 57 + __NR_gettid, 58 + 0xcaf0bea0, 59 + 0xcaf1bea1, 60 + 0xcaf2bea2, 61 + 0xcaf3bea3, 62 + 0xcaf4bea4, 63 + 0xcaf5bea5 64 + }, 65 + { 66 + __NR_exit_group, 67 + 0, 68 + 0xfac1c0d1, 69 + 0xfac2c0d2, 70 + 0xfac3c0d3, 71 + 0xfac4c0d4, 72 + 0xfac5c0d5 73 + } 74 + }; 75 + const unsigned long *exp_args; 76 + 77 + pid_t pid = fork(); 78 + 79 + ASSERT_LE(0, pid) { 80 + TH_LOG("fork: %m"); 81 + } 82 + 83 + if (pid == 0) { 84 + /* get the pid before PTRACE_TRACEME */ 85 + pid = getpid(); 86 + ASSERT_EQ(0, sys_ptrace(PTRACE_TRACEME, 0, 0, 0)) { 87 + TH_LOG("PTRACE_TRACEME: %m"); 88 + } 89 + ASSERT_EQ(0, kill(pid, SIGSTOP)) { 90 + /* cannot happen */ 91 + TH_LOG("kill SIGSTOP: %m"); 92 + } 93 + for (unsigned int i = 0; i < ARRAY_SIZE(args); ++i) { 94 + syscall(args[i][0], 95 + args[i][1], args[i][2], args[i][3], 96 + args[i][4], args[i][5], args[i][6]); 97 + } 98 + /* unreachable */ 99 + _exit(1); 100 + } 101 + 102 + const struct { 103 + unsigned int is_error; 104 + int rval; 105 + } *exp_param, exit_param[] = { 106 + { 1, -ENOENT }, /* chdir */ 107 + { 0, pid } /* gettid */ 108 + }; 109 + 110 + unsigned int ptrace_stop; 111 + 112 + for (ptrace_stop = 0; ; ++ptrace_stop) { 113 + struct ptrace_syscall_info info = { 114 + .op = 0xff /* invalid PTRACE_SYSCALL_INFO_* op */ 115 + }; 116 + const size_t size = sizeof(info); 117 + const int expected_none_size = 118 + (void *) &info.entry - (void *) &info; 119 + const int expected_entry_size = 120 + (void *) &info.entry.args[6] - (void *) &info; 121 + const int expected_exit_size = 122 + (void *) (&info.exit.is_error + 1) - 123 + (void *) &info; 124 + int status; 125 + long rc; 126 + 127 + ASSERT_EQ(pid, wait(&status)) { 128 + /* cannot happen */ 129 + LOG_KILL_TRACEE("wait: %m"); 130 + } 131 + if (WIFEXITED(status)) { 132 + pid = 0; /* the tracee is no more */ 133 + ASSERT_EQ(0, WEXITSTATUS(status)); 134 + break; 135 + } 136 + ASSERT_FALSE(WIFSIGNALED(status)) { 137 + pid = 0; /* the tracee is no more */ 138 + LOG_KILL_TRACEE("unexpected signal %u", 139 + WTERMSIG(status)); 140 + } 141 + ASSERT_TRUE(WIFSTOPPED(status)) { 142 + /* cannot happen */ 143 + LOG_KILL_TRACEE("unexpected wait status %#x", status); 144 + } 145 + 146 + switch (WSTOPSIG(status)) { 147 + case SIGSTOP: 148 + ASSERT_EQ(0, ptrace_stop) { 149 + LOG_KILL_TRACEE("unexpected signal stop"); 150 + } 151 + ASSERT_EQ(0, sys_ptrace(PTRACE_SETOPTIONS, pid, 0, 152 + PTRACE_O_TRACESYSGOOD)) { 153 + LOG_KILL_TRACEE("PTRACE_SETOPTIONS: %m"); 154 + } 155 + ASSERT_LT(0, (rc = sys_ptrace(PTRACE_GET_SYSCALL_INFO, 156 + pid, size, 157 + (unsigned long) &info))) { 158 + LOG_KILL_TRACEE("PTRACE_GET_SYSCALL_INFO: %m"); 159 + } 160 + ASSERT_EQ(expected_none_size, rc) { 161 + LOG_KILL_TRACEE("signal stop mismatch"); 162 + } 163 + ASSERT_EQ(PTRACE_SYSCALL_INFO_NONE, info.op) { 164 + LOG_KILL_TRACEE("signal stop mismatch"); 165 + } 166 + ASSERT_TRUE(info.arch) { 167 + LOG_KILL_TRACEE("signal stop mismatch"); 168 + } 169 + ASSERT_TRUE(info.instruction_pointer) { 170 + LOG_KILL_TRACEE("signal stop mismatch"); 171 + } 172 + ASSERT_TRUE(info.stack_pointer) { 173 + LOG_KILL_TRACEE("signal stop mismatch"); 174 + } 175 + break; 176 + 177 + case SIGTRAP | 0x80: 178 + ASSERT_LT(0, (rc = sys_ptrace(PTRACE_GET_SYSCALL_INFO, 179 + pid, size, 180 + (unsigned long) &info))) { 181 + LOG_KILL_TRACEE("PTRACE_GET_SYSCALL_INFO: %m"); 182 + } 183 + switch (ptrace_stop) { 184 + case 1: /* entering chdir */ 185 + case 3: /* entering gettid */ 186 + case 5: /* entering exit_group */ 187 + exp_args = args[ptrace_stop / 2]; 188 + ASSERT_EQ(expected_entry_size, rc) { 189 + LOG_KILL_TRACEE("entry stop mismatch"); 190 + } 191 + ASSERT_EQ(PTRACE_SYSCALL_INFO_ENTRY, info.op) { 192 + LOG_KILL_TRACEE("entry stop mismatch"); 193 + } 194 + ASSERT_TRUE(info.arch) { 195 + LOG_KILL_TRACEE("entry stop mismatch"); 196 + } 197 + ASSERT_TRUE(info.instruction_pointer) { 198 + LOG_KILL_TRACEE("entry stop mismatch"); 199 + } 200 + ASSERT_TRUE(info.stack_pointer) { 201 + LOG_KILL_TRACEE("entry stop mismatch"); 202 + } 203 + ASSERT_EQ(exp_args[0], info.entry.nr) { 204 + LOG_KILL_TRACEE("entry stop mismatch"); 205 + } 206 + ASSERT_EQ(exp_args[1], info.entry.args[0]) { 207 + LOG_KILL_TRACEE("entry stop mismatch"); 208 + } 209 + ASSERT_EQ(exp_args[2], info.entry.args[1]) { 210 + LOG_KILL_TRACEE("entry stop mismatch"); 211 + } 212 + ASSERT_EQ(exp_args[3], info.entry.args[2]) { 213 + LOG_KILL_TRACEE("entry stop mismatch"); 214 + } 215 + ASSERT_EQ(exp_args[4], info.entry.args[3]) { 216 + LOG_KILL_TRACEE("entry stop mismatch"); 217 + } 218 + ASSERT_EQ(exp_args[5], info.entry.args[4]) { 219 + LOG_KILL_TRACEE("entry stop mismatch"); 220 + } 221 + ASSERT_EQ(exp_args[6], info.entry.args[5]) { 222 + LOG_KILL_TRACEE("entry stop mismatch"); 223 + } 224 + break; 225 + case 2: /* exiting chdir */ 226 + case 4: /* exiting gettid */ 227 + exp_param = &exit_param[ptrace_stop / 2 - 1]; 228 + ASSERT_EQ(expected_exit_size, rc) { 229 + LOG_KILL_TRACEE("exit stop mismatch"); 230 + } 231 + ASSERT_EQ(PTRACE_SYSCALL_INFO_EXIT, info.op) { 232 + LOG_KILL_TRACEE("exit stop mismatch"); 233 + } 234 + ASSERT_TRUE(info.arch) { 235 + LOG_KILL_TRACEE("exit stop mismatch"); 236 + } 237 + ASSERT_TRUE(info.instruction_pointer) { 238 + LOG_KILL_TRACEE("exit stop mismatch"); 239 + } 240 + ASSERT_TRUE(info.stack_pointer) { 241 + LOG_KILL_TRACEE("exit stop mismatch"); 242 + } 243 + ASSERT_EQ(exp_param->is_error, 244 + info.exit.is_error) { 245 + LOG_KILL_TRACEE("exit stop mismatch"); 246 + } 247 + ASSERT_EQ(exp_param->rval, info.exit.rval) { 248 + LOG_KILL_TRACEE("exit stop mismatch"); 249 + } 250 + break; 251 + default: 252 + LOG_KILL_TRACEE("unexpected syscall stop"); 253 + abort(); 254 + } 255 + break; 256 + 257 + default: 258 + LOG_KILL_TRACEE("unexpected stop signal %#x", 259 + WSTOPSIG(status)); 260 + abort(); 261 + } 262 + 263 + ASSERT_EQ(0, sys_ptrace(PTRACE_SYSCALL, pid, 0, 0)) { 264 + LOG_KILL_TRACEE("PTRACE_SYSCALL: %m"); 265 + } 266 + } 267 + 268 + ASSERT_EQ(ARRAY_SIZE(args) * 2, ptrace_stop); 269 + } 270 + 271 + TEST_HARNESS_MAIN
+9 -4
tools/testing/selftests/seccomp/seccomp_bpf.c
··· 1775 1775 unsigned long msg; 1776 1776 static bool entry; 1777 1777 1778 - /* Make sure we got an empty message. */ 1778 + /* 1779 + * The traditional way to tell PTRACE_SYSCALL entry/exit 1780 + * is by counting. 1781 + */ 1782 + entry = !entry; 1783 + 1784 + /* Make sure we got an appropriate message. */ 1779 1785 ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg); 1780 1786 EXPECT_EQ(0, ret); 1781 - EXPECT_EQ(0, msg); 1787 + EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY 1788 + : PTRACE_EVENTMSG_SYSCALL_EXIT, msg); 1782 1789 1783 - /* The only way to tell PTRACE_SYSCALL entry/exit is by counting. */ 1784 - entry = !entry; 1785 1790 if (!entry) 1786 1791 return; 1787 1792