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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 's390-6.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull more s390 updates from Alexander Gordeev:

- Switch read and write software bits for PUDs

- Add missing hardware bits for PUDs and PMDs

- Generate unwind information for C modules to fix GDB unwind error for
vDSO functions

- Create .build-id links for unstripped vDSO files to enable vDSO
debugging with symbols

- Use standard stack frame layout for vDSO generated stack frames to
manually walk stack frames without DWARF information

- Rework perf_callchain_user() and arch_stack_walk_user() functions to
reduce code duplication

- Skip first stack frame when walking user stack

- Add basic checks to identify invalid instruction pointers when
walking stack frames

- Introduce and use struct stack_frame_vdso_wrapper within vDSO user
wrapper code to automatically generate an asm-offset define. Also use
STACK_FRAME_USER_OVERHEAD instead of STACK_FRAME_OVERHEAD to document
that the code works with user space stack

- Clear the backchain of the extra stack frame added by the vDSO user
wrapper code. This allows the user stack walker to detect and skip
the non-standard stack frame. Without this an incorrect instruction
pointer would be added to stack traces.

- Rewrite psw_idle() function in C to ease maintenance and further
enhancements

- Remove get_vtimer() function and use get_cpu_timer() instead

- Mark psw variable in __load_psw_mask() as __unitialized to avoid
superfluous clearing of PSW

- Remove obsolete and superfluous comment about removed TIF_FPU flag

- Replace memzero_explicit() and kfree() with kfree_sensitive() to fix
warnings reported by Coccinelle

- Wipe sensitive data and all copies of protected- or secure-keys from
stack when an IOCTL fails

- Both do_airq_interrupt() and do_io_interrupt() functions set
CIF_NOHZ_DELAY flag. Move it in do_io_irq() to simplify the code

- Provide iucv_alloc_device() and iucv_release_device() helpers, which
can be used to deduplicate more or less identical IUCV device
allocation and release code in four different drivers

- Make use of iucv_alloc_device() and iucv_release_device() helpers to
get rid of quite some code and also remove a cast to an incompatible
function (clang W=1)

- There is no user of iucv_root outside of the core IUCV code left.
Therefore remove the EXPORT_SYMBOL

- __apply_alternatives() contains a runtime check which verifies that
the size of the to be patched code area is even. Convert this to a
compile time check

- Increase size of buffers for sending z/VM CP DIAGNOSE X'008' commands
from 128 to 240

- Do not accept z/VM CP DIAGNOSE X'008' commands longer than maximally
allowed

- Use correct defines IPL_BP_NVME_LEN and IPL_BP0_NVME_LEN instead of
IPL_BP_FCP_LEN and IPL_BP0_FCP_LEN ones to initialize NVMe reIPL
block on 'scp_data' sysfs attribute update

- Initialize the correct fields of the NVMe dump block, which were
confused with FCP fields

- Refactor macros for 'scp_data' (re-)IPL sysfs attribute to reduce
code duplication

- Introduce 'scp_data' sysfs attribute for dump IPL to allow tools such
as dumpconf passing additional kernel command line parameters to a
stand-alone dumper

- Rework the CPACF query functions to use the correct RRE or RRF
instruction formats and set instruction register fields correctly

- Instead of calling BUG() at runtime force a link error during compile
when a unsupported opcode is used with __cpacf_query() or
__cpacf_check_opcode() functions

- Fix a crash in ap_parse_bitmap_str() function on /sys/bus/ap/apmask
or /sys/bus/ap/aqmask sysfs file update with a relative mask value

- Fix "bindings complete" udev event which should be sent once all AP
devices have been bound to device drivers and again when unbind/bind
actions take place and all AP devices are bound again

- Facility list alt_stfle_fac_list is nowhere used in the decompressor,
therefore remove it there

- Remove custom kprobes insn slot allocator in favour of the standard
module_alloc() one, since kernel image and module areas are located
within 4GB

- Use kvcalloc() instead of kvmalloc_array() in zcrypt driver to avoid
calling memset() with a large byte count and get rid of the sparse
warning as result

* tag 's390-6.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (39 commits)
s390/zcrypt: Use kvcalloc() instead of kvmalloc_array()
s390/kprobes: Remove custom insn slot allocator
s390/boot: Remove alt_stfle_fac_list from decompressor
s390/ap: Fix bind complete udev event sent after each AP bus scan
s390/ap: Fix crash in AP internal function modify_bitmap()
s390/cpacf: Make use of invalid opcode produce a link error
s390/cpacf: Split and rework cpacf query functions
s390/ipl: Introduce sysfs attribute 'scp_data' for dump ipl
s390/ipl: Introduce macros for (re)ipl sysfs attribute 'scp_data'
s390/ipl: Fix incorrect initialization of nvme dump block
s390/ipl: Fix incorrect initialization of len fields in nvme reipl block
s390/ipl: Do not accept z/VM CP diag X'008' cmds longer than max length
s390/ipl: Fix size of vmcmd buffers for sending z/VM CP diag X'008' cmds
s390/alternatives: Convert runtime sanity check into compile time check
s390/iucv: Unexport iucv_root
tty: hvc-iucv: Make use of iucv_alloc_device()
s390/smsgiucv_app: Make use of iucv_alloc_device()
s390/netiucv: Make use of iucv_alloc_device()
s390/vmlogrdr: Make use of iucv_alloc_device()
s390/iucv: Provide iucv_alloc_device() / iucv_release_device()
...

+517 -555
-1
arch/s390/boot/startup.c
··· 32 32 unsigned long __bootdata_preserved(max_mappable); 33 33 34 34 u64 __bootdata_preserved(stfle_fac_list[16]); 35 - u64 __bootdata_preserved(alt_stfle_fac_list[16]); 36 35 struct oldmem_data __bootdata_preserved(oldmem_data); 37 36 38 37 struct machine_info machine;
+1
arch/s390/include/asm/alternative-asm.h
··· 15 15 .long \alt_start - . 16 16 .word \feature 17 17 .byte \orig_end - \orig_start 18 + .org . - ( \orig_end - \orig_start ) & 1 18 19 .org . - ( \orig_end - \orig_start ) + ( \alt_end - \alt_start ) 19 20 .org . - ( \alt_end - \alt_start ) + ( \orig_end - \orig_start ) 20 21 .endm
+1
arch/s390/include/asm/alternative.h
··· 53 53 "\t.long " b_altinstr(num)"b - .\n" /* alt instruction */ \ 54 54 "\t.word " __stringify(facility) "\n" /* facility bit */ \ 55 55 "\t.byte " oldinstr_len "\n" /* instruction len */ \ 56 + "\t.org . - (" oldinstr_len ") & 1\n" \ 56 57 "\t.org . - (" oldinstr_len ") + (" altinstr_len(num) ")\n" \ 57 58 "\t.org . - (" altinstr_len(num) ") + (" oldinstr_len ")\n" 58 59
+89 -20
arch/s390/include/asm/cpacf.h
··· 166 166 167 167 typedef struct { unsigned char bytes[16]; } cpacf_mask_t; 168 168 169 - /** 170 - * cpacf_query() - check if a specific CPACF function is available 171 - * @opcode: the opcode of the crypto instruction 172 - * @func: the function code to test for 173 - * 174 - * Executes the query function for the given crypto instruction @opcode 175 - * and checks if @func is available 176 - * 177 - * Returns 1 if @func is available for @opcode, 0 otherwise 169 + /* 170 + * Prototype for a not existing function to produce a link 171 + * error if __cpacf_query() or __cpacf_check_opcode() is used 172 + * with an invalid compile time const opcode. 178 173 */ 179 - static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mask) 174 + void __cpacf_bad_opcode(void); 175 + 176 + static __always_inline void __cpacf_query_rre(u32 opc, u8 r1, u8 r2, 177 + cpacf_mask_t *mask) 180 178 { 181 179 asm volatile( 182 - " lghi 0,0\n" /* query function */ 183 - " lgr 1,%[mask]\n" 184 - " spm 0\n" /* pckmo doesn't change the cc */ 185 - /* Parameter regs are ignored, but must be nonzero and unique */ 186 - "0: .insn rrf,%[opc] << 16,2,4,6,0\n" 187 - " brc 1,0b\n" /* handle partial completion */ 188 - : "=m" (*mask) 189 - : [mask] "d" ((unsigned long)mask), [opc] "i" (opcode) 190 - : "cc", "0", "1"); 180 + " la %%r1,%[mask]\n" 181 + " xgr %%r0,%%r0\n" 182 + " .insn rre,%[opc] << 16,%[r1],%[r2]\n" 183 + : [mask] "=R" (*mask) 184 + : [opc] "i" (opc), 185 + [r1] "i" (r1), [r2] "i" (r2) 186 + : "cc", "r0", "r1"); 187 + } 188 + 189 + static __always_inline void __cpacf_query_rrf(u32 opc, 190 + u8 r1, u8 r2, u8 r3, u8 m4, 191 + cpacf_mask_t *mask) 192 + { 193 + asm volatile( 194 + " la %%r1,%[mask]\n" 195 + " xgr %%r0,%%r0\n" 196 + " .insn rrf,%[opc] << 16,%[r1],%[r2],%[r3],%[m4]\n" 197 + : [mask] "=R" (*mask) 198 + : [opc] "i" (opc), [r1] "i" (r1), [r2] "i" (r2), 199 + [r3] "i" (r3), [m4] "i" (m4) 200 + : "cc", "r0", "r1"); 201 + } 202 + 203 + static __always_inline void __cpacf_query(unsigned int opcode, 204 + cpacf_mask_t *mask) 205 + { 206 + switch (opcode) { 207 + case CPACF_KDSA: 208 + __cpacf_query_rre(CPACF_KDSA, 0, 2, mask); 209 + break; 210 + case CPACF_KIMD: 211 + __cpacf_query_rre(CPACF_KIMD, 0, 2, mask); 212 + break; 213 + case CPACF_KLMD: 214 + __cpacf_query_rre(CPACF_KLMD, 0, 2, mask); 215 + break; 216 + case CPACF_KM: 217 + __cpacf_query_rre(CPACF_KM, 2, 4, mask); 218 + break; 219 + case CPACF_KMA: 220 + __cpacf_query_rrf(CPACF_KMA, 2, 4, 6, 0, mask); 221 + break; 222 + case CPACF_KMAC: 223 + __cpacf_query_rre(CPACF_KMAC, 0, 2, mask); 224 + break; 225 + case CPACF_KMC: 226 + __cpacf_query_rre(CPACF_KMC, 2, 4, mask); 227 + break; 228 + case CPACF_KMCTR: 229 + __cpacf_query_rrf(CPACF_KMCTR, 2, 4, 6, 0, mask); 230 + break; 231 + case CPACF_KMF: 232 + __cpacf_query_rre(CPACF_KMF, 2, 4, mask); 233 + break; 234 + case CPACF_KMO: 235 + __cpacf_query_rre(CPACF_KMO, 2, 4, mask); 236 + break; 237 + case CPACF_PCC: 238 + __cpacf_query_rre(CPACF_PCC, 0, 0, mask); 239 + break; 240 + case CPACF_PCKMO: 241 + __cpacf_query_rre(CPACF_PCKMO, 0, 0, mask); 242 + break; 243 + case CPACF_PRNO: 244 + __cpacf_query_rre(CPACF_PRNO, 2, 4, mask); 245 + break; 246 + default: 247 + __cpacf_bad_opcode(); 248 + } 191 249 } 192 250 193 251 static __always_inline int __cpacf_check_opcode(unsigned int opcode) ··· 269 211 case CPACF_KMA: 270 212 return test_facility(146); /* check for MSA8 */ 271 213 default: 272 - BUG(); 214 + __cpacf_bad_opcode(); 215 + return 0; 273 216 } 274 217 } 275 218 219 + /** 220 + * cpacf_query() - check if a specific CPACF function is available 221 + * @opcode: the opcode of the crypto instruction 222 + * @func: the function code to test for 223 + * 224 + * Executes the query function for the given crypto instruction @opcode 225 + * and checks if @func is available 226 + * 227 + * Returns 1 if @func is available for @opcode, 0 otherwise 228 + */ 276 229 static __always_inline int cpacf_query(unsigned int opcode, cpacf_mask_t *mask) 277 230 { 278 231 if (__cpacf_check_opcode(opcode)) {
+7 -5
arch/s390/include/asm/pgtable.h
··· 268 268 #define _REGION3_ENTRY (_REGION_ENTRY_TYPE_R3 | _REGION_ENTRY_LENGTH) 269 269 #define _REGION3_ENTRY_EMPTY (_REGION_ENTRY_TYPE_R3 | _REGION_ENTRY_INVALID) 270 270 271 + #define _REGION3_ENTRY_HARDWARE_BITS 0xfffffffffffff6ffUL 272 + #define _REGION3_ENTRY_HARDWARE_BITS_LARGE 0xffffffff8001073cUL 271 273 #define _REGION3_ENTRY_ORIGIN_LARGE ~0x7fffffffUL /* large page address */ 272 274 #define _REGION3_ENTRY_DIRTY 0x2000 /* SW region dirty bit */ 273 275 #define _REGION3_ENTRY_YOUNG 0x1000 /* SW region young bit */ 274 276 #define _REGION3_ENTRY_LARGE 0x0400 /* RTTE-format control, large page */ 275 - #define _REGION3_ENTRY_READ 0x0002 /* SW region read bit */ 276 - #define _REGION3_ENTRY_WRITE 0x0001 /* SW region write bit */ 277 + #define _REGION3_ENTRY_WRITE 0x0002 /* SW region write bit */ 278 + #define _REGION3_ENTRY_READ 0x0001 /* SW region read bit */ 277 279 278 280 #ifdef CONFIG_MEM_SOFT_DIRTY 279 281 #define _REGION3_ENTRY_SOFT_DIRTY 0x4000 /* SW region soft dirty bit */ ··· 286 284 #define _REGION_ENTRY_BITS 0xfffffffffffff22fUL 287 285 288 286 /* Bits in the segment table entry */ 289 - #define _SEGMENT_ENTRY_BITS 0xfffffffffffffe33UL 290 - #define _SEGMENT_ENTRY_HARDWARE_BITS 0xfffffffffffffe30UL 291 - #define _SEGMENT_ENTRY_HARDWARE_BITS_LARGE 0xfffffffffff00730UL 287 + #define _SEGMENT_ENTRY_BITS 0xfffffffffffffe3fUL 288 + #define _SEGMENT_ENTRY_HARDWARE_BITS 0xfffffffffffffe3cUL 289 + #define _SEGMENT_ENTRY_HARDWARE_BITS_LARGE 0xfffffffffff1073cUL 292 290 #define _SEGMENT_ENTRY_ORIGIN_LARGE ~0xfffffUL /* large page address */ 293 291 #define _SEGMENT_ENTRY_ORIGIN ~0x7ffUL/* page table origin */ 294 292 #define _SEGMENT_ENTRY_PROTECT 0x200 /* segment protection bit */
+16 -1
arch/s390/include/asm/processor.h
··· 40 40 #include <asm/setup.h> 41 41 #include <asm/runtime_instr.h> 42 42 #include <asm/irqflags.h> 43 + #include <asm/alternative.h> 43 44 44 45 typedef long (*sys_call_ptr_t)(struct pt_regs *regs); 45 46 ··· 93 92 asm volatile("stidp %0" : "=Q" (*ptr)); 94 93 } 95 94 95 + static __always_inline unsigned long get_cpu_timer(void) 96 + { 97 + unsigned long timer; 98 + 99 + asm volatile("stpt %[timer]" : [timer] "=Q" (timer)); 100 + return timer; 101 + } 102 + 96 103 void s390_adjust_jiffies(void); 97 104 void s390_update_cpu_mhz(void); 98 105 void cpu_detect_mhz_feature(void); 99 106 100 107 extern const struct seq_operations cpuinfo_op; 101 108 extern void execve_tail(void); 109 + unsigned long vdso_text_size(void); 102 110 unsigned long vdso_size(void); 103 111 104 112 /* ··· 314 304 */ 315 305 static __always_inline void __load_psw_mask(unsigned long mask) 316 306 { 307 + psw_t psw __uninitialized; 317 308 unsigned long addr; 318 - psw_t psw; 319 309 320 310 psw.mask = mask; 321 311 ··· 401 391 static __always_inline bool regs_irqs_disabled(struct pt_regs *regs) 402 392 { 403 393 return arch_irqs_disabled_flags(regs->psw.mask); 394 + } 395 + 396 + static __always_inline void bpon(void) 397 + { 398 + asm volatile(ALTERNATIVE("nop", ".insn rrf,0xb2e80000,0,0,13,0", 82)); 404 399 } 405 400 406 401 #endif /* __ASSEMBLY__ */
+12
arch/s390/include/asm/stacktrace.h
··· 2 2 #ifndef _ASM_S390_STACKTRACE_H 3 3 #define _ASM_S390_STACKTRACE_H 4 4 5 + #include <linux/stacktrace.h> 5 6 #include <linux/uaccess.h> 6 7 #include <linux/ptrace.h> 7 8 ··· 12 11 unsigned long gprs[10]; 13 12 unsigned long empty2[4]; 14 13 }; 14 + 15 + struct stack_frame_vdso_wrapper { 16 + struct stack_frame_user sf; 17 + unsigned long return_address; 18 + }; 19 + 20 + struct perf_callchain_entry_ctx; 21 + 22 + void arch_stack_walk_user_common(stack_trace_consume_fn consume_entry, void *cookie, 23 + struct perf_callchain_entry_ctx *entry, 24 + const struct pt_regs *regs, bool perf); 15 25 16 26 enum stack_type { 17 27 STACK_TYPE_UNKNOWN,
-1
arch/s390/kernel/Makefile
··· 59 59 obj-$(CONFIG_COMPAT) += $(compat-obj-y) 60 60 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 61 61 obj-$(CONFIG_KPROBES) += kprobes.o 62 - obj-$(CONFIG_KPROBES) += kprobes_insn_page.o 63 62 obj-$(CONFIG_KPROBES) += mcount.o 64 63 obj-$(CONFIG_RETHOOK) += rethook.o 65 64 obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o
-7
arch/s390/kernel/alternative.c
··· 33 33 34 34 if (!__test_facility(a->facility, alt_stfle_fac_list)) 35 35 continue; 36 - 37 - if (unlikely(a->instrlen % 2)) { 38 - WARN_ONCE(1, "cpu alternatives instructions length is " 39 - "odd, skipping patching\n"); 40 - continue; 41 - } 42 - 43 36 s390_kernel_write(instr, replacement, a->instrlen); 44 37 } 45 38 }
+4 -5
arch/s390/kernel/asm-offsets.c
··· 13 13 #include <linux/purgatory.h> 14 14 #include <linux/pgtable.h> 15 15 #include <linux/ftrace.h> 16 - #include <asm/idle.h> 17 16 #include <asm/gmap.h> 18 17 #include <asm/stacktrace.h> 19 18 ··· 65 66 OFFSET(__SF_SIE_CONTROL_PHYS, stack_frame, sie_control_block_phys); 66 67 DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame)); 67 68 BLANK(); 68 - /* idle data offsets */ 69 - OFFSET(__CLOCK_IDLE_ENTER, s390_idle_data, clock_idle_enter); 70 - OFFSET(__TIMER_IDLE_ENTER, s390_idle_data, timer_idle_enter); 71 - OFFSET(__MT_CYCLES_ENTER, s390_idle_data, mt_cycles_enter); 69 + OFFSET(__SFUSER_BACKCHAIN, stack_frame_user, back_chain); 70 + DEFINE(STACK_FRAME_USER_OVERHEAD, sizeof(struct stack_frame_user)); 71 + OFFSET(__SFVDSO_RETURN_ADDRESS, stack_frame_vdso_wrapper, return_address); 72 + DEFINE(STACK_FRAME_VDSO_OVERHEAD, sizeof(struct stack_frame_vdso_wrapper)); 72 73 BLANK(); 73 74 /* hardware defined lowcore locations 0x000 - 0x1ff */ 74 75 OFFSET(__LC_EXT_PARAMS, lowcore, ext_params);
-23
arch/s390/kernel/entry.S
··· 441 441 INT_HANDLER io_int_handler,__LC_IO_OLD_PSW,do_io_irq 442 442 443 443 /* 444 - * Load idle PSW. 445 - */ 446 - SYM_FUNC_START(psw_idle) 447 - stg %r14,(__SF_GPRS+8*8)(%r15) 448 - stg %r3,__SF_EMPTY(%r15) 449 - larl %r1,psw_idle_exit 450 - stg %r1,__SF_EMPTY+8(%r15) 451 - larl %r1,smp_cpu_mtid 452 - llgf %r1,0(%r1) 453 - ltgr %r1,%r1 454 - jz .Lpsw_idle_stcctm 455 - .insn rsy,0xeb0000000017,%r1,5,__MT_CYCLES_ENTER(%r2) 456 - .Lpsw_idle_stcctm: 457 - oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT 458 - BPON 459 - stckf __CLOCK_IDLE_ENTER(%r2) 460 - stpt __TIMER_IDLE_ENTER(%r2) 461 - lpswe __SF_EMPTY(%r15) 462 - SYM_INNER_LABEL(psw_idle_exit, SYM_L_GLOBAL) 463 - BR_EX %r14 464 - SYM_FUNC_END(psw_idle) 465 - 466 - /* 467 444 * Machine check handler routines 468 445 */ 469 446 SYM_CODE_START(mcck_int_handler)
+7 -3
arch/s390/kernel/idle.c
··· 57 57 psw_mask = PSW_KERNEL_BITS | PSW_MASK_WAIT | 58 58 PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK; 59 59 clear_cpu_flag(CIF_NOHZ_DELAY); 60 - 61 - /* psw_idle() returns with interrupts disabled. */ 62 - psw_idle(idle, psw_mask); 60 + set_cpu_flag(CIF_ENABLED_WAIT); 61 + if (smp_cpu_mtid) 62 + stcctm(MT_DIAG, smp_cpu_mtid, (u64 *)&idle->mt_cycles_enter); 63 + idle->clock_idle_enter = get_tod_clock_fast(); 64 + idle->timer_idle_enter = get_cpu_timer(); 65 + bpon(); 66 + __load_psw_mask(psw_mask); 63 67 } 64 68 65 69 static ssize_t show_idle_count(struct device *dev,
+139 -180
arch/s390/kernel/ipl.c
··· 267 267 struct kobj_attribute *attr, \ 268 268 const char *buf, size_t len) \ 269 269 { \ 270 - strscpy(_value, buf, sizeof(_value)); \ 270 + if (len >= sizeof(_value)) \ 271 + return -E2BIG; \ 272 + len = strscpy(_value, buf, sizeof(_value)); \ 273 + if (len < 0) \ 274 + return len; \ 271 275 strim(_value); \ 272 276 return len; \ 273 277 } \ ··· 279 275 __ATTR(_name, 0644, \ 280 276 sys_##_prefix##_##_name##_show, \ 281 277 sys_##_prefix##_##_name##_store) 278 + 279 + #define IPL_ATTR_SCP_DATA_SHOW_FN(_prefix, _ipl_block) \ 280 + static ssize_t sys_##_prefix##_scp_data_show(struct file *filp, \ 281 + struct kobject *kobj, \ 282 + struct bin_attribute *attr, \ 283 + char *buf, loff_t off, \ 284 + size_t count) \ 285 + { \ 286 + size_t size = _ipl_block.scp_data_len; \ 287 + void *scp_data = _ipl_block.scp_data; \ 288 + \ 289 + return memory_read_from_buffer(buf, count, &off, \ 290 + scp_data, size); \ 291 + } 292 + 293 + #define IPL_ATTR_SCP_DATA_STORE_FN(_prefix, _ipl_block_hdr, _ipl_block, _ipl_bp_len, _ipl_bp0_len)\ 294 + static ssize_t sys_##_prefix##_scp_data_store(struct file *filp, \ 295 + struct kobject *kobj, \ 296 + struct bin_attribute *attr, \ 297 + char *buf, loff_t off, \ 298 + size_t count) \ 299 + { \ 300 + size_t scpdata_len = count; \ 301 + size_t padding; \ 302 + \ 303 + if (off) \ 304 + return -EINVAL; \ 305 + \ 306 + memcpy(_ipl_block.scp_data, buf, count); \ 307 + if (scpdata_len % 8) { \ 308 + padding = 8 - (scpdata_len % 8); \ 309 + memset(_ipl_block.scp_data + scpdata_len, \ 310 + 0, padding); \ 311 + scpdata_len += padding; \ 312 + } \ 313 + \ 314 + _ipl_block_hdr.len = _ipl_bp_len + scpdata_len; \ 315 + _ipl_block.len = _ipl_bp0_len + scpdata_len; \ 316 + _ipl_block.scp_data_len = scpdata_len; \ 317 + \ 318 + return count; \ 319 + } 320 + 321 + #define DEFINE_IPL_ATTR_SCP_DATA_RO(_prefix, _ipl_block, _size) \ 322 + IPL_ATTR_SCP_DATA_SHOW_FN(_prefix, _ipl_block) \ 323 + static struct bin_attribute sys_##_prefix##_scp_data_attr = \ 324 + __BIN_ATTR(scp_data, 0444, sys_##_prefix##_scp_data_show, \ 325 + NULL, _size) 326 + 327 + #define DEFINE_IPL_ATTR_SCP_DATA_RW(_prefix, _ipl_block_hdr, _ipl_block, _ipl_bp_len, _ipl_bp0_len, _size)\ 328 + IPL_ATTR_SCP_DATA_SHOW_FN(_prefix, _ipl_block) \ 329 + IPL_ATTR_SCP_DATA_STORE_FN(_prefix, _ipl_block_hdr, _ipl_block, _ipl_bp_len, _ipl_bp0_len)\ 330 + static struct bin_attribute sys_##_prefix##_scp_data_attr = \ 331 + __BIN_ATTR(scp_data, 0644, sys_##_prefix##_scp_data_show, \ 332 + sys_##_prefix##_scp_data_store, _size) 282 333 283 334 /* 284 335 * ipl section ··· 433 374 static struct kobj_attribute sys_ipl_device_attr = 434 375 __ATTR(device, 0444, sys_ipl_device_show, NULL); 435 376 436 - static ssize_t ipl_parameter_read(struct file *filp, struct kobject *kobj, 437 - struct bin_attribute *attr, char *buf, 438 - loff_t off, size_t count) 377 + static ssize_t sys_ipl_parameter_read(struct file *filp, struct kobject *kobj, 378 + struct bin_attribute *attr, char *buf, 379 + loff_t off, size_t count) 439 380 { 440 381 return memory_read_from_buffer(buf, count, &off, &ipl_block, 441 382 ipl_block.hdr.len); 442 383 } 443 - static struct bin_attribute ipl_parameter_attr = 444 - __BIN_ATTR(binary_parameter, 0444, ipl_parameter_read, NULL, 384 + static struct bin_attribute sys_ipl_parameter_attr = 385 + __BIN_ATTR(binary_parameter, 0444, sys_ipl_parameter_read, NULL, 445 386 PAGE_SIZE); 446 387 447 - static ssize_t ipl_scp_data_read(struct file *filp, struct kobject *kobj, 448 - struct bin_attribute *attr, char *buf, 449 - loff_t off, size_t count) 450 - { 451 - unsigned int size = ipl_block.fcp.scp_data_len; 452 - void *scp_data = &ipl_block.fcp.scp_data; 453 - 454 - return memory_read_from_buffer(buf, count, &off, scp_data, size); 455 - } 456 - 457 - static ssize_t ipl_nvme_scp_data_read(struct file *filp, struct kobject *kobj, 458 - struct bin_attribute *attr, char *buf, 459 - loff_t off, size_t count) 460 - { 461 - unsigned int size = ipl_block.nvme.scp_data_len; 462 - void *scp_data = &ipl_block.nvme.scp_data; 463 - 464 - return memory_read_from_buffer(buf, count, &off, scp_data, size); 465 - } 466 - 467 - static ssize_t ipl_eckd_scp_data_read(struct file *filp, struct kobject *kobj, 468 - struct bin_attribute *attr, char *buf, 469 - loff_t off, size_t count) 470 - { 471 - unsigned int size = ipl_block.eckd.scp_data_len; 472 - void *scp_data = &ipl_block.eckd.scp_data; 473 - 474 - return memory_read_from_buffer(buf, count, &off, scp_data, size); 475 - } 476 - 477 - static struct bin_attribute ipl_scp_data_attr = 478 - __BIN_ATTR(scp_data, 0444, ipl_scp_data_read, NULL, PAGE_SIZE); 479 - 480 - static struct bin_attribute ipl_nvme_scp_data_attr = 481 - __BIN_ATTR(scp_data, 0444, ipl_nvme_scp_data_read, NULL, PAGE_SIZE); 482 - 483 - static struct bin_attribute ipl_eckd_scp_data_attr = 484 - __BIN_ATTR(scp_data, 0444, ipl_eckd_scp_data_read, NULL, PAGE_SIZE); 388 + DEFINE_IPL_ATTR_SCP_DATA_RO(ipl_fcp, ipl_block.fcp, PAGE_SIZE); 485 389 486 390 static struct bin_attribute *ipl_fcp_bin_attrs[] = { 487 - &ipl_parameter_attr, 488 - &ipl_scp_data_attr, 391 + &sys_ipl_parameter_attr, 392 + &sys_ipl_fcp_scp_data_attr, 489 393 NULL, 490 394 }; 395 + 396 + DEFINE_IPL_ATTR_SCP_DATA_RO(ipl_nvme, ipl_block.nvme, PAGE_SIZE); 491 397 492 398 static struct bin_attribute *ipl_nvme_bin_attrs[] = { 493 - &ipl_parameter_attr, 494 - &ipl_nvme_scp_data_attr, 399 + &sys_ipl_parameter_attr, 400 + &sys_ipl_nvme_scp_data_attr, 495 401 NULL, 496 402 }; 497 403 404 + DEFINE_IPL_ATTR_SCP_DATA_RO(ipl_eckd, ipl_block.eckd, PAGE_SIZE); 405 + 498 406 static struct bin_attribute *ipl_eckd_bin_attrs[] = { 499 - &ipl_parameter_attr, 500 - &ipl_eckd_scp_data_attr, 407 + &sys_ipl_parameter_attr, 408 + &sys_ipl_eckd_scp_data_attr, 501 409 NULL, 502 410 }; 503 411 ··· 803 777 804 778 /* FCP reipl device attributes */ 805 779 806 - static ssize_t reipl_fcp_scpdata_read(struct file *filp, struct kobject *kobj, 807 - struct bin_attribute *attr, 808 - char *buf, loff_t off, size_t count) 809 - { 810 - size_t size = reipl_block_fcp->fcp.scp_data_len; 811 - void *scp_data = reipl_block_fcp->fcp.scp_data; 812 - 813 - return memory_read_from_buffer(buf, count, &off, scp_data, size); 814 - } 815 - 816 - static ssize_t reipl_fcp_scpdata_write(struct file *filp, struct kobject *kobj, 817 - struct bin_attribute *attr, 818 - char *buf, loff_t off, size_t count) 819 - { 820 - size_t scpdata_len = count; 821 - size_t padding; 822 - 823 - 824 - if (off) 825 - return -EINVAL; 826 - 827 - memcpy(reipl_block_fcp->fcp.scp_data, buf, count); 828 - if (scpdata_len % 8) { 829 - padding = 8 - (scpdata_len % 8); 830 - memset(reipl_block_fcp->fcp.scp_data + scpdata_len, 831 - 0, padding); 832 - scpdata_len += padding; 833 - } 834 - 835 - reipl_block_fcp->hdr.len = IPL_BP_FCP_LEN + scpdata_len; 836 - reipl_block_fcp->fcp.len = IPL_BP0_FCP_LEN + scpdata_len; 837 - reipl_block_fcp->fcp.scp_data_len = scpdata_len; 838 - 839 - return count; 840 - } 841 - static struct bin_attribute sys_reipl_fcp_scp_data_attr = 842 - __BIN_ATTR(scp_data, 0644, reipl_fcp_scpdata_read, 843 - reipl_fcp_scpdata_write, DIAG308_SCPDATA_SIZE); 780 + DEFINE_IPL_ATTR_SCP_DATA_RW(reipl_fcp, reipl_block_fcp->hdr, 781 + reipl_block_fcp->fcp, 782 + IPL_BP_FCP_LEN, IPL_BP0_FCP_LEN, 783 + DIAG308_SCPDATA_SIZE); 844 784 845 785 static struct bin_attribute *reipl_fcp_bin_attrs[] = { 846 786 &sys_reipl_fcp_scp_data_attr, ··· 927 935 928 936 /* NVME reipl device attributes */ 929 937 930 - static ssize_t reipl_nvme_scpdata_read(struct file *filp, struct kobject *kobj, 931 - struct bin_attribute *attr, 932 - char *buf, loff_t off, size_t count) 933 - { 934 - size_t size = reipl_block_nvme->nvme.scp_data_len; 935 - void *scp_data = reipl_block_nvme->nvme.scp_data; 936 - 937 - return memory_read_from_buffer(buf, count, &off, scp_data, size); 938 - } 939 - 940 - static ssize_t reipl_nvme_scpdata_write(struct file *filp, struct kobject *kobj, 941 - struct bin_attribute *attr, 942 - char *buf, loff_t off, size_t count) 943 - { 944 - size_t scpdata_len = count; 945 - size_t padding; 946 - 947 - if (off) 948 - return -EINVAL; 949 - 950 - memcpy(reipl_block_nvme->nvme.scp_data, buf, count); 951 - if (scpdata_len % 8) { 952 - padding = 8 - (scpdata_len % 8); 953 - memset(reipl_block_nvme->nvme.scp_data + scpdata_len, 954 - 0, padding); 955 - scpdata_len += padding; 956 - } 957 - 958 - reipl_block_nvme->hdr.len = IPL_BP_FCP_LEN + scpdata_len; 959 - reipl_block_nvme->nvme.len = IPL_BP0_FCP_LEN + scpdata_len; 960 - reipl_block_nvme->nvme.scp_data_len = scpdata_len; 961 - 962 - return count; 963 - } 964 - 965 - static struct bin_attribute sys_reipl_nvme_scp_data_attr = 966 - __BIN_ATTR(scp_data, 0644, reipl_nvme_scpdata_read, 967 - reipl_nvme_scpdata_write, DIAG308_SCPDATA_SIZE); 938 + DEFINE_IPL_ATTR_SCP_DATA_RW(reipl_nvme, reipl_block_nvme->hdr, 939 + reipl_block_nvme->nvme, 940 + IPL_BP_NVME_LEN, IPL_BP0_NVME_LEN, 941 + DIAG308_SCPDATA_SIZE); 968 942 969 943 static struct bin_attribute *reipl_nvme_bin_attrs[] = { 970 944 &sys_reipl_nvme_scp_data_attr, ··· 1026 1068 1027 1069 /* ECKD reipl device attributes */ 1028 1070 1029 - static ssize_t reipl_eckd_scpdata_read(struct file *filp, struct kobject *kobj, 1030 - struct bin_attribute *attr, 1031 - char *buf, loff_t off, size_t count) 1032 - { 1033 - size_t size = reipl_block_eckd->eckd.scp_data_len; 1034 - void *scp_data = reipl_block_eckd->eckd.scp_data; 1035 - 1036 - return memory_read_from_buffer(buf, count, &off, scp_data, size); 1037 - } 1038 - 1039 - static ssize_t reipl_eckd_scpdata_write(struct file *filp, struct kobject *kobj, 1040 - struct bin_attribute *attr, 1041 - char *buf, loff_t off, size_t count) 1042 - { 1043 - size_t scpdata_len = count; 1044 - size_t padding; 1045 - 1046 - if (off) 1047 - return -EINVAL; 1048 - 1049 - memcpy(reipl_block_eckd->eckd.scp_data, buf, count); 1050 - if (scpdata_len % 8) { 1051 - padding = 8 - (scpdata_len % 8); 1052 - memset(reipl_block_eckd->eckd.scp_data + scpdata_len, 1053 - 0, padding); 1054 - scpdata_len += padding; 1055 - } 1056 - 1057 - reipl_block_eckd->hdr.len = IPL_BP_ECKD_LEN + scpdata_len; 1058 - reipl_block_eckd->eckd.len = IPL_BP0_ECKD_LEN + scpdata_len; 1059 - reipl_block_eckd->eckd.scp_data_len = scpdata_len; 1060 - 1061 - return count; 1062 - } 1063 - 1064 - static struct bin_attribute sys_reipl_eckd_scp_data_attr = 1065 - __BIN_ATTR(scp_data, 0644, reipl_eckd_scpdata_read, 1066 - reipl_eckd_scpdata_write, DIAG308_SCPDATA_SIZE); 1071 + DEFINE_IPL_ATTR_SCP_DATA_RW(reipl_eckd, reipl_block_eckd->hdr, 1072 + reipl_block_eckd->eckd, 1073 + IPL_BP_ECKD_LEN, IPL_BP0_ECKD_LEN, 1074 + DIAG308_SCPDATA_SIZE); 1067 1075 1068 1076 static struct bin_attribute *reipl_eckd_bin_attrs[] = { 1069 1077 &sys_reipl_eckd_scp_data_attr, ··· 1573 1649 DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", 1574 1650 dump_block_fcp->fcp.devno); 1575 1651 1652 + DEFINE_IPL_ATTR_SCP_DATA_RW(dump_fcp, dump_block_fcp->hdr, 1653 + dump_block_fcp->fcp, 1654 + IPL_BP_FCP_LEN, IPL_BP0_FCP_LEN, 1655 + DIAG308_SCPDATA_SIZE); 1656 + 1576 1657 static struct attribute *dump_fcp_attrs[] = { 1577 1658 &sys_dump_fcp_device_attr.attr, 1578 1659 &sys_dump_fcp_wwpn_attr.attr, ··· 1587 1658 NULL, 1588 1659 }; 1589 1660 1661 + static struct bin_attribute *dump_fcp_bin_attrs[] = { 1662 + &sys_dump_fcp_scp_data_attr, 1663 + NULL, 1664 + }; 1665 + 1590 1666 static struct attribute_group dump_fcp_attr_group = { 1591 1667 .name = IPL_FCP_STR, 1592 1668 .attrs = dump_fcp_attrs, 1669 + .bin_attrs = dump_fcp_bin_attrs, 1593 1670 }; 1594 1671 1595 1672 /* NVME dump device attributes */ ··· 1608 1673 DEFINE_IPL_ATTR_RW(dump_nvme, br_lba, "%lld\n", "%llx\n", 1609 1674 dump_block_nvme->nvme.br_lba); 1610 1675 1676 + DEFINE_IPL_ATTR_SCP_DATA_RW(dump_nvme, dump_block_nvme->hdr, 1677 + dump_block_nvme->nvme, 1678 + IPL_BP_NVME_LEN, IPL_BP0_NVME_LEN, 1679 + DIAG308_SCPDATA_SIZE); 1680 + 1611 1681 static struct attribute *dump_nvme_attrs[] = { 1612 1682 &sys_dump_nvme_fid_attr.attr, 1613 1683 &sys_dump_nvme_nsid_attr.attr, ··· 1621 1681 NULL, 1622 1682 }; 1623 1683 1684 + static struct bin_attribute *dump_nvme_bin_attrs[] = { 1685 + &sys_dump_nvme_scp_data_attr, 1686 + NULL, 1687 + }; 1688 + 1624 1689 static struct attribute_group dump_nvme_attr_group = { 1625 1690 .name = IPL_NVME_STR, 1626 1691 .attrs = dump_nvme_attrs, 1692 + .bin_attrs = dump_nvme_bin_attrs, 1627 1693 }; 1628 1694 1629 1695 /* ECKD dump device attributes */ ··· 1643 1697 static struct kobj_attribute sys_dump_eckd_br_chr_attr = 1644 1698 __ATTR(br_chr, 0644, eckd_dump_br_chr_show, eckd_dump_br_chr_store); 1645 1699 1700 + DEFINE_IPL_ATTR_SCP_DATA_RW(dump_eckd, dump_block_eckd->hdr, 1701 + dump_block_eckd->eckd, 1702 + IPL_BP_ECKD_LEN, IPL_BP0_ECKD_LEN, 1703 + DIAG308_SCPDATA_SIZE); 1704 + 1646 1705 static struct attribute *dump_eckd_attrs[] = { 1647 1706 &sys_dump_eckd_device_attr.attr, 1648 1707 &sys_dump_eckd_bootprog_attr.attr, ··· 1655 1704 NULL, 1656 1705 }; 1657 1706 1707 + static struct bin_attribute *dump_eckd_bin_attrs[] = { 1708 + &sys_dump_eckd_scp_data_attr, 1709 + NULL, 1710 + }; 1711 + 1658 1712 static struct attribute_group dump_eckd_attr_group = { 1659 1713 .name = IPL_ECKD_STR, 1660 1714 .attrs = dump_eckd_attrs, 1715 + .bin_attrs = dump_eckd_bin_attrs, 1661 1716 }; 1662 1717 1663 1718 /* CCW dump device attributes */ ··· 1816 1859 } 1817 1860 dump_block_nvme->hdr.len = IPL_BP_NVME_LEN; 1818 1861 dump_block_nvme->hdr.version = IPL_PARM_BLOCK_VERSION; 1819 - dump_block_nvme->fcp.len = IPL_BP0_NVME_LEN; 1820 - dump_block_nvme->fcp.pbt = IPL_PBT_NVME; 1821 - dump_block_nvme->fcp.opt = IPL_PB0_NVME_OPT_DUMP; 1862 + dump_block_nvme->nvme.len = IPL_BP0_NVME_LEN; 1863 + dump_block_nvme->nvme.pbt = IPL_PBT_NVME; 1864 + dump_block_nvme->nvme.opt = IPL_PB0_NVME_OPT_DUMP; 1822 1865 dump_capabilities |= DUMP_TYPE_NVME; 1823 1866 return 0; 1824 1867 } ··· 1916 1959 * vmcmd shutdown action: Trigger vm command on shutdown. 1917 1960 */ 1918 1961 1919 - static char vmcmd_on_reboot[128]; 1920 - static char vmcmd_on_panic[128]; 1921 - static char vmcmd_on_halt[128]; 1922 - static char vmcmd_on_poff[128]; 1923 - static char vmcmd_on_restart[128]; 1962 + #define VMCMD_MAX_SIZE 240 1963 + 1964 + static char vmcmd_on_reboot[VMCMD_MAX_SIZE + 1]; 1965 + static char vmcmd_on_panic[VMCMD_MAX_SIZE + 1]; 1966 + static char vmcmd_on_halt[VMCMD_MAX_SIZE + 1]; 1967 + static char vmcmd_on_poff[VMCMD_MAX_SIZE + 1]; 1968 + static char vmcmd_on_restart[VMCMD_MAX_SIZE + 1]; 1924 1969 1925 1970 DEFINE_IPL_ATTR_STR_RW(vmcmd, on_reboot, "%s\n", "%s\n", vmcmd_on_reboot); 1926 1971 DEFINE_IPL_ATTR_STR_RW(vmcmd, on_panic, "%s\n", "%s\n", vmcmd_on_panic); ··· 2248 2289 { 2249 2290 if (!MACHINE_IS_VM) 2250 2291 return 1; 2251 - strncpy_skip_quote(vmcmd_on_reboot, str, 127); 2252 - vmcmd_on_reboot[127] = 0; 2292 + strncpy_skip_quote(vmcmd_on_reboot, str, VMCMD_MAX_SIZE); 2293 + vmcmd_on_reboot[VMCMD_MAX_SIZE] = 0; 2253 2294 on_reboot_trigger.action = &vmcmd_action; 2254 2295 return 1; 2255 2296 } ··· 2259 2300 { 2260 2301 if (!MACHINE_IS_VM) 2261 2302 return 1; 2262 - strncpy_skip_quote(vmcmd_on_panic, str, 127); 2263 - vmcmd_on_panic[127] = 0; 2303 + strncpy_skip_quote(vmcmd_on_panic, str, VMCMD_MAX_SIZE); 2304 + vmcmd_on_panic[VMCMD_MAX_SIZE] = 0; 2264 2305 on_panic_trigger.action = &vmcmd_action; 2265 2306 return 1; 2266 2307 } ··· 2270 2311 { 2271 2312 if (!MACHINE_IS_VM) 2272 2313 return 1; 2273 - strncpy_skip_quote(vmcmd_on_halt, str, 127); 2274 - vmcmd_on_halt[127] = 0; 2314 + strncpy_skip_quote(vmcmd_on_halt, str, VMCMD_MAX_SIZE); 2315 + vmcmd_on_halt[VMCMD_MAX_SIZE] = 0; 2275 2316 on_halt_trigger.action = &vmcmd_action; 2276 2317 return 1; 2277 2318 } ··· 2281 2322 { 2282 2323 if (!MACHINE_IS_VM) 2283 2324 return 1; 2284 - strncpy_skip_quote(vmcmd_on_poff, str, 127); 2285 - vmcmd_on_poff[127] = 0; 2325 + strncpy_skip_quote(vmcmd_on_poff, str, VMCMD_MAX_SIZE); 2326 + vmcmd_on_poff[VMCMD_MAX_SIZE] = 0; 2286 2327 on_poff_trigger.action = &vmcmd_action; 2287 2328 return 1; 2288 2329 }
+1
arch/s390/kernel/irq.c
··· 151 151 if (from_idle) 152 152 account_idle_time_irq(); 153 153 154 + set_cpu_flag(CIF_NOHZ_DELAY); 154 155 do { 155 156 regs->tpi_info = S390_lowcore.tpi_info; 156 157 if (S390_lowcore.tpi_info.adapter_IO)
+10 -57
arch/s390/kernel/kprobes.c
··· 24 24 #include <asm/set_memory.h> 25 25 #include <asm/sections.h> 26 26 #include <asm/dis.h> 27 - #include "kprobes.h" 28 27 #include "entry.h" 29 28 30 29 DEFINE_PER_CPU(struct kprobe *, current_kprobe); 31 30 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 32 31 33 32 struct kretprobe_blackpoint kretprobe_blacklist[] = { }; 34 - 35 - static int insn_page_in_use; 36 33 37 34 void *alloc_insn_page(void) 38 35 { ··· 41 44 set_memory_rox((unsigned long)page, 1); 42 45 return page; 43 46 } 44 - 45 - static void *alloc_s390_insn_page(void) 46 - { 47 - if (xchg(&insn_page_in_use, 1) == 1) 48 - return NULL; 49 - return &kprobes_insn_page; 50 - } 51 - 52 - static void free_s390_insn_page(void *page) 53 - { 54 - xchg(&insn_page_in_use, 0); 55 - } 56 - 57 - struct kprobe_insn_cache kprobe_s390_insn_slots = { 58 - .mutex = __MUTEX_INITIALIZER(kprobe_s390_insn_slots.mutex), 59 - .alloc = alloc_s390_insn_page, 60 - .free = free_s390_insn_page, 61 - .pages = LIST_HEAD_INIT(kprobe_s390_insn_slots.pages), 62 - .insn_size = MAX_INSN_SIZE, 63 - }; 64 47 65 48 static void copy_instruction(struct kprobe *p) 66 49 { ··· 55 78 if (probe_is_insn_relative_long(&insn[0])) { 56 79 /* 57 80 * For pc-relative instructions in RIL-b or RIL-c format patch 58 - * the RI2 displacement field. We have already made sure that 59 - * the insn slot for the patched instruction is within the same 60 - * 2GB area as the original instruction (either kernel image or 61 - * module area). Therefore the new displacement will always fit. 81 + * the RI2 displacement field. The insn slot for the to be 82 + * patched instruction is within the same 4GB area like the 83 + * original instruction. Therefore the new displacement will 84 + * always fit. 62 85 */ 63 86 disp = *(s32 *)&insn[1]; 64 87 addr = (u64)(unsigned long)p->addr; ··· 69 92 s390_kernel_write(p->ainsn.insn, &insn, len); 70 93 } 71 94 NOKPROBE_SYMBOL(copy_instruction); 72 - 73 - static int s390_get_insn_slot(struct kprobe *p) 74 - { 75 - /* 76 - * Get an insn slot that is within the same 2GB area like the original 77 - * instruction. That way instructions with a 32bit signed displacement 78 - * field can be patched and executed within the insn slot. 79 - */ 80 - p->ainsn.insn = NULL; 81 - if (is_kernel((unsigned long)p->addr)) 82 - p->ainsn.insn = get_s390_insn_slot(); 83 - else if (is_module_addr(p->addr)) 84 - p->ainsn.insn = get_insn_slot(); 85 - return p->ainsn.insn ? 0 : -ENOMEM; 86 - } 87 - NOKPROBE_SYMBOL(s390_get_insn_slot); 88 - 89 - static void s390_free_insn_slot(struct kprobe *p) 90 - { 91 - if (!p->ainsn.insn) 92 - return; 93 - if (is_kernel((unsigned long)p->addr)) 94 - free_s390_insn_slot(p->ainsn.insn, 0); 95 - else 96 - free_insn_slot(p->ainsn.insn, 0); 97 - p->ainsn.insn = NULL; 98 - } 99 - NOKPROBE_SYMBOL(s390_free_insn_slot); 100 95 101 96 /* Check if paddr is at an instruction boundary */ 102 97 static bool can_probe(unsigned long paddr) ··· 123 174 /* Make sure the probe isn't going on a difficult instruction */ 124 175 if (probe_is_prohibited_opcode(p->addr)) 125 176 return -EINVAL; 126 - if (s390_get_insn_slot(p)) 177 + p->ainsn.insn = get_insn_slot(); 178 + if (!p->ainsn.insn) 127 179 return -ENOMEM; 128 180 copy_instruction(p); 129 181 return 0; ··· 166 216 167 217 void arch_remove_kprobe(struct kprobe *p) 168 218 { 169 - s390_free_insn_slot(p); 219 + if (!p->ainsn.insn) 220 + return; 221 + free_insn_slot(p->ainsn.insn, 0); 222 + p->ainsn.insn = NULL; 170 223 } 171 224 NOKPROBE_SYMBOL(arch_remove_kprobe); 172 225
-9
arch/s390/kernel/kprobes.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0+ */ 2 - #ifndef _ARCH_S390_KPROBES_H 3 - #define _ARCH_S390_KPROBES_H 4 - 5 - #include <linux/kprobes.h> 6 - 7 - DEFINE_INSN_CACHE_OPS(s390_insn); 8 - 9 - #endif
-22
arch/s390/kernel/kprobes_insn_page.S
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - 3 - #include <linux/linkage.h> 4 - 5 - /* 6 - * insn_page is a special 4k aligned dummy function for kprobes. 7 - * It will contain all kprobed instructions that are out-of-line executed. 8 - * The page must be within the kernel image to guarantee that the 9 - * out-of-line instructions are within 2GB distance of their original 10 - * location. Using a dummy function ensures that the insn_page is within 11 - * the text section of the kernel and mapped read-only/executable from 12 - * the beginning on, thus avoiding to split large mappings if the page 13 - * would be in the data section instead. 14 - */ 15 - .section .kprobes.text, "ax" 16 - .balign 4096 17 - SYM_CODE_START(kprobes_insn_page) 18 - .rept 2048 19 - .word 0x07fe 20 - .endr 21 - SYM_CODE_END(kprobes_insn_page) 22 - .previous
+1 -33
arch/s390/kernel/perf_event.c
··· 218 218 void perf_callchain_user(struct perf_callchain_entry_ctx *entry, 219 219 struct pt_regs *regs) 220 220 { 221 - struct stack_frame_user __user *sf; 222 - unsigned long ip, sp; 223 - bool first = true; 224 - 225 - if (is_compat_task()) 226 - return; 227 - perf_callchain_store(entry, instruction_pointer(regs)); 228 - sf = (void __user *)user_stack_pointer(regs); 229 - pagefault_disable(); 230 - while (entry->nr < entry->max_stack) { 231 - if (__get_user(sp, &sf->back_chain)) 232 - break; 233 - if (__get_user(ip, &sf->gprs[8])) 234 - break; 235 - if (ip & 0x1) { 236 - /* 237 - * If the instruction address is invalid, and this 238 - * is the first stack frame, assume r14 has not 239 - * been written to the stack yet. Otherwise exit. 240 - */ 241 - if (first && !(regs->gprs[14] & 0x1)) 242 - ip = regs->gprs[14]; 243 - else 244 - break; 245 - } 246 - perf_callchain_store(entry, ip); 247 - /* Sanity check: ABI requires SP to be aligned 8 bytes. */ 248 - if (!sp || sp & 0x7) 249 - break; 250 - sf = (void __user *)sp; 251 - first = false; 252 - } 253 - pagefault_enable(); 221 + arch_stack_walk_user_common(NULL, NULL, entry, regs, true); 254 222 } 255 223 256 224 /* Perf definitions for PMU event attributes in sysfs */
-5
arch/s390/kernel/process.c
··· 86 86 87 87 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) 88 88 { 89 - /* 90 - * Save the floating-point or vector register state of the current 91 - * task and set the TIF_FPU flag to lazy restore the FPU register 92 - * state when returning to user space. 93 - */ 94 89 save_user_fpu_regs(); 95 90 96 91 *dst = *src;
+1 -1
arch/s390/kernel/setup.c
··· 155 155 EXPORT_SYMBOL(zlib_dfltcc_support); 156 156 u64 __bootdata_preserved(stfle_fac_list[16]); 157 157 EXPORT_SYMBOL(stfle_fac_list); 158 - u64 __bootdata_preserved(alt_stfle_fac_list[16]); 158 + u64 alt_stfle_fac_list[16]; 159 159 struct oldmem_data __bootdata_preserved(oldmem_data); 160 160 161 161 unsigned long VMALLOC_START;
+75 -14
arch/s390/kernel/stacktrace.c
··· 5 5 * Copyright IBM Corp. 2006 6 6 */ 7 7 8 + #include <linux/perf_event.h> 8 9 #include <linux/stacktrace.h> 9 10 #include <linux/uaccess.h> 10 11 #include <linux/compat.h> ··· 63 62 return 0; 64 63 } 65 64 66 - void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, 67 - const struct pt_regs *regs) 65 + static inline bool store_ip(stack_trace_consume_fn consume_entry, void *cookie, 66 + struct perf_callchain_entry_ctx *entry, bool perf, 67 + unsigned long ip) 68 68 { 69 + #ifdef CONFIG_PERF_EVENTS 70 + if (perf) { 71 + if (perf_callchain_store(entry, ip)) 72 + return false; 73 + return true; 74 + } 75 + #endif 76 + return consume_entry(cookie, ip); 77 + } 78 + 79 + static inline bool ip_invalid(unsigned long ip) 80 + { 81 + /* 82 + * Perform some basic checks if an instruction address taken 83 + * from unreliable source is invalid. 84 + */ 85 + if (ip & 1) 86 + return true; 87 + if (ip < mmap_min_addr) 88 + return true; 89 + if (ip >= current->mm->context.asce_limit) 90 + return true; 91 + return false; 92 + } 93 + 94 + static inline bool ip_within_vdso(unsigned long ip) 95 + { 96 + return in_range(ip, current->mm->context.vdso_base, vdso_text_size()); 97 + } 98 + 99 + void arch_stack_walk_user_common(stack_trace_consume_fn consume_entry, void *cookie, 100 + struct perf_callchain_entry_ctx *entry, 101 + const struct pt_regs *regs, bool perf) 102 + { 103 + struct stack_frame_vdso_wrapper __user *sf_vdso; 69 104 struct stack_frame_user __user *sf; 70 105 unsigned long ip, sp; 71 106 bool first = true; 72 107 73 108 if (is_compat_task()) 74 109 return; 75 - if (!consume_entry(cookie, instruction_pointer(regs))) 110 + if (!current->mm) 111 + return; 112 + ip = instruction_pointer(regs); 113 + if (!store_ip(consume_entry, cookie, entry, perf, ip)) 76 114 return; 77 115 sf = (void __user *)user_stack_pointer(regs); 78 116 pagefault_disable(); 79 117 while (1) { 80 118 if (__get_user(sp, &sf->back_chain)) 81 119 break; 82 - if (__get_user(ip, &sf->gprs[8])) 120 + /* 121 + * VDSO entry code has a non-standard stack frame layout. 122 + * See VDSO user wrapper code for details. 123 + */ 124 + if (!sp && ip_within_vdso(ip)) { 125 + sf_vdso = (void __user *)sf; 126 + if (__get_user(ip, &sf_vdso->return_address)) 127 + break; 128 + sp = (unsigned long)sf + STACK_FRAME_VDSO_OVERHEAD; 129 + sf = (void __user *)sp; 130 + if (__get_user(sp, &sf->back_chain)) 131 + break; 132 + } else { 133 + sf = (void __user *)sp; 134 + if (__get_user(ip, &sf->gprs[8])) 135 + break; 136 + } 137 + /* Sanity check: ABI requires SP to be 8 byte aligned. */ 138 + if (sp & 0x7) 83 139 break; 84 - if (ip & 0x1) { 140 + if (ip_invalid(ip)) { 85 141 /* 86 142 * If the instruction address is invalid, and this 87 143 * is the first stack frame, assume r14 has not 88 144 * been written to the stack yet. Otherwise exit. 89 145 */ 90 - if (first && !(regs->gprs[14] & 0x1)) 91 - ip = regs->gprs[14]; 92 - else 146 + if (!first) 147 + break; 148 + ip = regs->gprs[14]; 149 + if (ip_invalid(ip)) 93 150 break; 94 151 } 95 - if (!consume_entry(cookie, ip)) 96 - break; 97 - /* Sanity check: ABI requires SP to be aligned 8 bytes. */ 98 - if (!sp || sp & 0x7) 99 - break; 100 - sf = (void __user *)sp; 152 + if (!store_ip(consume_entry, cookie, entry, perf, ip)) 153 + return; 101 154 first = false; 102 155 } 103 156 pagefault_enable(); 157 + } 158 + 159 + void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, 160 + const struct pt_regs *regs) 161 + { 162 + arch_stack_walk_user_common(consume_entry, cookie, NULL, regs, false); 104 163 } 105 164 106 165 unsigned long return_address(unsigned int n)
+9 -4
arch/s390/kernel/vdso.c
··· 210 210 return addr; 211 211 } 212 212 213 - unsigned long vdso_size(void) 213 + unsigned long vdso_text_size(void) 214 214 { 215 - unsigned long size = VVAR_NR_PAGES * PAGE_SIZE; 215 + unsigned long size; 216 216 217 217 if (is_compat_task()) 218 - size += vdso32_end - vdso32_start; 218 + size = vdso32_end - vdso32_start; 219 219 else 220 - size += vdso64_end - vdso64_start; 220 + size = vdso64_end - vdso64_start; 221 221 return PAGE_ALIGN(size); 222 + } 223 + 224 + unsigned long vdso_size(void) 225 + { 226 + return vdso_text_size() + VVAR_NR_PAGES * PAGE_SIZE; 222 227 } 223 228 224 229 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+3 -1
arch/s390/kernel/vdso32/Makefile
··· 17 17 KBUILD_AFLAGS_32 += -m31 -s 18 18 19 19 KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) 20 + KBUILD_CFLAGS_32 := $(filter-out -mpacked-stack,$(KBUILD_CFLAGS)) 20 21 KBUILD_CFLAGS_32 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_32)) 21 - KBUILD_CFLAGS_32 += -m31 -fPIC -shared -fno-common -fno-builtin 22 + KBUILD_CFLAGS_32 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_32)) 23 + KBUILD_CFLAGS_32 += -m31 -fPIC -shared -fno-common -fno-builtin -fasynchronous-unwind-tables 22 24 23 25 LDFLAGS_vdso32.so.dbg += -shared -soname=linux-vdso32.so.1 \ 24 26 --hash-style=both --build-id=sha1 -melf_s390 -T
+3 -1
arch/s390/kernel/vdso64/Makefile
··· 22 22 KBUILD_AFLAGS_64 += -m64 23 23 24 24 KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) 25 + KBUILD_CFLAGS_64 := $(filter-out -mpacked-stack,$(KBUILD_CFLAGS_64)) 25 26 KBUILD_CFLAGS_64 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_64)) 26 27 KBUILD_CFLAGS_64 := $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_64)) 27 - KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin 28 + KBUILD_CFLAGS_64 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_64)) 29 + KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin -fasynchronous-unwind-tables 28 30 ldflags-y := -shared -soname=linux-vdso64.so.1 \ 29 31 --hash-style=both --build-id=sha1 -T 30 32
+9 -10
arch/s390/kernel/vdso64/vdso_user_wrapper.S
··· 6 6 #include <asm/dwarf.h> 7 7 #include <asm/ptrace.h> 8 8 9 - #define WRAPPER_FRAME_SIZE (STACK_FRAME_OVERHEAD+8) 10 - 11 9 /* 12 10 * Older glibc version called vdso without allocating a stackframe. This wrapper 13 11 * is just used to allocate a stackframe. See ··· 18 20 __ALIGN 19 21 __kernel_\func: 20 22 CFI_STARTPROC 21 - aghi %r15,-WRAPPER_FRAME_SIZE 22 - CFI_DEF_CFA_OFFSET (STACK_FRAME_OVERHEAD + WRAPPER_FRAME_SIZE) 23 - CFI_VAL_OFFSET 15, -STACK_FRAME_OVERHEAD 24 - stg %r14,STACK_FRAME_OVERHEAD(%r15) 25 - CFI_REL_OFFSET 14, STACK_FRAME_OVERHEAD 23 + aghi %r15,-STACK_FRAME_VDSO_OVERHEAD 24 + CFI_DEF_CFA_OFFSET (STACK_FRAME_USER_OVERHEAD + STACK_FRAME_VDSO_OVERHEAD) 25 + CFI_VAL_OFFSET 15,-STACK_FRAME_USER_OVERHEAD 26 + stg %r14,__SFVDSO_RETURN_ADDRESS(%r15) 27 + CFI_REL_OFFSET 14,__SFVDSO_RETURN_ADDRESS 28 + xc __SFUSER_BACKCHAIN(8,%r15),__SFUSER_BACKCHAIN(%r15) 26 29 brasl %r14,__s390_vdso_\func 27 - lg %r14,STACK_FRAME_OVERHEAD(%r15) 30 + lg %r14,__SFVDSO_RETURN_ADDRESS(%r15) 28 31 CFI_RESTORE 14 29 - aghi %r15,WRAPPER_FRAME_SIZE 30 - CFI_DEF_CFA_OFFSET STACK_FRAME_OVERHEAD 32 + aghi %r15,STACK_FRAME_VDSO_OVERHEAD 33 + CFI_DEF_CFA_OFFSET STACK_FRAME_USER_OVERHEAD 31 34 CFI_RESTORE 15 32 35 br %r14 33 36 CFI_ENDPROC
+1 -9
arch/s390/kernel/vtime.c
··· 33 33 static DEFINE_PER_CPU(u64, mt_scaling_div) = { 1 }; 34 34 static DEFINE_PER_CPU(u64, mt_scaling_jiffies); 35 35 36 - static inline u64 get_vtimer(void) 37 - { 38 - u64 timer; 39 - 40 - asm volatile("stpt %0" : "=Q" (timer)); 41 - return timer; 42 - } 43 - 44 36 static inline void set_vtimer(u64 expires) 45 37 { 46 38 u64 timer; ··· 215 223 { 216 224 u64 timer = S390_lowcore.last_update_timer; 217 225 218 - S390_lowcore.last_update_timer = get_vtimer(); 226 + S390_lowcore.last_update_timer = get_cpu_timer(); 219 227 220 228 return timer - S390_lowcore.last_update_timer; 221 229 }
+3 -17
drivers/s390/char/vmlogrdr.c
··· 728 728 struct device *dev; 729 729 int ret; 730 730 731 - dev = kzalloc(sizeof(struct device), GFP_KERNEL); 732 - if (dev) { 733 - dev_set_name(dev, "%s", priv->internal_name); 734 - dev->bus = &iucv_bus; 735 - dev->parent = iucv_root; 736 - dev->driver = &vmlogrdr_driver; 737 - dev->groups = vmlogrdr_attr_groups; 738 - dev_set_drvdata(dev, priv); 739 - /* 740 - * The release function could be called after the 741 - * module has been unloaded. It's _only_ task is to 742 - * free the struct. Therefore, we specify kfree() 743 - * directly here. (Probably a little bit obfuscating 744 - * but legitime ...). 745 - */ 746 - dev->release = (void (*)(struct device *))kfree; 747 - } else 731 + dev = iucv_alloc_device(vmlogrdr_attr_groups, &vmlogrdr_driver, 732 + priv, priv->internal_name); 733 + if (!dev) 748 734 return -ENOMEM; 749 735 ret = device_register(dev); 750 736 if (ret) {
-1
drivers/s390/cio/airq.c
··· 90 90 struct airq_struct *airq; 91 91 struct hlist_head *head; 92 92 93 - set_cpu_flag(CIF_NOHZ_DELAY); 94 93 tpi_info = &get_irq_regs()->tpi_info; 95 94 trace_s390_cio_adapter_int(tpi_info); 96 95 head = &airq_lists[tpi_info->isc];
-1
drivers/s390/cio/cio.c
··· 535 535 struct subchannel *sch; 536 536 struct irb *irb; 537 537 538 - set_cpu_flag(CIF_NOHZ_DELAY); 539 538 tpi_info = &get_irq_regs()->tpi_info; 540 539 trace_s390_cio_interrupt(tpi_info); 541 540 irb = this_cpu_ptr(&cio_irb);
+8 -2
drivers/s390/crypto/ap_bus.c
··· 732 732 if (bound == apqns) { 733 733 if (!completion_done(&ap_apqn_bindings_complete)) { 734 734 complete_all(&ap_apqn_bindings_complete); 735 + ap_send_bindings_complete_uevent(); 735 736 pr_debug("%s all apqn bindings complete\n", __func__); 736 737 } 737 - ap_send_bindings_complete_uevent(); 738 738 } 739 739 } 740 740 } ··· 893 893 if (!!devres != !!drvres) 894 894 goto out; 895 895 } 896 + 897 + /* 898 + * Rearm the bindings complete completion to trigger 899 + * bindings complete when all devices are bound again 900 + */ 901 + reinit_completion(&ap_apqn_bindings_complete); 896 902 897 903 /* Add queue/card to list of active queues/cards */ 898 904 spin_lock_bh(&ap_queues_lock); ··· 1097 1091 */ 1098 1092 static int modify_bitmap(const char *str, unsigned long *bitmap, int bits) 1099 1093 { 1100 - int a, i, z; 1094 + unsigned long a, i, z; 1101 1095 char *np, sign; 1102 1096 1103 1097 /* bits needs to be a multiple of 8 */
+51 -58
drivers/s390/crypto/pkey_api.c
··· 1359 1359 rc = cca_genseckey(kgs.cardnr, kgs.domain, 1360 1360 kgs.keytype, kgs.seckey.seckey); 1361 1361 pr_debug("%s cca_genseckey()=%d\n", __func__, rc); 1362 - if (rc) 1363 - break; 1364 - if (copy_to_user(ugs, &kgs, sizeof(kgs))) 1365 - return -EFAULT; 1362 + if (!rc && copy_to_user(ugs, &kgs, sizeof(kgs))) 1363 + rc = -EFAULT; 1364 + memzero_explicit(&kgs, sizeof(kgs)); 1366 1365 break; 1367 1366 } 1368 1367 case PKEY_CLR2SECK: { ··· 1373 1374 rc = cca_clr2seckey(kcs.cardnr, kcs.domain, kcs.keytype, 1374 1375 kcs.clrkey.clrkey, kcs.seckey.seckey); 1375 1376 pr_debug("%s cca_clr2seckey()=%d\n", __func__, rc); 1376 - if (rc) 1377 - break; 1378 - if (copy_to_user(ucs, &kcs, sizeof(kcs))) 1379 - return -EFAULT; 1377 + if (!rc && copy_to_user(ucs, &kcs, sizeof(kcs))) 1378 + rc = -EFAULT; 1380 1379 memzero_explicit(&kcs, sizeof(kcs)); 1381 1380 break; 1382 1381 } ··· 1389 1392 ksp.seckey.seckey, ksp.protkey.protkey, 1390 1393 &ksp.protkey.len, &ksp.protkey.type); 1391 1394 pr_debug("%s cca_sec2protkey()=%d\n", __func__, rc); 1392 - if (rc) 1393 - break; 1394 - if (copy_to_user(usp, &ksp, sizeof(ksp))) 1395 - return -EFAULT; 1395 + if (!rc && copy_to_user(usp, &ksp, sizeof(ksp))) 1396 + rc = -EFAULT; 1397 + memzero_explicit(&ksp, sizeof(ksp)); 1396 1398 break; 1397 1399 } 1398 1400 case PKEY_CLR2PROTK: { ··· 1405 1409 kcp.protkey.protkey, 1406 1410 &kcp.protkey.len, &kcp.protkey.type); 1407 1411 pr_debug("%s pkey_clr2protkey()=%d\n", __func__, rc); 1408 - if (rc) 1409 - break; 1410 - if (copy_to_user(ucp, &kcp, sizeof(kcp))) 1411 - return -EFAULT; 1412 + if (!rc && copy_to_user(ucp, &kcp, sizeof(kcp))) 1413 + rc = -EFAULT; 1412 1414 memzero_explicit(&kcp, sizeof(kcp)); 1413 1415 break; 1414 1416 } ··· 1435 1441 rc = pkey_skey2pkey(ksp.seckey.seckey, ksp.protkey.protkey, 1436 1442 &ksp.protkey.len, &ksp.protkey.type); 1437 1443 pr_debug("%s pkey_skey2pkey()=%d\n", __func__, rc); 1438 - if (rc) 1439 - break; 1440 - if (copy_to_user(usp, &ksp, sizeof(ksp))) 1441 - return -EFAULT; 1444 + if (!rc && copy_to_user(usp, &ksp, sizeof(ksp))) 1445 + rc = -EFAULT; 1446 + memzero_explicit(&ksp, sizeof(ksp)); 1442 1447 break; 1443 1448 } 1444 1449 case PKEY_VERIFYKEY: { ··· 1449 1456 rc = pkey_verifykey(&kvk.seckey, &kvk.cardnr, &kvk.domain, 1450 1457 &kvk.keysize, &kvk.attributes); 1451 1458 pr_debug("%s pkey_verifykey()=%d\n", __func__, rc); 1452 - if (rc) 1453 - break; 1454 - if (copy_to_user(uvk, &kvk, sizeof(kvk))) 1455 - return -EFAULT; 1459 + if (!rc && copy_to_user(uvk, &kvk, sizeof(kvk))) 1460 + rc = -EFAULT; 1461 + memzero_explicit(&kvk, sizeof(kvk)); 1456 1462 break; 1457 1463 } 1458 1464 case PKEY_GENPROTK: { ··· 1464 1472 rc = pkey_genprotkey(kgp.keytype, kgp.protkey.protkey, 1465 1473 &kgp.protkey.len, &kgp.protkey.type); 1466 1474 pr_debug("%s pkey_genprotkey()=%d\n", __func__, rc); 1467 - if (rc) 1468 - break; 1469 - if (copy_to_user(ugp, &kgp, sizeof(kgp))) 1470 - return -EFAULT; 1475 + if (!rc && copy_to_user(ugp, &kgp, sizeof(kgp))) 1476 + rc = -EFAULT; 1477 + memzero_explicit(&kgp, sizeof(kgp)); 1471 1478 break; 1472 1479 } 1473 1480 case PKEY_VERIFYPROTK: { ··· 1478 1487 rc = pkey_verifyprotkey(kvp.protkey.protkey, 1479 1488 kvp.protkey.len, kvp.protkey.type); 1480 1489 pr_debug("%s pkey_verifyprotkey()=%d\n", __func__, rc); 1490 + memzero_explicit(&kvp, sizeof(kvp)); 1481 1491 break; 1482 1492 } 1483 1493 case PKEY_KBLOB2PROTK: { ··· 1495 1503 rc = pkey_keyblob2pkey(kkey, ktp.keylen, ktp.protkey.protkey, 1496 1504 &ktp.protkey.len, &ktp.protkey.type); 1497 1505 pr_debug("%s pkey_keyblob2pkey()=%d\n", __func__, rc); 1498 - memzero_explicit(kkey, ktp.keylen); 1499 - kfree(kkey); 1500 - if (rc) 1501 - break; 1502 - if (copy_to_user(utp, &ktp, sizeof(ktp))) 1503 - return -EFAULT; 1506 + kfree_sensitive(kkey); 1507 + if (!rc && copy_to_user(utp, &ktp, sizeof(ktp))) 1508 + rc = -EFAULT; 1509 + memzero_explicit(&ktp, sizeof(ktp)); 1504 1510 break; 1505 1511 } 1506 1512 case PKEY_GENSECK2: { ··· 1524 1534 pr_debug("%s pkey_genseckey2()=%d\n", __func__, rc); 1525 1535 kfree(apqns); 1526 1536 if (rc) { 1527 - kfree(kkey); 1537 + kfree_sensitive(kkey); 1528 1538 break; 1529 1539 } 1530 1540 if (kgs.key) { 1531 1541 if (kgs.keylen < klen) { 1532 - kfree(kkey); 1542 + kfree_sensitive(kkey); 1533 1543 return -EINVAL; 1534 1544 } 1535 1545 if (copy_to_user(kgs.key, kkey, klen)) { 1536 - kfree(kkey); 1546 + kfree_sensitive(kkey); 1537 1547 return -EFAULT; 1538 1548 } 1539 1549 } 1540 1550 kgs.keylen = klen; 1541 1551 if (copy_to_user(ugs, &kgs, sizeof(kgs))) 1542 1552 rc = -EFAULT; 1543 - kfree(kkey); 1553 + kfree_sensitive(kkey); 1544 1554 break; 1545 1555 } 1546 1556 case PKEY_CLR2SECK2: { ··· 1553 1563 if (copy_from_user(&kcs, ucs, sizeof(kcs))) 1554 1564 return -EFAULT; 1555 1565 apqns = _copy_apqns_from_user(kcs.apqns, kcs.apqn_entries); 1556 - if (IS_ERR(apqns)) 1566 + if (IS_ERR(apqns)) { 1567 + memzero_explicit(&kcs, sizeof(kcs)); 1557 1568 return PTR_ERR(apqns); 1569 + } 1558 1570 kkey = kzalloc(klen, GFP_KERNEL); 1559 1571 if (!kkey) { 1560 1572 kfree(apqns); 1573 + memzero_explicit(&kcs, sizeof(kcs)); 1561 1574 return -ENOMEM; 1562 1575 } 1563 1576 rc = pkey_clr2seckey2(apqns, kcs.apqn_entries, ··· 1569 1576 pr_debug("%s pkey_clr2seckey2()=%d\n", __func__, rc); 1570 1577 kfree(apqns); 1571 1578 if (rc) { 1572 - kfree(kkey); 1579 + kfree_sensitive(kkey); 1580 + memzero_explicit(&kcs, sizeof(kcs)); 1573 1581 break; 1574 1582 } 1575 1583 if (kcs.key) { 1576 1584 if (kcs.keylen < klen) { 1577 - kfree(kkey); 1585 + kfree_sensitive(kkey); 1586 + memzero_explicit(&kcs, sizeof(kcs)); 1578 1587 return -EINVAL; 1579 1588 } 1580 1589 if (copy_to_user(kcs.key, kkey, klen)) { 1581 - kfree(kkey); 1590 + kfree_sensitive(kkey); 1591 + memzero_explicit(&kcs, sizeof(kcs)); 1582 1592 return -EFAULT; 1583 1593 } 1584 1594 } ··· 1589 1593 if (copy_to_user(ucs, &kcs, sizeof(kcs))) 1590 1594 rc = -EFAULT; 1591 1595 memzero_explicit(&kcs, sizeof(kcs)); 1592 - kfree(kkey); 1596 + kfree_sensitive(kkey); 1593 1597 break; 1594 1598 } 1595 1599 case PKEY_VERIFYKEY2: { ··· 1606 1610 &kvk.cardnr, &kvk.domain, 1607 1611 &kvk.type, &kvk.size, &kvk.flags); 1608 1612 pr_debug("%s pkey_verifykey2()=%d\n", __func__, rc); 1609 - kfree(kkey); 1613 + kfree_sensitive(kkey); 1610 1614 if (rc) 1611 1615 break; 1612 1616 if (copy_to_user(uvk, &kvk, sizeof(kvk))) ··· 1636 1640 &ktp.protkey.type); 1637 1641 pr_debug("%s pkey_keyblob2pkey2()=%d\n", __func__, rc); 1638 1642 kfree(apqns); 1639 - memzero_explicit(kkey, ktp.keylen); 1640 - kfree(kkey); 1641 - if (rc) 1642 - break; 1643 - if (copy_to_user(utp, &ktp, sizeof(ktp))) 1644 - return -EFAULT; 1643 + kfree_sensitive(kkey); 1644 + if (!rc && copy_to_user(utp, &ktp, sizeof(ktp))) 1645 + rc = -EFAULT; 1646 + memzero_explicit(&ktp, sizeof(ktp)); 1645 1647 break; 1646 1648 } 1647 1649 case PKEY_APQNS4K: { ··· 1667 1673 rc = pkey_apqns4key(kkey, kak.keylen, kak.flags, 1668 1674 apqns, &nr_apqns); 1669 1675 pr_debug("%s pkey_apqns4key()=%d\n", __func__, rc); 1670 - kfree(kkey); 1676 + kfree_sensitive(kkey); 1671 1677 if (rc && rc != -ENOSPC) { 1672 1678 kfree(apqns); 1673 1679 break; ··· 1753 1759 protkey = kmalloc(protkeylen, GFP_KERNEL); 1754 1760 if (!protkey) { 1755 1761 kfree(apqns); 1756 - kfree(kkey); 1762 + kfree_sensitive(kkey); 1757 1763 return -ENOMEM; 1758 1764 } 1759 1765 rc = pkey_keyblob2pkey3(apqns, ktp.apqn_entries, ··· 1761 1767 protkey, &protkeylen, &ktp.pkeytype); 1762 1768 pr_debug("%s pkey_keyblob2pkey3()=%d\n", __func__, rc); 1763 1769 kfree(apqns); 1764 - memzero_explicit(kkey, ktp.keylen); 1765 - kfree(kkey); 1770 + kfree_sensitive(kkey); 1766 1771 if (rc) { 1767 - kfree(protkey); 1772 + kfree_sensitive(protkey); 1768 1773 break; 1769 1774 } 1770 1775 if (ktp.pkey && ktp.pkeylen) { 1771 1776 if (protkeylen > ktp.pkeylen) { 1772 - kfree(protkey); 1777 + kfree_sensitive(protkey); 1773 1778 return -EINVAL; 1774 1779 } 1775 1780 if (copy_to_user(ktp.pkey, protkey, protkeylen)) { 1776 - kfree(protkey); 1781 + kfree_sensitive(protkey); 1777 1782 return -EFAULT; 1778 1783 } 1779 1784 } 1780 - kfree(protkey); 1785 + kfree_sensitive(protkey); 1781 1786 ktp.pkeylen = protkeylen; 1782 1787 if (copy_to_user(utp, &ktp, sizeof(ktp))) 1783 1788 return -EFAULT;
+3 -6
drivers/s390/crypto/zcrypt_api.c
··· 1300 1300 struct zcrypt_device_status_ext *stat; 1301 1301 int card, queue; 1302 1302 1303 - memset(devstatus, 0, MAX_ZDEV_ENTRIES_EXT 1304 - * sizeof(struct zcrypt_device_status_ext)); 1305 - 1306 1303 spin_lock(&zcrypt_list_lock); 1307 1304 for_each_zcrypt_card(zc) { 1308 1305 for_each_zcrypt_queue(zq, zc) { ··· 1604 1607 size_t total_size = MAX_ZDEV_ENTRIES_EXT 1605 1608 * sizeof(struct zcrypt_device_status_ext); 1606 1609 1607 - device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT, 1608 - sizeof(struct zcrypt_device_status_ext), 1609 - GFP_KERNEL); 1610 + device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT, 1611 + sizeof(struct zcrypt_device_status_ext), 1612 + GFP_KERNEL); 1610 1613 if (!device_status) 1611 1614 return -ENOMEM; 1612 1615 zcrypt_device_status_mask_ext(device_status);
+6 -6
drivers/s390/crypto/zcrypt_ccamisc.c
··· 1762 1762 return -EINVAL; 1763 1763 1764 1764 /* fetch status of all crypto cards */ 1765 - device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT, 1766 - sizeof(struct zcrypt_device_status_ext), 1767 - GFP_KERNEL); 1765 + device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT, 1766 + sizeof(struct zcrypt_device_status_ext), 1767 + GFP_KERNEL); 1768 1768 if (!device_status) 1769 1769 return -ENOMEM; 1770 1770 zcrypt_device_status_mask_ext(device_status); ··· 1878 1878 struct cca_info ci; 1879 1879 1880 1880 /* fetch status of all crypto cards */ 1881 - device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT, 1882 - sizeof(struct zcrypt_device_status_ext), 1883 - GFP_KERNEL); 1881 + device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT, 1882 + sizeof(struct zcrypt_device_status_ext), 1883 + GFP_KERNEL); 1884 1884 if (!device_status) 1885 1885 return -ENOMEM; 1886 1886 zcrypt_device_status_mask_ext(device_status);
+3 -3
drivers/s390/crypto/zcrypt_ep11misc.c
··· 1588 1588 struct ep11_card_info eci; 1589 1589 1590 1590 /* fetch status of all crypto cards */ 1591 - device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT, 1592 - sizeof(struct zcrypt_device_status_ext), 1593 - GFP_KERNEL); 1591 + device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT, 1592 + sizeof(struct zcrypt_device_status_ext), 1593 + GFP_KERNEL); 1594 1594 if (!device_status) 1595 1595 return -ENOMEM; 1596 1596 zcrypt_device_status_mask_ext(device_status);
+4 -16
drivers/s390/net/netiucv.c
··· 1696 1696 static int netiucv_register_device(struct net_device *ndev) 1697 1697 { 1698 1698 struct netiucv_priv *priv = netdev_priv(ndev); 1699 - struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL); 1699 + struct device *dev; 1700 1700 int ret; 1701 1701 1702 1702 IUCV_DBF_TEXT(trace, 3, __func__); 1703 1703 1704 - if (dev) { 1705 - dev_set_name(dev, "net%s", ndev->name); 1706 - dev->bus = &iucv_bus; 1707 - dev->parent = iucv_root; 1708 - dev->groups = netiucv_attr_groups; 1709 - /* 1710 - * The release function could be called after the 1711 - * module has been unloaded. It's _only_ task is to 1712 - * free the struct. Therefore, we specify kfree() 1713 - * directly here. (Probably a little bit obfuscating 1714 - * but legitime ...). 1715 - */ 1716 - dev->release = (void (*)(struct device *))kfree; 1717 - dev->driver = &netiucv_driver; 1718 - } else 1704 + dev = iucv_alloc_device(netiucv_attr_groups, &netiucv_driver, NULL, 1705 + "net%s", ndev->name); 1706 + if (!dev) 1719 1707 return -ENOMEM; 1720 1708 1721 1709 ret = device_register(dev);
+5 -16
drivers/s390/net/smsgiucv_app.c
··· 156 156 if (!MACHINE_IS_VM) 157 157 return -ENODEV; 158 158 159 - smsg_app_dev = kzalloc(sizeof(*smsg_app_dev), GFP_KERNEL); 159 + smsgiucv_drv = driver_find(SMSGIUCV_DRV_NAME, &iucv_bus); 160 + if (!smsgiucv_drv) 161 + return -ENODEV; 162 + 163 + smsg_app_dev = iucv_alloc_device(NULL, smsgiucv_drv, NULL, KMSG_COMPONENT); 160 164 if (!smsg_app_dev) 161 165 return -ENOMEM; 162 166 163 - smsgiucv_drv = driver_find(SMSGIUCV_DRV_NAME, &iucv_bus); 164 - if (!smsgiucv_drv) { 165 - kfree(smsg_app_dev); 166 - return -ENODEV; 167 - } 168 - 169 - rc = dev_set_name(smsg_app_dev, KMSG_COMPONENT); 170 - if (rc) { 171 - kfree(smsg_app_dev); 172 - goto fail; 173 - } 174 - smsg_app_dev->bus = &iucv_bus; 175 - smsg_app_dev->parent = iucv_root; 176 - smsg_app_dev->release = (void (*)(struct device *)) kfree; 177 - smsg_app_dev->driver = smsgiucv_drv; 178 167 rc = device_register(smsg_app_dev); 179 168 if (rc) { 180 169 put_device(smsg_app_dev);
+2 -13
drivers/tty/hvc/hvc_iucv.c
··· 1035 1035 NULL, 1036 1036 }; 1037 1037 1038 - static void hvc_iucv_free(struct device *data) 1039 - { 1040 - kfree(data); 1041 - } 1042 - 1043 1038 /** 1044 1039 * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance 1045 1040 * @id: hvc_iucv_table index ··· 1085 1090 memcpy(priv->srv_name, name, 8); 1086 1091 ASCEBC(priv->srv_name, 8); 1087 1092 1088 - /* create and setup device */ 1089 - priv->dev = kzalloc(sizeof(*priv->dev), GFP_KERNEL); 1093 + priv->dev = iucv_alloc_device(hvc_iucv_dev_attr_groups, NULL, 1094 + priv, "hvc_iucv%d", id); 1090 1095 if (!priv->dev) { 1091 1096 rc = -ENOMEM; 1092 1097 goto out_error_dev; 1093 1098 } 1094 - dev_set_name(priv->dev, "hvc_iucv%d", id); 1095 - dev_set_drvdata(priv->dev, priv); 1096 - priv->dev->bus = &iucv_bus; 1097 - priv->dev->parent = iucv_root; 1098 - priv->dev->groups = hvc_iucv_dev_attr_groups; 1099 - priv->dev->release = hvc_iucv_free; 1100 1099 rc = device_register(priv->dev); 1101 1100 if (rc) { 1102 1101 put_device(priv->dev);
+6 -1
include/net/iucv/iucv.h
··· 82 82 } __attribute__ ((aligned (8))); 83 83 84 84 extern const struct bus_type iucv_bus; 85 - extern struct device *iucv_root; 85 + 86 + struct device_driver; 87 + 88 + struct device *iucv_alloc_device(const struct attribute_group **attrs, 89 + struct device_driver *driver, void *priv, 90 + const char *fmt, ...) __printf(4, 5); 86 91 87 92 /* 88 93 * struct iucv_path
+36 -2
net/iucv/iucv.c
··· 73 73 }; 74 74 EXPORT_SYMBOL(iucv_bus); 75 75 76 - struct device *iucv_root; 77 - EXPORT_SYMBOL(iucv_root); 76 + static struct device *iucv_root; 77 + 78 + static void iucv_release_device(struct device *device) 79 + { 80 + kfree(device); 81 + } 82 + 83 + struct device *iucv_alloc_device(const struct attribute_group **attrs, 84 + struct device_driver *driver, 85 + void *priv, const char *fmt, ...) 86 + { 87 + struct device *dev; 88 + va_list vargs; 89 + int rc; 90 + 91 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 92 + if (!dev) 93 + goto out_error; 94 + va_start(vargs, fmt); 95 + rc = dev_set_name(dev, fmt, vargs); 96 + va_end(vargs); 97 + if (rc) 98 + goto out_error; 99 + dev->bus = &iucv_bus; 100 + dev->parent = iucv_root; 101 + dev->driver = driver; 102 + dev->groups = attrs; 103 + dev->release = iucv_release_device; 104 + dev_set_drvdata(dev, priv); 105 + return dev; 106 + 107 + out_error: 108 + kfree(dev); 109 + return NULL; 110 + } 111 + EXPORT_SYMBOL(iucv_alloc_device); 78 112 79 113 static int iucv_available; 80 114
+1 -1
scripts/Makefile.vdsoinst
··· 20 20 $$(call cmd,install) 21 21 22 22 # Some architectures create .build-id symlinks 23 - ifneq ($(filter arm sparc x86, $(SRCARCH)),) 23 + ifneq ($(filter arm s390 sparc x86, $(SRCARCH)),) 24 24 link := $(install-dir)/.build-id/$$(shell $(READELF) -n $(1) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p').debug 25 25 26 26 __default: $$(link)