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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Tue,  6 May 2014 17:26:45 -0300
From:	Fabio Estevam <festevam@...il.com>
To:	mturquette@...aro.org
Cc:	linux-kernel@...r.kernel.org, shawn.guo@...escale.com,
	kernel@...gutronix.de, maxime.coquelin@...com,
	linux-arm-kernel@...ts.infradead.org,
	Fabio Estevam <fabio.estevam@...escale.com>
Subject: [PATCH] clk: clk-divider: Fix infinite loop for table divider

From: Fabio Estevam <fabio.estevam@...escale.com>

Since commit e7489693b3 (clk: divider: Optimize clk_divider_bestdiv loop) we 
notice a system hang on mx6qboard.

The cause for the hang is well explained by Sascha Hauer [1]:

"This cannot work. _round_up_table is implemented like this:

static int _round_up_table(const struct clk_div_table *table, int div)
{
        const struct clk_div_table *clkt;
        int up = _get_table_maxdiv(table);

        for (clkt = table; clkt->div; clkt++) {
                if (clkt->div == div)
                        return clkt->div;
                ...
        }
        ...
}

Here when a table entry matches the input div this function will return
exactly the input div. This means _next_div() will always return the
same value and clk_divider_bestdiv() has an infinite loop:

        for (i = 1; i <= maxdiv; i = _next_div(divider, i)) {
                ...
        } 
"
[1] http://marc.info/?l=linux-arm-kernel&m=139940658726253&w=2

Remove the 'return _round_up_table' so that the system can work normally again.

Signed-off-by: Fabio Estevam <fabio.estevam@...escale.com>
---
 drivers/clk/clk-divider.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index b3c8396..fc3e344 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -246,8 +246,6 @@ static int _next_div(struct clk_divider *divider, int div)
 
 	if (divider->flags & CLK_DIVIDER_POWER_OF_TWO)
 		return __roundup_pow_of_two(div);
-	if (divider->table)
-		return _round_up_table(divider->table, div);
 
 	return div;
 }
-- 
1.8.3.2

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ