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]
Date:	Wed, 20 Mar 2013 12:31:53 +0100
From:	Richard Genoud <richard.genoud@...il.com>
To:	Linus Walleij <linus.walleij@...aro.org>
Cc:	Axel Lin <axel.lin@...ics.com>,
	Stephen Warren <swarren@...dia.com>,
	linux-kernel@...r.kernel.org,
	Richard Genoud <richard.genoud@...il.com>
Subject: [PATCH] BUG: [RFC] pinctrl: pins are freed 2 times in pinctrl_bind_pins

If the function pinctrl_select_state() fails because one pin is already
taken elsewhere, pinmux_enable_setting makes all the necessary pin_free
calls (and not more than necessary).
The problem here is that devm_pinctrl_put() will be called on the pin
group, and each pin in this group has already been freed.

Example:
If a i2c function has already sucessfully taken pins 5 and 6.
And now, pinctrl_bind_pins() is called for function PHY (pins 3 4 5 6 7).
pinmux_enable_setting() will fail AND call pin_free on necessary pins.
But if devm_pinctrl_put() is called, it will call again pin_free on pins
3 4 5 6 7.
So, the pins 5 and 6 will be released (and pins 3 4 7 double freed).
Which means that even if the i2c function has claim the pins, they will
be available for other functions.

This patch simply doesn't call devm_pinctrl_put when
pinctrl_select_state fails, but I'm not sure it's the right thing to do.

Signed-off-by: Richard Genoud <richard.genoud@...il.com>
---
 drivers/base/pinctrl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/base/pinctrl.c b/drivers/base/pinctrl.c
index 67a274e..537406d 100644
--- a/drivers/base/pinctrl.c
+++ b/drivers/base/pinctrl.c
@@ -45,7 +45,7 @@ int pinctrl_bind_pins(struct device *dev)
 	ret = pinctrl_select_state(dev->pins->p, dev->pins->default_state);
 	if (ret) {
 		dev_dbg(dev, "failed to activate default pinctrl state\n");
-		goto cleanup_get;
+		goto cleanup_alloc; /* pins already un-muxed */
 	}
 
 	return 0;
-- 
1.7.2.5

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