Skip to content

Commit

Permalink
Merge tag 'locking-urgent-2021-07-11' of git://git.kernel.org/pub/scm…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
Linus Torvalds committed Jul 11, 2021
2 parents 8b9cc17 + 7e10887 commit 301c8b1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion arch/sparc/include/asm/cmpxchg_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
#define arch_cmpxchg64_local(ptr, o, n) \
({ \
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
cmpxchg_local((ptr), (o), (n)); \
arch_cmpxchg_local((ptr), (o), (n)); \
})
#define arch_cmpxchg64(ptr, o, n) arch_cmpxchg64_local((ptr), (o), (n))

Expand Down
13 changes: 8 additions & 5 deletions kernel/jump_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,16 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end)
}

static int __jump_label_text_reserved(struct jump_entry *iter_start,
struct jump_entry *iter_stop, void *start, void *end)
struct jump_entry *iter_stop, void *start, void *end, bool init)
{
struct jump_entry *iter;

iter = iter_start;
while (iter < iter_stop) {
if (addr_conflict(iter, start, end))
return 1;
if (init || !jump_entry_is_init(iter)) {
if (addr_conflict(iter, start, end))
return 1;
}
iter++;
}

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

ret = __jump_label_text_reserved(mod->jump_entries,
mod->jump_entries + mod->num_jump_entries,
start, end);
start, end, mod->state == MODULE_STATE_COMING);

module_put(mod);

Expand Down Expand Up @@ -788,8 +790,9 @@ early_initcall(jump_label_init_module);
*/
int jump_label_text_reserved(void *start, void *end)
{
bool init = system_state < SYSTEM_RUNNING;
int ret = __jump_label_text_reserved(__start___jump_table,
__stop___jump_table, start, end);
__stop___jump_table, start, end, init);

if (ret)
return ret;
Expand Down
2 changes: 2 additions & 0 deletions kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/ftrace.h>
#include <linux/cpu.h>
#include <linux/jump_label.h>
#include <linux/static_call.h>
#include <linux/perf_event.h>

#include <asm/sections.h>
Expand Down Expand Up @@ -1561,6 +1562,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
if (!kernel_text_address((unsigned long) p->addr) ||
within_kprobe_blacklist((unsigned long) p->addr) ||
jump_label_text_reserved(p->addr, p->addr) ||
static_call_text_reserved(p->addr, p->addr) ||
find_bug((unsigned long)p->addr)) {
ret = -EINVAL;
goto out;
Expand Down
26 changes: 14 additions & 12 deletions kernel/locking/lockdep_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,28 @@ static int l_show(struct seq_file *m, void *v)
#ifdef CONFIG_DEBUG_LOCKDEP
seq_printf(m, " OPS:%8ld", debug_class_ops_read(class));
#endif
#ifdef CONFIG_PROVE_LOCKING
seq_printf(m, " FD:%5ld", lockdep_count_forward_deps(class));
seq_printf(m, " BD:%5ld", lockdep_count_backward_deps(class));
#endif
if (IS_ENABLED(CONFIG_PROVE_LOCKING)) {
seq_printf(m, " FD:%5ld", lockdep_count_forward_deps(class));
seq_printf(m, " BD:%5ld", lockdep_count_backward_deps(class));

get_usage_chars(class, usage);
seq_printf(m, " %s", usage);
get_usage_chars(class, usage);
seq_printf(m, " %s", usage);
}

seq_printf(m, ": ");
print_name(m, class);
seq_puts(m, "\n");

list_for_each_entry(entry, &class->locks_after, entry) {
if (entry->distance == 1) {
seq_printf(m, " -> [%p] ", entry->class->key);
print_name(m, entry->class);
seq_puts(m, "\n");
if (IS_ENABLED(CONFIG_PROVE_LOCKING)) {
list_for_each_entry(entry, &class->locks_after, entry) {
if (entry->distance == 1) {
seq_printf(m, " -> [%p] ", entry->class->key);
print_name(m, entry->class);
seq_puts(m, "\n");
}
}
seq_puts(m, "\n");
}
seq_puts(m, "\n");

return 0;
}
Expand Down
13 changes: 8 additions & 5 deletions kernel/static_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end)

static int __static_call_text_reserved(struct static_call_site *iter_start,
struct static_call_site *iter_stop,
void *start, void *end)
void *start, void *end, bool init)
{
struct static_call_site *iter = iter_start;

while (iter < iter_stop) {
if (addr_conflict(iter, start, end))
return 1;
if (init || !static_call_is_init(iter)) {
if (addr_conflict(iter, start, end))
return 1;
}
iter++;
}

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

ret = __static_call_text_reserved(mod->static_call_sites,
mod->static_call_sites + mod->num_static_call_sites,
start, end);
start, end, mod->state == MODULE_STATE_COMING);

module_put(mod);

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

int static_call_text_reserved(void *start, void *end)
{
bool init = system_state < SYSTEM_RUNNING;
int ret = __static_call_text_reserved(__start_static_call_sites,
__stop_static_call_sites, start, end);
__stop_static_call_sites, start, end, init);

if (ret)
return ret;
Expand Down

0 comments on commit 301c8b1

Please sign in to comment.