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: <20221018-clk-range-checks-fixes-v1-4-f3ef80518140@cerno.tech>
Date:   Tue, 18 Oct 2022 15:52:59 +0200
From:   Maxime Ripard <maxime@...no.tech>
To:     Stephen Boyd <sboyd@...nel.org>,
        Michael Turquette <mturquette@...libre.com>
Cc:     linux-kernel@...r.kernel.org,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        Maxime Ripard <maxime@...no.tech>, linux-clk@...r.kernel.org
Subject: [PATCH 4/4] clk: Warn if we register a mux without determine_rate

The determine_rate hook allows to select the proper parent and its rate
for a given clock configuration. On another hand, set_parent is there to
change the parent of a mux.

Some clocks provide a set_parent hook but don't implement
determine_rate. In such a case, set_parent is pretty much useless since
the clock framework will always assume the current parent is to be used,
and we will thus never change it.

This situation can be solved in two ways:
  - either we don't need to change the parent, and we thus shouldn't
    implement set_parent;
  - or we don't want to change the parent, in this case we should set
    CLK_SET_RATE_NO_REPARENT;
  - or we're missing a determine_rate implementation.

The latter is probably just an oversight from the driver's author, and
we should thus raise their awareness about the fact that the current
state of the driver is confusing.

It's not clear at this point how many drivers are affected though, so
let's make it a warning instead of an error for now.

Signed-off-by: Maxime Ripard <maxime@...no.tech>
---
 drivers/clk/clk.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 57b83665e5c3..11c41d987ff4 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3700,6 +3700,11 @@ static int __clk_core_init(struct clk_core *core)
 		goto out;
 	}
 
+	/* TODO: Promote to an error */
+	if (core->ops->set_parent && !core->ops->determine_rate)
+		pr_warn("%s: %s must implement .set_parent & .determine_rate\n",
+			__func__, core->name);
+
 	if (core->num_parents > 1 && !core->ops->get_parent) {
 		pr_err("%s: %s must implement .get_parent as it has multi parents\n",
 		       __func__, core->name);

-- 
b4 0.11.0-dev-7da52

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ