From: Mark Rutland <mark.rutland@arm.com>
To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: Matthew Wilcox <willy@infradead.org>,
Courtney Cavin <courtney.cavin@sonymobile.com>,
Bjorn Andersson <bjorn.andersson@linaro.org>
Subject: Preemptible idr_alloc() in QRTR code
Date: Tue, 26 Jan 2021 10:47:34 +0000 [thread overview]
Message-ID: <20210126104734.GB80448@C02TD0UTHF1T.local> (raw)
Hi,
When fuzzing arm64 with Syzkaller, I'm seeing some splats where
this_cpu_ptr() is used in the bowels of idr_alloc(), by way of
radix_tree_node_alloc(), in a preemptible context:
| BUG: using smp_processor_id() in preemptible [00000000] code: syz-executor.1/32582
| caller is debug_smp_processor_id+0x24/0x30
| CPU: 3 PID: 32582 Comm: syz-executor.1 Not tainted 5.11.0-rc4-next-20210125-00001-gf57e7edf910d #3
| Hardware name: linux,dummy-virt (DT)
| Call trace:
| dump_backtrace+0x0/0x4a8
| show_stack+0x34/0x88
| dump_stack+0x1d4/0x2a0
| check_preemption_disabled+0x1b8/0x210
| debug_smp_processor_id+0x24/0x30
| radix_tree_node_alloc.constprop.17+0x26c/0x3d0
| radix_tree_extend+0x200/0x420
| idr_get_free+0x63c/0xa38
| idr_alloc_u32+0x164/0x2a0
| __qrtr_bind.isra.8+0x350/0x658
| qrtr_bind+0x18c/0x218
| __sys_bind+0x1fc/0x238
| __arm64_sys_bind+0x78/0xb0
| el0_svc_common+0x1ac/0x4c8
| do_el0_svc+0xfc/0x150
| el0_svc+0x24/0x38
| el0_sync_handler+0x134/0x180
| el0_sync+0x154/0x180
It's not clear to me whether this is a bug in the caller or a bug the
implementation of idr_alloc(). The kerneldoc for idr_alloc() mentions
that callers must provide their own locking (and in this case a mutex is
used), but doesn't mention that preemption must be disabled.
Is this an intentional requirement that's simply missing from the
documentation and requires a change to the QRTR code, or is this
something to fix within the bowels of idr_alloc() and its callees?
Thanks,
Mark.
next reply other threads:[~2021-01-26 11:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 10:47 Mark Rutland [this message]
2021-01-26 14:58 ` Preemptible idr_alloc() in QRTR code Matthew Wilcox
2021-01-26 16:21 ` Mark Rutland
2021-01-26 17:00 ` Bjorn Andersson
2021-01-26 18:36 ` Mark Rutland
2021-01-27 0:41 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210126104734.GB80448@C02TD0UTHF1T.local \
--to=mark.rutland@arm.com \
--cc=bjorn.andersson@linaro.org \
--cc=courtney.cavin@sonymobile.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).