[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2173063.OarFjbCqhk@wuerfel>
Date: Wed, 13 May 2015 22:48:19 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Brian Norris <computersforpeace@...il.com>
Cc: linux-mtd@...ts.infradead.org, Dmitry Torokhov <dtor@...gle.com>,
Anatol Pomazao <anatol@...gle.com>,
Ray Jui <rjui@...adcom.com>,
Corneliu Doban <cdoban@...adcom.com>,
Jonathan Richardson <jonathar@...adcom.com>,
Scott Branden <sbranden@...adcom.com>,
Florian Fainelli <f.fainelli@...il.com>,
Rafał Miłecki <zajec5@...il.com>,
bcm-kernel-feedback-list@...adcom.com,
Dan Ehrenberg <dehrenberg@...omium.org>,
Gregory Fong <gregory.0xf0@...il.com>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Kevin Cernekee <cernekee@...il.com>
Subject: Re: [PATCH v4 08/11] mtd: brcmnand: add BCM63138 support
On Wednesday 13 May 2015 13:24:15 Brian Norris wrote:
> > >
> > > static int bcm63138_nand_probe(...)
> > > {
> > > struct bcm63138_nand_soc *priv;
> > >
> > > priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > > ...
> > > return brcmnand_probe(pdev, &priv->soc);
> > > }
> >
> > That would make struct brcmnand_soc an empty structure, right?
>
> No, it still contains the function pointers for our callbacks, which is
> the entire point. I guess it's more of a 'nand_soc_ops' structure than a
> 'nand_soc' pointer now though.
>
Ah, I see.
This is fine for a small number of function pointers, but if you ever
get a structure like this with a lot of pointers, it's better to
keep them separate, so you can define the structure of function pointers
as 'static const' in the client driver, as we do for a number of
other operations.
The main advantage of that is that you don't have to assign the members
manually at run-time, but also putting them into the read-only segment
makes it harder for an attacker to overwrite a known function pointer
with a pointer to an exploit (assuming they have limited control over
writing to kernel memory).
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists