Re: next-20191122: qemu arm64: WARNING: suspicious RCU usage
From: Masami Hiramatsu
Date: Sun Dec 01 2019 - 21:24:46 EST
Hello,
Sorry for replying so late.
On Fri, 22 Nov 2019 22:43:56 +0100
Anders Roxell <anders.roxell@xxxxxxxxxx> wrote:
> Hi,
>
> I'm seeing the following warning when I'm booting an arm64 allmodconfig
> kernel [1] on linux-next; tag next-20191122, is this anything you've seen
> before ?
>
> The code seems to have introduced a long time ago and the warning was
> added recently 28875945ba98 ("rcu: Add support for consolidated-RCU
> reader checking").
I've never seen this but the warning itself is justified.
struct kprobe *get_kprobe(void *addr)
{
struct hlist_head *head;
struct kprobe *p;
head = &kprobe_table[hash_ptr(addr, KPROBE_HASH_BITS)];
hlist_for_each_entry_rcu(p, head, hlist) { <---- this cause the warning
if (p->addr == addr)
return p;
}
return NULL;
}
The kprobe_table itself is protected by kprobe_mutex OR rcu.
If the caller locks the kprobe_mutex, we can safely access the hash
table, this is what the register_kprobe does. If not, the caller must
disable preemption, this happens when a kprobe (breakpoint) is hit.
Thus, the kernel itself is safe, but it should be fixed.
Thank you,
--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>