From: Marc Zyngier <maz@kernel.org>
To: Ben Dooks <ben.dooks@codethink.co.uk>
Cc: linux-kernel@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] irqdomain: check irq mapping against domain size
Date: Fri, 05 Nov 2021 12:09:22 +0000 [thread overview]
Message-ID: <87y262953h.wl-maz@kernel.org> (raw)
In-Reply-To: <20211105090601.243416-1-ben.dooks@codethink.co.uk>
Hi Ben,
On Fri, 05 Nov 2021 09:06:01 +0000,
Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>
> The irq translate code does not check the irq number against
> the maximum a domain can handle. This can cause an OOPS if
> the firmware data has been damaged in any way. Check the intspec
> or fwdata against the irqdomain and return -EINVAL if over.
>
> This is the result of bug somewhere in the boot of a SiFive Unmatched
> board where the 5th argument of the pcie node is being damaged which
> causes an OOPS in the startup code.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> kernel/irq/irqdomain.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 6284443b87ec..e61397420723 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -906,6 +906,8 @@ int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
> {
> if (WARN_ON(intsize < 1))
> return -EINVAL;
> + if (WARN_ON(intspec[0] > d->hwirq_max))
> + return -EINVAL;
This doesn't seem right.
For a start, d->hwirq_max is 0 when the domain is backed by a radix
tree. Also, nothing says that what you read from the DT is something
that should be directly meaningful to the irqdomain. A driver could
well call into this and perform some extra processing on the data
before it lands into the irqdomain.
In general, this looks like DT validation code, and I'm not keen on
that in the core code.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2021-11-05 12:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-05 9:06 [PATCH] irqdomain: check irq mapping against domain size Ben Dooks
2021-11-05 12:09 ` Marc Zyngier [this message]
2021-12-13 16:07 ` Ben Dooks
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=87y262953h.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=ben.dooks@codethink.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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