Skip to content

Commit 301c8b1

Browse files
committed
Merge tag 'locking-urgent-2021-07-11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fixes from Ingo Molnar: - Fix a Sparc crash - Fix a number of objtool warnings - Fix /proc/lockdep output on certain configs - Restore a kprobes fail-safe * tag 'locking-urgent-2021-07-11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: locking/atomic: sparc: Fix arch_cmpxchg64_local() kprobe/static_call: Restore missing static_call_text_reserved() static_call: Fix static_call_text_reserved() vs __init jump_label: Fix jump_label_text_reserved() vs __init locking/lockdep: Fix meaningless /proc/lockdep output of lock classes on !CONFIG_PROVE_LOCKING
2 parents 8b9cc17 + 7e10887 commit 301c8b1

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

arch/sparc/include/asm/cmpxchg_64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
201201
#define arch_cmpxchg64_local(ptr, o, n) \
202202
({ \
203203
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
204-
cmpxchg_local((ptr), (o), (n)); \
204+
arch_cmpxchg_local((ptr), (o), (n)); \
205205
})
206206
#define arch_cmpxchg64(ptr, o, n) arch_cmpxchg64_local((ptr), (o), (n))
207207

kernel/jump_label.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,16 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end)
316316
}
317317

318318
static int __jump_label_text_reserved(struct jump_entry *iter_start,
319-
struct jump_entry *iter_stop, void *start, void *end)
319+
struct jump_entry *iter_stop, void *start, void *end, bool init)
320320
{
321321
struct jump_entry *iter;
322322

323323
iter = iter_start;
324324
while (iter < iter_stop) {
325-
if (addr_conflict(iter, start, end))
326-
return 1;
325+
if (init || !jump_entry_is_init(iter)) {
326+
if (addr_conflict(iter, start, end))
327+
return 1;
328+
}
327329
iter++;
328330
}
329331

@@ -562,7 +564,7 @@ static int __jump_label_mod_text_reserved(void *start, void *end)
562564

563565
ret = __jump_label_text_reserved(mod->jump_entries,
564566
mod->jump_entries + mod->num_jump_entries,
565-
start, end);
567+
start, end, mod->state == MODULE_STATE_COMING);
566568

567569
module_put(mod);
568570

@@ -788,8 +790,9 @@ early_initcall(jump_label_init_module);
788790
*/
789791
int jump_label_text_reserved(void *start, void *end)
790792
{
793+
bool init = system_state < SYSTEM_RUNNING;
791794
int ret = __jump_label_text_reserved(__start___jump_table,
792-
__stop___jump_table, start, end);
795+
__stop___jump_table, start, end, init);
793796

794797
if (ret)
795798
return ret;

kernel/kprobes.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/ftrace.h>
3636
#include <linux/cpu.h>
3737
#include <linux/jump_label.h>
38+
#include <linux/static_call.h>
3839
#include <linux/perf_event.h>
3940

4041
#include <asm/sections.h>
@@ -1561,6 +1562,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
15611562
if (!kernel_text_address((unsigned long) p->addr) ||
15621563
within_kprobe_blacklist((unsigned long) p->addr) ||
15631564
jump_label_text_reserved(p->addr, p->addr) ||
1565+
static_call_text_reserved(p->addr, p->addr) ||
15641566
find_bug((unsigned long)p->addr)) {
15651567
ret = -EINVAL;
15661568
goto out;

kernel/locking/lockdep_proc.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,28 @@ static int l_show(struct seq_file *m, void *v)
7070
#ifdef CONFIG_DEBUG_LOCKDEP
7171
seq_printf(m, " OPS:%8ld", debug_class_ops_read(class));
7272
#endif
73-
#ifdef CONFIG_PROVE_LOCKING
74-
seq_printf(m, " FD:%5ld", lockdep_count_forward_deps(class));
75-
seq_printf(m, " BD:%5ld", lockdep_count_backward_deps(class));
76-
#endif
73+
if (IS_ENABLED(CONFIG_PROVE_LOCKING)) {
74+
seq_printf(m, " FD:%5ld", lockdep_count_forward_deps(class));
75+
seq_printf(m, " BD:%5ld", lockdep_count_backward_deps(class));
7776

78-
get_usage_chars(class, usage);
79-
seq_printf(m, " %s", usage);
77+
get_usage_chars(class, usage);
78+
seq_printf(m, " %s", usage);
79+
}
8080

8181
seq_printf(m, ": ");
8282
print_name(m, class);
8383
seq_puts(m, "\n");
8484

85-
list_for_each_entry(entry, &class->locks_after, entry) {
86-
if (entry->distance == 1) {
87-
seq_printf(m, " -> [%p] ", entry->class->key);
88-
print_name(m, entry->class);
89-
seq_puts(m, "\n");
85+
if (IS_ENABLED(CONFIG_PROVE_LOCKING)) {
86+
list_for_each_entry(entry, &class->locks_after, entry) {
87+
if (entry->distance == 1) {
88+
seq_printf(m, " -> [%p] ", entry->class->key);
89+
print_name(m, entry->class);
90+
seq_puts(m, "\n");
91+
}
9092
}
93+
seq_puts(m, "\n");
9194
}
92-
seq_puts(m, "\n");
9395

9496
return 0;
9597
}

kernel/static_call.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end)
292292

293293
static int __static_call_text_reserved(struct static_call_site *iter_start,
294294
struct static_call_site *iter_stop,
295-
void *start, void *end)
295+
void *start, void *end, bool init)
296296
{
297297
struct static_call_site *iter = iter_start;
298298

299299
while (iter < iter_stop) {
300-
if (addr_conflict(iter, start, end))
301-
return 1;
300+
if (init || !static_call_is_init(iter)) {
301+
if (addr_conflict(iter, start, end))
302+
return 1;
303+
}
302304
iter++;
303305
}
304306

@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserved(void *start, void *end)
324326

325327
ret = __static_call_text_reserved(mod->static_call_sites,
326328
mod->static_call_sites + mod->num_static_call_sites,
327-
start, end);
329+
start, end, mod->state == MODULE_STATE_COMING);
328330

329331
module_put(mod);
330332

@@ -459,8 +461,9 @@ static inline int __static_call_mod_text_reserved(void *start, void *end)
459461

460462
int static_call_text_reserved(void *start, void *end)
461463
{
464+
bool init = system_state < SYSTEM_RUNNING;
462465
int ret = __static_call_text_reserved(__start_static_call_sites,
463-
__stop_static_call_sites, start, end);
466+
__stop_static_call_sites, start, end, init);
464467

465468
if (ret)
466469
return ret;

0 commit comments

Comments
 (0)