hwrng: geode: fix accessing registers
PATCH 1/1 hwrng: geode: fix accessing registers
When the membase and pci_dev pointer were moved to a new struct in priv, the actual membase users were left untouched, and they started reading out arbitrary memory behind the struct instead of registers. This unfortunately turned the RNG into a constant number generator, depending on the content of what was at that offset.
To fix this, update geode_rng_data_{read,present}() to also get the membase via amd_geode_priv, and properly read from the right addresses again.
--- drivers/char/hw_random/geode-rng.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/char/hw_random/geode-rng.c +4 -2
@@ -58,7 +58,8 @@ struct amd_geode_priv {static int geode_rng_data_read (struct hwrng *rng,u32 *data) { -void __iomem *mem = (void __iomem *)rng->priv; +struct amd_geode_priv *priv = (struct amd_geode_priv *)rng->priv; +void __iomem *mem = priv->membase; *data =readl (mem +GEODE_RNG_DATA_REG );
@@ -67,7 +68,8 @@ static int geode_rng_data_read(struct hwrng *rng, u32 *data)static int geode_rng_data_present (struct hwrng *rng,int wait) { -void __iomem *mem = (void __iomem *)rng->priv; +struct amd_geode_priv *priv = (struct amd_geode_priv *)rng->priv; +void __iomem *mem = priv->membase;int data, i;for (i =0 ; i <20 ; i++) {
Signature · 1 line
2.34.1
Herbert Xu
maintainerQuoted 16 lines · Jonas Gorski
When the membase and
pci_devpointer were moved to a new struct in priv, the actual membase users were left untouched, and they started reading out arbitrary memory behind the struct instead of registers. This unfortunately turned the RNG into a constant number generator, depending on the content of what was at that offset.To fix this, update geode_rng_data_{read,present}() to also get the membase via
amd_geode_priv, and properly read from the right addresses again.Fixes 9f6ec8dc574e ("hwrng: geode - Fix PCI device refcount leak")Reported-by Timur I. Davletshin <[email protected]>Tested-by Timur I. Davletshin <[email protected]>Suggested-by Jo-Philipp Wich <[email protected]>Signed-off-by Jonas Gorski <[email protected]>
Quoted 3 lines
--- drivers/char/hw_random/geode-rng.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Hi Herbert,
Quoted 22 lines · Herbert Xu
Quoted 16 lines · Jonas Gorski
When the membase and
pci_devpointer were moved to a new struct in priv, the actual membase users were left untouched, and they started reading out arbitrary memory behind the struct instead of registers. This unfortunately turned the RNG into a constant number generator, depending on the content of what was at that offset.To fix this, update geode_rng_data_{read,present}() to also get the membase via
amd_geode_priv, and properly read from the right addresses again.Fixes 9f6ec8dc574e ("hwrng: geode - Fix PCI device refcount leak")Reported-by Timur I. Davletshin <[email protected]>Tested-by Timur I. Davletshin <[email protected]>Suggested-by Jo-Philipp Wich <[email protected]>Signed-off-by Jonas Gorski <[email protected]>Quoted 3 lines
--- drivers/char/hw_random/geode-rng.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 1 line
Patch applied. Thanks.
Where was it applied? I don't see it neither in linus' tree nor in char-misc. Wondering if it got stuck somewhere.
Best Regards,
Jonas
Herbert Xu
maintainerQuoted 3 lines · Jonas Gorski
Where was it applied? I don't see it neither in linus' tree nor in char-misc. Wondering if it got stuck somewhere.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt