lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210128104627.76b35a5c@slackpad.fritz.box>
Date:   Thu, 28 Jan 2021 11:11:28 +0000
From:   Andre Przywara <andre.przywara@....com>
To:     Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:     Maxime Ripard <mripard@...nel.org>, Chen-Yu Tsai <wens@...e.org>,
        Jernej Skrabec <jernej.skrabec@...l.net>,
        Samuel Holland <samuel@...lland.org>,
        Icenowy Zheng <icenowy@...c.io>, Rob Herring <robh@...nel.org>,
        Clément Péron <peron.clem@...il.com>,
        Shuosheng Huang <huangshuosheng@...winnertech.com>,
        Yangtao Li <tiny.windzz@...il.com>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        linux-sunxi@...glegroups.com, Lee Jones <lee.jones@...aro.org>,
        linux-input@...r.kernel.org, Mark Brown <broonie@...nel.org>
Subject: Re: [PATCH v5 05/20] Input: axp20x-pek: Bail out if AXP has no
 interrupt line connected

On Wed, 27 Jan 2021 11:42:15 -0800
Dmitry Torokhov <dmitry.torokhov@...il.com> wrote:

Hi Dmitry,

thanks for your feedback!

> On Wed, Jan 27, 2021 at 05:24:45PM +0000, Andre Przywara wrote:
> > On at least one board (Orangepi Zero2) the AXP305 PMIC does not have its
> > interrupt line connected to the CPU (mostly because the H616 SoC does
> > not feature an NMI pin anymore).
> > After allowing the AXP driver to proceed without an "interrupts"
> > property [1], the axp20x-pek driver crashes with a NULL pointer
> > dereference (see below).
> > 
> > Check for the regmap_irqc member to be not NULL before proceeding with
> > probe. This gets normally filled by the call to regmap_add_irq_chip(),
> > which we allow to skip now, when the DT node lacks an interrupt
> > property.  
> 
> No, the driver is not the right place to patch this; regmap should be
> fixed so it does not crash instead.

I am not sure this is the right approach, those regmap functions look
more like an internal interface to me, with lots of wrapper functions
happily dereferencing pointers and reaching into structs. Moving
NULL checks into those does not sound like the right thing. CC:ing Mark
for more opinions on this.

A more general solution would be to not instantiate this driver here
at all, when we don't have an interrupt line.
However at the moment the AXP MFD driver uses a const struct to hold
all MFD cells, so there is no easy way of omitting the power key
device dynamically. And even then it would hard code the requirement
for an interrupt into the MFD driver, when this could be considered an
implementation detail of the axp20x-pek driver.

That's why I came up with this patch here, which was the easiest and
cleanest: This driver *requires* a valid regmap_irqc, so it should
verify this at probe time, kind of like a normal driver would bail out
if no IRQ line could be reserved.

Let me know what you think!

Cheers,
Andre

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ