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 'pstore-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull pstore updates from Kees Cook:

- fix ftrace dump when ECC is enabled (Andrey Skvortsov)

- fix resource leak when ioremap() fails (Cole Leavitt)

- Remove useless memblock header (Guilherme G. Piccoli)

- Fix ECC parameter help text (Guilherme G. Piccoli)

- Keep ftrace module parameter and debugfs switch in sync (Guilherme G.
Piccoli)

- Factor KASLR offset in the core kernel instruction addresses
(Guilherme G. Piccoli)

* tag 'pstore-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
pstore/ftrace: Factor KASLR offset in the core kernel instruction addresses
pstore/ftrace: Keep ftrace module parameter and debugfs switch in sync
pstore/ram: fix resource leak when ioremap() fails
pstore/ramoops: Fix ECC parameter help text
pstore/ramoops: Remove useless memblock header
pstore: fix ftrace dump, when ECC is enabled

+49 -20
+35 -13
fs/pstore/ftrace.c
··· 18 18 #include <linux/cache.h> 19 19 #include <linux/slab.h> 20 20 #include <asm/barrier.h> 21 + #include <asm/setup.h> 21 22 #include "internal.h" 22 23 23 24 /* This doesn't need to be atomic: speed is chosen over correctness here. */ 24 25 static u64 pstore_ftrace_stamp; 26 + 27 + static inline unsigned long adjust_ip(unsigned long ip) 28 + { 29 + #if defined(CONFIG_RANDOMIZE_BASE) && !defined(PSTORE_CPU_IN_IP) && IS_BUILTIN(CONFIG_PSTORE) 30 + if (core_kernel_text(ip)) 31 + return ip - kaslr_offset(); 32 + 33 + __clear_bit(BITS_PER_LONG - 1, &ip); 34 + #endif 35 + return ip; 36 + } 37 + 38 + inline unsigned long decode_ip(unsigned long ip) 39 + { 40 + #if defined(CONFIG_RANDOMIZE_BASE) && !defined(PSTORE_CPU_IN_IP) && IS_BUILTIN(CONFIG_PSTORE) 41 + if (test_bit(BITS_PER_LONG - 1, &ip)) 42 + return ip + kaslr_offset(); 43 + 44 + __set_bit(BITS_PER_LONG - 1, &ip); 45 + 46 + #endif 47 + return ip; 48 + } 25 49 26 50 static void notrace pstore_ftrace_call(unsigned long ip, 27 51 unsigned long parent_ip, ··· 71 47 72 48 local_irq_save(flags); 73 49 74 - rec.ip = ip; 75 - rec.parent_ip = parent_ip; 50 + rec.ip = adjust_ip(ip); 51 + rec.parent_ip = adjust_ip(parent_ip); 76 52 pstore_ftrace_write_timestamp(&rec, pstore_ftrace_stamp++); 77 53 pstore_ftrace_encode_cpu(&rec, raw_smp_processor_id()); 78 54 psinfo->write(&record); ··· 86 62 }; 87 63 88 64 static DEFINE_MUTEX(pstore_ftrace_lock); 89 - static bool pstore_ftrace_enabled; 65 + static bool record_ftrace; 66 + module_param(record_ftrace, bool, 0400); 67 + MODULE_PARM_DESC(record_ftrace, 68 + "enable ftrace recording immediately (default: off)"); 90 69 91 70 static int pstore_set_ftrace_enabled(bool on) 92 71 { 93 72 ssize_t ret; 94 73 95 - if (on == pstore_ftrace_enabled) 74 + if (on == record_ftrace) 96 75 return 0; 97 76 98 77 if (on) { ··· 109 82 pr_err("%s: unable to %sregister ftrace ops: %zd\n", 110 83 __func__, on ? "" : "un", ret); 111 84 } else { 112 - pstore_ftrace_enabled = on; 85 + record_ftrace = on; 113 86 } 114 87 115 88 return ret; ··· 138 111 static ssize_t pstore_ftrace_knob_read(struct file *f, char __user *buf, 139 112 size_t count, loff_t *ppos) 140 113 { 141 - char val[] = { '0' + pstore_ftrace_enabled, '\n' }; 114 + char val[] = { '0' + record_ftrace, '\n' }; 142 115 143 116 return simple_read_from_buffer(buf, count, ppos, val, sizeof(val)); 144 117 } ··· 150 123 }; 151 124 152 125 static struct dentry *pstore_ftrace_dir; 153 - 154 - static bool record_ftrace; 155 - module_param(record_ftrace, bool, 0400); 156 - MODULE_PARM_DESC(record_ftrace, 157 - "enable ftrace recording immediately (default: off)"); 158 126 159 127 void pstore_register_ftrace(void) 160 128 { ··· 167 145 void pstore_unregister_ftrace(void) 168 146 { 169 147 mutex_lock(&pstore_ftrace_lock); 170 - if (pstore_ftrace_enabled) { 148 + if (record_ftrace) { 171 149 unregister_ftrace_function(&pstore_ftrace_ops); 172 - pstore_ftrace_enabled = false; 150 + record_ftrace = false; 173 151 } 174 152 mutex_unlock(&pstore_ftrace_lock); 175 153
+7 -5
fs/pstore/inode.c
··· 74 74 if (!data) 75 75 return NULL; 76 76 77 - data->off = ps->total_size % REC_SIZE; 77 + data->off = ps->record->size % REC_SIZE; 78 78 data->off += *pos * REC_SIZE; 79 - if (data->off + REC_SIZE > ps->total_size) 79 + if (data->off + REC_SIZE > ps->record->size) 80 80 return NULL; 81 81 82 82 return_ptr(data); ··· 94 94 95 95 (*pos)++; 96 96 data->off += REC_SIZE; 97 - if (data->off + REC_SIZE > ps->total_size) 97 + if (data->off + REC_SIZE > ps->record->size) 98 98 return NULL; 99 99 100 100 return data; ··· 105 105 struct pstore_private *ps = s->private; 106 106 struct pstore_ftrace_seq_data *data = v; 107 107 struct pstore_ftrace_record *rec; 108 + unsigned long ip, parent_ip; 108 109 109 110 if (!data) 110 111 return 0; 111 112 112 113 rec = (struct pstore_ftrace_record *)(ps->record->buf + data->off); 113 114 115 + ip = decode_ip(rec->ip); 116 + parent_ip = decode_ip(rec->parent_ip); 114 117 seq_printf(s, "CPU:%d ts:%llu %08lx %08lx %ps <- %pS\n", 115 118 pstore_ftrace_decode_cpu(rec), 116 119 pstore_ftrace_read_timestamp(rec), 117 - rec->ip, rec->parent_ip, (void *)rec->ip, 118 - (void *)rec->parent_ip); 120 + ip, parent_ip, (void *)ip, (void *)parent_ip); 119 121 120 122 return 0; 121 123 }
+2
fs/pstore/internal.h
··· 9 9 extern unsigned int kmsg_bytes; 10 10 11 11 #ifdef CONFIG_PSTORE_FTRACE 12 + extern unsigned long decode_ip(unsigned long ip); 12 13 extern void pstore_register_ftrace(void); 13 14 extern void pstore_unregister_ftrace(void); 14 15 ssize_t pstore_ftrace_combine_log(char **dest_log, size_t *dest_log_size, ··· 17 16 #else 18 17 static inline void pstore_register_ftrace(void) {} 19 18 static inline void pstore_unregister_ftrace(void) {} 19 + static inline unsigned long decode_ip(unsigned long ip) { return ip; } 20 20 static inline ssize_t 21 21 pstore_ftrace_combine_log(char **dest_log, size_t *dest_log_size, 22 22 const char *src_log, size_t src_log_size)
+1 -1
fs/pstore/ram.c
··· 71 71 72 72 static int ramoops_ecc; 73 73 module_param_named(ecc, ramoops_ecc, int, 0400); 74 - MODULE_PARM_DESC(ramoops_ecc, 74 + MODULE_PARM_DESC(ecc, 75 75 "if non-zero, the option enables ECC support and specifies " 76 76 "ECC buffer size in bytes (1 is a special value, means 16 " 77 77 "bytes ECC)");
+4 -1
fs/pstore/ram_core.c
··· 12 12 #include <linux/io.h> 13 13 #include <linux/kernel.h> 14 14 #include <linux/list.h> 15 - #include <linux/memblock.h> 16 15 #include <linux/rslib.h> 17 16 #include <linux/slab.h> 18 17 #include <linux/uaccess.h> ··· 486 487 va = ioremap(start, size); 487 488 else 488 489 va = ioremap_wc(start, size); 490 + 491 + /* We must release the mem region if ioremap fails. */ 492 + if (!va) 493 + release_mem_region(start, size); 489 494 490 495 /* 491 496 * Since request_mem_region() and ioremap() are byte-granularity