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: <5149E296.1030304@wwwdotorg.org>
Date:	Wed, 20 Mar 2013 10:23:50 -0600
From:	Stephen Warren <swarren@...dotorg.org>
To:	Richard Genoud <richard.genoud@...il.com>
CC:	Linus Walleij <linus.walleij@...aro.org>,
	Axel Lin <axel.lin@...ics.com>,
	Stephen Warren <swarren@...dia.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] BUG: [RFC] pinctrl: pins are freed 2 times in pinctrl_bind_pins

On 03/20/2013 05:31 AM, Richard Genoud wrote:
> 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.

The correct fix here is not to skip the call to devm_pinctrl_put(),
since that undoes a lot of other things besides the current state selection.

Instead, pinctrl_select_state_locked() needs to be fixed so that:

a)

Change "p->state = state;" to "p->state = NULL;" or similar, to indicate
that no state is selected. (Please validate if a NULL value in that
variable will cause problems elsewhere)

b)

Add back the assignment "p->state = state;" at the end of the function,
if no error occurred.

c)

Fix the list_for_each_entry() call that applies all the settings for the
new state so that if it fails, it undoes everything that it's applied so
far. That's the hard part, unless there's a
list_for_each_entry_before_the_current_one_that_list_for_each_entry_iterated_over_already()
macro!
--
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